MSC2/Script/cyclic playback of multiple timelines

Hi colleagues,

please tell me how to do a cyclic playback of several timelines?

Parents
  • Do you want to randomly play one timeline after another or when one ends another starts?
  • The task is follows:
    There is BPS device with 8 battons
    Button_1-Cyclic Play Timeline_1
    .
    .
    Button_4-Cyclic Play Timeline_4
    Button_5-Cyclic play of timelines from 1 to 4
    Buttons should have a type "Radiobutton"
  • Hello,

     Like almost every situation in Mosaic, there are multiple ways to accomplish this.  Below is one method (you'll notice, I was working with a Tessera, you'll need to adjust for BPS input and output).

     

    Startup Trigger executing script

    playlistSequences ={   
    --[[button 1]]            {1},
    --[[button 2]]            {2},
    --[[button 3]]            {3},
    --[[button 4]]            {4},
    --[[button 5]]            {3, 2, 3, 2, 3, 2, 4, 1}
                       }

    timelineList = {}               -- to be populated by complete list of timelines referenced by all playlists
    function build_timeline_list()
        for m = 1, #playlistSequences, 1 do
        -- go one playlist at a time
            for j = 1, #playlistSequences[m], 1 do
            -- go one timeline at a time
                if not timelineList[playlistSequences[m][j]] then
                -- we don't already have this one in the complete list, add it
                    timelineList[playlistSequences[m][j]] = true
                end
            end
        end
    end
    build_timeline_list()           -- build the list now


    function set_radio_button (activeButton)
    -- used to light only one button at a time
        for i = 1, 8, 1 do
            if i == activeButton then
            -- turn on the active one
                set_control_state(string.format("button%03d",i), "Green Highlight")
            else
            -- turn off all the others
                set_control_state(string.format("button%03d",i), "Red Dim")
            end
        end
    end

    function fire_solo_timeline (timelineNum)
    -- used to release any other running timelines in timelineList and start just the one we want to keep
        -- add a conditional check if you don't want to restart a timeline that's currently running
        get_timeline(timelineNum):start()
        for key, value in ipairs(timelineList) do
        -- step through all timelines (timelineList keys contain the timeline numbers)
            if key ~= timelineNum then
            -- release any affecting output that aren't the one we're starting
                state = get_timeline(key).state
                if state ~= Timeline.NONE and state ~= Timeline.RELEASED then
                    get_timeline(key):release()
                end
            end
        end
    end

    function fire_next_timeline (currentTimeline)
    -- used to fire the appropriate timeline based on current mode and prior timeline
        -- some modes just loop one timeline
        local nextTimeline = currentTimeline
        if #playlistSequences[currentPlaylist] > 1 then
        -- more than 1 timeline means we need to figure out what's next
            -- find next slot (or first slot if we're at the end)
            currentSlot = (currentSlot % #playlistSequences[currentPlaylist]) + 1
            nextTimeline = playlistSequences[currentPlaylist][currentSlot]
        end
        fire_solo_timeline(nextTimeline)
    end

    function handle_button (buttonNum)
        if buttonNum < 1 or buttonNum > #playlistSequences then
        -- only defined playlists are valid input
            return nil
        elseif buttonNum == currentPlaylist then
        -- we're already doing this
            return nil
        else
        -- buttons start their respective playlists with first timelines
            currentSlot = 1
            fire_solo_timeline(playlistSequences[buttonNum][currentSlot])
        end
        -- set the proper indicators on/off
        set_radio_button(buttonNum)
        -- store mode for later
        currentPlaylist = buttonNum
    end


    currentPlaylist = 0             -- which playlist is currently being used
    currentSlot = 0                 -- which slot in the playlist is currently being used


    set_radio_button(currentPlaylist)

     

    Touch Button Event trigger for any button, capturing button<3d> executing script

    local incomingButton = get_trigger_variable(1).integer 
    handle_button(incomingButton)

     

    Timeline Ended trigger for any timeline executing script

    local endingTimeline = get_trigger_variable(1).integer
    fire_next_timeline(endingTimeline)
Reply
  • Hello,

     Like almost every situation in Mosaic, there are multiple ways to accomplish this.  Below is one method (you'll notice, I was working with a Tessera, you'll need to adjust for BPS input and output).

     

    Startup Trigger executing script

    playlistSequences ={   
    --[[button 1]]            {1},
    --[[button 2]]            {2},
    --[[button 3]]            {3},
    --[[button 4]]            {4},
    --[[button 5]]            {3, 2, 3, 2, 3, 2, 4, 1}
                       }

    timelineList = {}               -- to be populated by complete list of timelines referenced by all playlists
    function build_timeline_list()
        for m = 1, #playlistSequences, 1 do
        -- go one playlist at a time
            for j = 1, #playlistSequences[m], 1 do
            -- go one timeline at a time
                if not timelineList[playlistSequences[m][j]] then
                -- we don't already have this one in the complete list, add it
                    timelineList[playlistSequences[m][j]] = true
                end
            end
        end
    end
    build_timeline_list()           -- build the list now


    function set_radio_button (activeButton)
    -- used to light only one button at a time
        for i = 1, 8, 1 do
            if i == activeButton then
            -- turn on the active one
                set_control_state(string.format("button%03d",i), "Green Highlight")
            else
            -- turn off all the others
                set_control_state(string.format("button%03d",i), "Red Dim")
            end
        end
    end

    function fire_solo_timeline (timelineNum)
    -- used to release any other running timelines in timelineList and start just the one we want to keep
        -- add a conditional check if you don't want to restart a timeline that's currently running
        get_timeline(timelineNum):start()
        for key, value in ipairs(timelineList) do
        -- step through all timelines (timelineList keys contain the timeline numbers)
            if key ~= timelineNum then
            -- release any affecting output that aren't the one we're starting
                state = get_timeline(key).state
                if state ~= Timeline.NONE and state ~= Timeline.RELEASED then
                    get_timeline(key):release()
                end
            end
        end
    end

    function fire_next_timeline (currentTimeline)
    -- used to fire the appropriate timeline based on current mode and prior timeline
        -- some modes just loop one timeline
        local nextTimeline = currentTimeline
        if #playlistSequences[currentPlaylist] > 1 then
        -- more than 1 timeline means we need to figure out what's next
            -- find next slot (or first slot if we're at the end)
            currentSlot = (currentSlot % #playlistSequences[currentPlaylist]) + 1
            nextTimeline = playlistSequences[currentPlaylist][currentSlot]
        end
        fire_solo_timeline(nextTimeline)
    end

    function handle_button (buttonNum)
        if buttonNum < 1 or buttonNum > #playlistSequences then
        -- only defined playlists are valid input
            return nil
        elseif buttonNum == currentPlaylist then
        -- we're already doing this
            return nil
        else
        -- buttons start their respective playlists with first timelines
            currentSlot = 1
            fire_solo_timeline(playlistSequences[buttonNum][currentSlot])
        end
        -- set the proper indicators on/off
        set_radio_button(buttonNum)
        -- store mode for later
        currentPlaylist = buttonNum
    end


    currentPlaylist = 0             -- which playlist is currently being used
    currentSlot = 0                 -- which slot in the playlist is currently being used


    set_radio_button(currentPlaylist)

     

    Touch Button Event trigger for any button, capturing button<3d> executing script

    local incomingButton = get_trigger_variable(1).integer 
    handle_button(incomingButton)

     

    Timeline Ended trigger for any timeline executing script

    local endingTimeline = get_trigger_variable(1).integer
    fire_next_timeline(endingTimeline)
Children
Related