Clip Related Script

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
structure SClipInstance
    oClipChannel              as ClipChannel
    iClipChannelID            as Integer
    bLiveUpdate               as Boolean
    szShmKeyModeChanged       as String
    szShmKeyFrameChanged      as String
    bAutoRun                  as boolean
    bLoopMode                 as Boolean
    bReverseFields            as Boolean
    iRepeatMode               as Integer
    iModeOnLoadError          as Integer
    dPlaybackSpeed            as Double
    iMode                     as Integer
    szClipName                as String
    szClipNameToLoad          as String
    iDuration                 as Integer
    iCurrentFrame             as Integer
    iFrameIn                  as Integer
    iFrameOut                 as Integer
end structure

dim oClip   as array[SClipInstance]
dim iClip   as Integer = 0


' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub OnInit()
    println( "OnInit()" )

    println( "channel=" & GetParameterInt( "channel" ) )

    dim iNumberOfClipChannels = system.GetNumberOfClipChannel()

    for i = 0 to iNumberOfClipChannels
        ClipPlayerInitializeClipChannel( i )
    next

iClip = 0

end sub




dim kButtonStop     as integer = 0
dim kButtonPlay     as integer = 1
dim kButtonPause    as integer = 2
dim kButtonContinue as integer = 3
dim kButtonFlush    as integer = 4
dim kButtonLoad     as integer = 5

' ---------------------------------------------------------------------
' ClipInGetClipNameAbsolute Test
' ---------------------------------------------------------------------
dim kButtonTest1    as integer = 6 

' ---------------------------------------------------------------------
' RequestClipStatus Test
' ---------------------------------------------------------------------
dim kButtonTest2    as integer = 7

' ---------------------------------------------------------------------
' QueueList Test
' ---------------------------------------------------------------------
dim kButtonTest3    as integer = 8

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub OnInitParameters()
    println( "OnInitParameters()" )

    dim clip_channel_entries as array[string]
    clip_channel_entries.push( "Clip Channel 1" )
    clip_channel_entries.push( "Clip Channel 2" )
    RegisterParameterDropDown("channel","Clip Channel", 0, clip_channel_entries, 20, 2)

    RegisterFileSelector( "file", "Browse Filename", "D:/clips", "", "*.avi *.dv *.mov")
    RegisterPushButton( "cmd_load",     "Load Clip", kButtonLoad )
	RegisterPushButton( "cmd_test1",     "Test1", kButtonTest1 )
	RegisterPushButton( "cmd_test2",     "Test2", kButtonTest2 )
	RegisterPushButton( "cmd_test3",     "Test3", kButtonTest3 )
    RegisterPushButton( "cmd_stop",     "Stop",     kButtonStop )
    RegisterPushButton( "cmd_play",     "Play",     kButtonPlay )
    RegisterPushButton( "cmd_pause",    "Pause",    kButtonPause )
    RegisterPushButton( "cmd_continue", "Continue", kButtonContinue )
    RegisterPushButton( "cmd_flush",    "Flush",    kButtonFlush )

    RegisterParameterBool  ( "live_update",     "Live Update",  false )
    RegisterParameterString( "status_mode",     "Current Mode", "", 20, 20, "?" )
    RegisterParameterInt   ( "status_duration", "Duration (frames)", 0, 0, 2000000000 )
    RegisterParameterBool( "auto_run",       "Auto Run",       false )
    RegisterParameterBool( "loop_mode",      "Loop Mode",      true  )
    RegisterParameterBool( "reverse_fields", "Reverse Fields", false )


    dim repeat_mode_entries as array[string]
    repeat_mode_entries.push( "none" )
    repeat_mode_entries.push( "field" )
    repeat_mode_entries.push( "frame" )
    RegisterParameterDropDown("repeat_mode","Repeat Mode", 1, repeat_mode_entries, 20, 3 )

    dim mode_on_load_error_entries as array[string]
    mode_on_load_error_entries.push( "none" )
    mode_on_load_error_entries.push( "pause" )
    mode_on_load_error_entries.push( "stop" )
    mode_on_load_error_entries.push( "flush" )
    RegisterParameterDropDown("mode_on_load_error","Mode on Load Error", 0, mode_on_load_error_entries, 20, 4 )

    RegisterParameterDouble("speed", "Speed", 1,-2.00,2.00)
    RegisterParameterInt("currentframe", "Current Frame", 0, 0, 2000000000)

    RegisterParameterInt("framein", "Frame In", 0, 0, 2000000000)
    RegisterParameterInt("frameout", "Frame Out", 0, 0, 2000000000)
end sub

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub OnParameterChanged( parameterName As String )

    println( "OnParameterChanged: " & parameterName )

    if parametername.StartsWith( "status_" ) then exit sub

    if oClip[iClip].iMode <> 2 then     println( "OnParameterChanged: " & parameterName )

    dim cmd as string
    if "channel" == parameterName  then
        ClipPlayerChangeClipChannel( GetParameterInt( parameterName ))

    elseif "file" == parameterName then
        oClip[iClip].szClipNameToLoad = GetParameterString( parameterName )

    elseif "auto_run" == parameterName then
        ClipPlayerSetAutoRun( GetParameterBool( parameterName ))

    elseif "loop_mode" == parameterName then
        ClipPlayerSetLoopMode( GetParameterBool( parameterName ))

    elseif "reverse_fields" == parameterName then
        ClipPlayerSetReverseFields( GetParameterBool( parameterName ))

    elseif "repeat_mode" == parameterName then
        ClipPlayerSetRepeatMode( GetParameterInt( parameterName ))

    elseif "mode_on_load_error" == parameterName then
        ClipPlayerSetModeOnLoadError( GetParameterInt( parameterName ))

    elseif "speed" == parameterName then
        ClipPlayerSetPlaybackSpeed( GetParameterDouble( parameterName ))

    elseif "currentframe" == parameterName then
        ClipPlayerScrub( GetParameterInt( parameterName ))

    elseif "framein" == parameterName then
        ClipPlayerSetFrameIn( GetParameterInt( parameterName ))

    elseif "frameout" == parameterName then
        ClipPlayerSetFrameOut( GetParameterInt( parameterName ))

    elseif "live_update" == parameterName then
        ClipPlayerSetLiveUpdate( GetParameterBool( parameterName ))
    end if
end sub

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub OnExecAction( buttonId As Integer )
    println("Pressed button: "&buttonId )

    if kButtonLoad == buttonId then
        ClipPlayerSetClipName( oClip[iClip].szClipNameToLoad )
    elseif kButtonStop == buttonId then
        ClipPlayerStop()
    elseif kButtonPlay == buttonId then
        ClipPlayerPlay()
    elseif kButtonPause == buttonId then
        ClipPlayerPause()
    elseif kButtonContinue == buttonId then
        ClipPlayerContinue()
    elseif kButtonFlush == buttonId then
        ClipPlayerFlush()
    elseif kButtonTest1 == buttonId then
        Test1()
    elseif kButtonTest2 == buttonId then
        Test2()
    elseif kButtonTest3 == buttonId then
        Test3()
    end if
end sub


' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub OnSharedMemoryVariableChanged( map As SharedMemory, mapKey As String )

    ' Remove this as soon as shared memory is working.
    println( "shared memory variable: " & mapKey & " changed" )
    'exit sub

    if mapKey == oClip[iClip].szShmKeyModeChanged then
        oClip[iClip].iMode = CInt( map[ mapKey ] )
        UpdateAllFromClipPlayer( false )
    elseif mapKey == oClip[iClip].szShmKeyFrameChanged then
        oClip[iClip].iCurrentFrame = CInt( map[ mapKey ] )
        ClipPlayerChangedFrame()
    else
        println( "shared memory variable: " & mapKey & " changed to:" & map[ mapKey ] )
    end if
end sub

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ModeToString(mode as integer) as string
    if mode == 0 then
        ModeToString = "none"
    elseif mode == 1 then
        ModeToString = "stopped"
    elseif mode == 2 then
        ModeToString = "playing"
    elseif mode == 3 then
        ModeToString = "scrubbing"
    elseif mode == 4 then
        ModeToString = "ERROR"
    elseif mode == 5 then
        ModeToString = "playcont"
    else
        ModeToString = IntToString(mode, 1)
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub UpdateAllFromClipPlayer( bDoGuiAlways as Boolean )
    if oClip[iClip].oClipChannel.VizId <= 0 then                exit sub

    if ClipPlayerGetAutoRun() OR bDoGuiAlways then
        this.scriptPlugininstance.SetParameterBool( "auto_run", oClip[iClip].bAutoRun )
    end if

    if ClipPlayerGetLoopMode() OR bDoGuiAlways then
        this.scriptPlugininstance.SetParameterBool( "loop_mode", oClip[iClip].bLoopMode )
    end if

    if ClipPlayerGetReverseFields() OR bDoGuiAlways then
        this.scriptPlugininstance.SetParameterBool( "reverse_fields", oClip[iClip].bReverseFields )
    end if

    if ClipPlayerGetRepeatMode() OR bDoGuiAlways then
        this.scriptPlugininstance.SetParameterInt( "repeat_mode", oClip[iClip].iRepeatMode )
    end if

    if ClipPlayerGetModeOnLoadError() OR bDoGuiAlways then
        this.scriptPlugininstance.SetParameterInt( "mode_on_load_error", oClip[iClip].iModeOnLoadError )
    end if

    if ClipPlayerGetPlayBackSpeed() OR bDoGuiAlways then
        this.scriptPlugininstance.SetParameterDouble( "speed", oClip[iClip].dPlayBackSpeed )
    end if

    if ClipPlayerGetFrameIn() OR bDoGuiAlways then
        this.scriptPlugininstance.SetParameterInt( "framein", oClip[iClip].iFrameIn )
    end if

    if ClipPlayerGetFrameOut() OR bDoGuiAlways then
        this.scriptPlugininstance.SetParameterInt( "frameout", oClip[iClip].iFrameOut )
    end if


    if ClipPlayerGetClipName() OR bDoGuiAlways then
        this.scriptPlugininstance.SetParameterString( "file", oClip[iClip].szClipName )
    end if

    this.scriptPlugininstance.SetParameterString( "status_mode", ModeToString( oClip[iClip].iMode ))

    oClip[iClip].iDuration = oClip[iClip].oClipChannel.Duration
    this.scriptPlugininstance.SetParameterInt( "status_duration", oClip[iClip].iDuration )


    if NOT oClip[iClip].bLiveUpdate then
        dim iCurrentFrame as Integer = oClip[iClip].oClipChannel.CurrentFrame
        if iCurrentFrame <> oClip[iClip].iCurrentFrame then
            oClip[iClip].iCurrentFrame = oClip[iClip].oClipChannel.CurrentFrame
            this.scriptPlugininstance.SetParameterInt( "currentframe", oClip[iClip].iCurrentFrame )
        end if
    end if

    SendGuiRefresh()
end sub

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub ClipPlayerChangedFrame()
    if oClip[iClip].oClipChannel.VizId <= 0 then                exit sub

    if oClip[iClip].bLiveUpdate then
        this.scriptPlugininstance.SetParameterInt( "currentframe", oClip[iClip].iCurrentFrame )
        SendGuiRefresh()
    end if
end sub








' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub ClipPlayerInitializeClipChannel( iClipChannel as Integer )
    dim oClipInst   as SClipInstance
    iClip = iClipChannel

    oClipInst.oClipChannel        = system.GetClipChannel( iClip )
    oClipInst.iClipChannelID      = oClipInst.oClipChannel.ClipChannelID
    oClipInst.bLiveUpdate         = false
    println( "[" & iClip & "]iClipChannelID=" & oClipInst.iClipChannelID     )
    println( "[" & iClip & "]object id:="     & oClipInst.oClipChannel.VizId )
    oClip.push( oClipInst )

    ClipPlayerGetRegisteredChangedClipModeKey()
    ClipPlayerCreateChangedClipModeKey()

    ClipPlayerGetRegisteredChangedClipFrameKey()
    ClipPlayerCreateChangedClipFrameKey()

    ClipPlayerGetCurrentMode()
    ClipPlayerGetCurrentFrame()
    UpdateAllFromClipPlayer( true )
end sub


' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub ClipPlayerChangeClipChannel( iClipChannel as Integer )
    if oClip[iClip].bLiveUpdate then
        ClipPlayerUnRegisterChanges()
    end if

    iClip = iClipChannel

    ClipPlayerGetCurrentMode()
    ClipPlayerGetCurrentFrame()

    UpdateAllFromClipPlayer( true )

    if oClip[iClip].bLiveUpdate then
        ClipPlayerRegisterChanges()
    end if
end sub

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub ClipPlayerGetRegisteredChangedClipModeKey()
    if oClip[iClip].oClipChannel.VizId <= 0 then                exit sub

    oClip[iClip].szShmKeyModeChanged = oClip[iClip].oClipChannel.GetRegisterChangedClipMode()
    println( "[" & iClip & "]GetRegisterChangedClipMode()=" & oClip[iClip].szShmKeyModeChanged )
end sub

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub ClipPlayerGetRegisteredChangedClipFrameKey()
    if oClip[iClip].oClipChannel.VizId == 0 then                exit sub

    oClip[iClip].szShmKeyFrameChanged = oClip[iClip].oClipChannel.GetRegisterChangedClipFrame()
    println( "[" & iClip & "]GetRegisterChangedClipFrame()=" & oClip[iClip].szShmKeyFrameChanged )
end sub


' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub ClipPlayerCreateChangedClipModeKey()
    if oClip[iClip].szShmKeyModeChanged.length == 0 then
        oClip[iClip].szShmKeyModeChanged = "com.vizrt.clip" & IntToString( oClip[iClip].iClipChannelID , 1 ) & ".mode"
    end if
    dim oShmMap as SharedMemory
    if Scene.Map.ContainsKey( oClip[iClip].szShmKeyModeChanged ) then
        oShmMap = Scene.Map
    elseif System.Map.ContainsKey( oClip[iClip].szShmKeyModeChanged ) then
        oShmMap = System.Map
    else
        oShmMap = Scene.Map
        oShmMap.CreateKey( oClip[iClip].szShmKeyModeChanged )
    end if
    ' oClip.oClipChannel.RegisterChangedClipMode( oClip[iClip].szShmKeyModeChanged )
    oShmMap.RegisterChangedCallback( oClip[iClip].szShmKeyModeChanged )
end sub

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub ClipPlayerCreateChangedClipFrameKey()
    if oClip[iClip].szShmKeyFrameChanged.length == 0 then
        oClip[iClip].szShmKeyFrameChanged = "com.vizrt.clip" & IntToString( oClip[iClip].iClipChannelID , 1 ) & ".frame"
    end if
    dim oShmMap as SharedMemory
    if Scene.Map.ContainsKey( oClip[iClip].szShmKeyFrameChanged ) then
        oShmMap = Scene.Map
    elseif System.Map.ContainsKey( oClip[iClip].szShmKeyFrameChanged ) then
        oShmMap = System.Map
    else
        oShmMap = Scene.Map
        oShmMap.CreateKey( oClip[iClip].szShmKeyFrameChanged )
    end if
    ' oClip[iClip].oClipChannel.RegisterChangedClipFrame( oClip[iClip].szShmKeyFrameChanged )
    oShmMap.RegisterChangedCallback( oClip[iClip].szShmKeyFrameChanged )
end sub










' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerSetClipName( szClipName as String ) as Boolean
'    if oClip[iClip].szClipName <> szClipName then
        oClip[iClip].szClipName = szClipName
        oClip[iClip].oClipChannel.SetClipName( oClip[iClip].szClipName )
        ClipPlayerSetClipName = true
        println( "[" & iClip & "]SetClipName(" & oClip[iClip].szClipName & ")" )
'    else
'            ClipPlayerSetClipName = false
'    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerGetClipName() as Boolean
    dim szClipName as String = oClip[iClip].oClipChannel.GetClipName()
    if oClip[iClip].szClipName <> szClipName then
        oClip[iClip].szClipName = szClipName
        ClipPlayerGetClipName = true
        println( "[" & iClip & "]GetClipName=" & oClip[iClip].szClipName )
    else
        ClipPlayerGetClipName = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerSetAutoRun( bAutoRun as Boolean ) as Boolean
	if oClip[iClip].bAutoRun <> bAutoRun then
        oClip[iClip].bAutoRun = bAutoRun
        oClip[iClip].oClipChannel.AutoRun = oClip[iClip].bAutoRun
        ClipPlayerSetAutoRun = true
        println( "[" & iClip & "]SetAutoRun(" & oClip[iClip].bAutoRun & ")" )
    else
        ClipPlayerSetAutoRun = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function Test1( ) as Boolean
    println( "------------------------------------------------------------" )
	println( "------------------------------------------------------------" )
	dim sClipName as String
	sClipName = oClip[iClip].oClipChannel.GetClipName()
	println( sClipName )
	
	dim sClipNameAbsolute as String
	sClipNameAbsolute = oClip[iClip].oClipChannel.GetClipNameAbsolute( sClipName )
	println( sClipNameAbsolute )

	println( "------------------------------------------------------------" )
	println( "------------------------------------------------------------" )
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function Test2( ) as Boolean
    println( "------------------------------------------------------------" )
	println( "------------------------------------------------------------" )
	dim sClipName as String
	sClipName = oClip[iClip].oClipChannel.GetClipName()
	println( sClipName )
	
	dim sClipNameAbsolute as String
	sClipNameAbsolute = oClip[iClip].oClipChannel.GetClipNameAbsolute( sClipName )
	println( sClipNameAbsolute )

	println( "------------------------------------------------------------" )
	println( "------------------------------------------------------------" )
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function Test3( ) as Boolean
    println( "------------------------------------------------------------" )
	println( "------------------------------------------------------------" )
	dim sClipName as String
	sClipName = oClip[iClip].oClipChannel.GetClipName()

oClip[iClip].oClipChannel.SetNextCueIsInstant( true )
oClip[iClip].oClipChannel.QueueInsert(sClipName, 0, 100, false, 50)
oClip[iClip].oClipChannel.SetNextCueIsInstant( true )
oClip[iClip].oClipChannel.QueueInsert(sClipName, 0, 200, false, 100)
oClip[iClip].oClipChannel.SetNextCueIsInstant( true )
oClip[iClip].oClipChannel.QueueInsert(sClipName, 0, 300, false, 150)

	dim sQueueList as String
	sQueueList = oClip[iClip].oClipChannel.QueueList( )
	println( sQueueList )

	println( "------------------------------------------------------------" )
	println( "------------------------------------------------------------" )
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerGetAutoRun() as Boolean
    dim bAutoRun as Boolean = oClip[iClip].oClipChannel.AutoRun
    if oClip[iClip].bAutoRun <> bAutoRun then
        oClip[iClip].bAutoRun = bAutoRun
        ClipPlayerGetAutoRun = true
        println( "[" & iClip & "]GetAutoRun=" & oClip[iClip].bAutoRun )
    else
        ClipPlayerGetAutoRun = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerSetLoopMode( bLoopMode as Boolean ) as Boolean
    if oClip[iClip].bLoopMode <> bLoopMode then
        oClip[iClip].bLoopMode = bLoopMode
        oClip[iClip].oClipChannel.LoopMode = oClip[iClip].bLoopMode
        ClipPlayerSetLoopMode = true
        println( "[" & iClip & "]SetLoopMode(" & oClip[iClip].bLoopMode & ")" )
    else
        ClipPlayerSetLoopMode = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerGetLoopMode() as Boolean
    dim bLoopMode as Boolean = oClip[iClip].oClipChannel.LoopMode
    if oClip[iClip].bLoopMode <> bLoopMode then
        oClip[iClip].bLoopMode = bLoopMode
        ClipPlayerGetLoopMode = true
        println( "[" & iClip & "]GetLoopMode=" & oClip[iClip].bLoopMode )
    else
        ClipPlayerGetLoopMode = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerSetReverseFields( bReverseFields as Boolean ) as Boolean
    if oClip[iClip].bReverseFields <> bReverseFields then
        oClip[iClip].bReverseFields = bReverseFields
        oClip[iClip].oClipChannel.ReverseFields = oClip[iClip].bReverseFields
        ClipPlayerSetReverseFields = true
        println( "[" & iClip & "]SetReverseFields(" & oClip[iClip].bReverseFields & ")" )
    else
        ClipPlayerSetReverseFields = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerGetReverseFields() as Boolean
    dim bReverseFields as Boolean = oClip[iClip].oClipChannel.ReverseFields
    if oClip[iClip].bReverseFields <> bReverseFields then
        oClip[iClip].bReverseFields = bReverseFields
        ClipPlayerGetReverseFields = true
        println( "[" & iClip & "]GetReverseFields=" & oClip[iClip].bReverseFields )
    else
        ClipPlayerGetReverseFields = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerSetRepeatMode( iRepeatMode as Integer ) as Boolean
    if oClip[iClip].iRepeatMode <> iRepeatMode then
        oClip[iClip].iRepeatMode = iRepeatMode
        oClip[iClip].oClipChannel.RepeatMode = oClip[iClip].iRepeatMode
        ClipPlayerSetRepeatMode = true
        println( "[" & iClip & "]SetRepeatMode(" & oClip[iClip].iRepeatMode & ")" )
    else
        ClipPlayerSetRepeatMode = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerGetRepeatMode() as Boolean
    dim iRepeatMode as Integer = oClip[iClip].oClipChannel.RepeatMode
    if oClip[iClip].iRepeatMode <> iRepeatMode then
        oClip[iClip].iRepeatMode = iRepeatMode
        ClipPlayerGetRepeatMode = true
        println( "[" & iClip & "]GetRepeatMode=" & oClip[iClip].iRepeatMode )
    else
        ClipPlayerGetRepeatMode = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerSetModeOnLoadError( iModeOnLoadError as Integer ) as Boolean
    if oClip[iClip].iModeOnLoadError <> iModeOnLoadError then
        oClip[iClip].iModeOnLoadError = iModeOnLoadError
        oClip[iClip].oClipChannel.ModeOnLoadError = oClip[iClip].iModeOnLoadError
        ClipPlayerSetModeOnLoadError = true
        println( "[" & iClip & "]SetModeOnLoadError(" & oClip[iClip].iModeOnLoadError & ")" )
    else
        ClipPlayerSetModeOnLoadError = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerGetModeOnLoadError() as Boolean
    dim iModeOnLoadError as Integer = oClip[iClip].oClipChannel.ModeOnLoadError
    if oClip[iClip].iModeOnLoadError <> iModeOnLoadError then
        oClip[iClip].iModeOnLoadError = iModeOnLoadError
        ClipPlayerGetModeOnLoadError = true
        println( "[" & iClip & "]GetModeOnLoadError=" & oClip[iClip].iModeOnLoadError )
    else
        ClipPlayerGetModeOnLoadError = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerSetPlayBackSpeed( dPlaybackSpeed as Double ) as Boolean
    if oClip[iClip].dPlaybackSpeed <> dPlaybackSpeed then
        oClip[iClip].dPlaybackSpeed = dPlaybackSpeed
        oClip[iClip].oClipChannel.PlayBackSpeed = oClip[iClip].dPlaybackSpeed
        ClipPlayerSetPlayBackSpeed = true
        println( "[" & iClip & "]SetPlayBackSpeed(" & oClip[iClip].dPlaybackSpeed & ")" )
    else
        ClipPlayerSetPlayBackSpeed = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerGetPlayBackSpeed() as Boolean
    dim dPlaybackSpeed as Double = oClip[iClip].oClipChannel.PlayBackSpeed
    if oClip[iClip].dPlaybackSpeed <> dPlaybackSpeed then
        oClip[iClip].dPlaybackSpeed = dPlaybackSpeed
        ClipPlayerGetPlayBackSpeed = true
        println( "[" & iClip & "]GetPlayBackSpeed=" & oClip[iClip].dPlaybackSpeed )
    else
        ClipPlayerGetPlayBackSpeed = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerSetFrameIn( iFrameIn as Integer ) as Boolean
    if oClip[iClip].iFrameIn <> iFrameIn then
        oClip[iClip].iFrameIn = iFrameIn
        oClip[iClip].oClipChannel.FrameIn = oClip[iClip].iFrameIn
        ClipPlayerSetFrameIn = true
        println( "[" & iClip & "]SetFrameIn(" & oClip[iClip].iFrameIn & ")" )
    else
        ClipPlayerSetFrameIn = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerGetFrameIn() as Boolean
    dim iFrameIn as Integer = oClip[iClip].oClipChannel.FrameIn
    if oClip[iClip].iFrameIn <> iFrameIn then
        oClip[iClip].iFrameIn = iFrameIn
        ClipPlayerGetFrameIn = true
        println( "[" & iClip & "]GetFrameIn=" & oClip[iClip].iFrameIn )
    else
        ClipPlayerGetFrameIn = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerSetFrameOut( iFrameOut as Integer ) as Boolean
    if oClip[iClip].iFrameOut <> iFrameOut then
        oClip[iClip].iFrameOut = iFrameOut
        oClip[iClip].oClipChannel.FrameOut = oClip[iClip].iFrameOut
        ClipPlayerSetFrameOut = true
        println( "[" & iClip & "]SetFrameOut(" & oClip[iClip].iFrameOut & ")" )
    else
        ClipPlayerSetFrameOut = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerGetFrameOut() as Boolean
    dim iFrameOut as Integer = oClip[iClip].oClipChannel.FrameOut
    if oClip[iClip].iFrameOut <> iFrameOut then
        oClip[iClip].iFrameOut = iFrameOut
        ClipPlayerGetFrameOut = true
        println( "[" & iClip & "]GetFrameOut=" & oClip[iClip].iFrameOut )
    else
        ClipPlayerGetFrameOut = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerGetCurrentMode() as Boolean
    dim iMode as Integer = oClip[iClip].oClipChannel.PlayMode
    if oClip[iClip].iMode <> iMode then
        oClip[iClip].iMode = iMode
        ClipPlayerGetCurrentMode = true
        println( "[" & iClip & "]GetCurrentMode=" & oClip[iClip].iMode & ")" )
    else
        ClipPlayerGetCurrentMode = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerGetCurrentFrame() as Boolean
    dim iCurrentFrame as Integer = oClip[iClip].oClipChannel.CurrentFrame
    if oClip[iClip].iCurrentFrame <> iCurrentFrame then
        oClip[iClip].iCurrentFrame = iCurrentFrame
        ClipPlayerGetCurrentFrame = true
        println( "[" & iClip & "]GetCurrentFrame=" & oClip[iClip].iCurrentFrame & ")" )
    else
        ClipPlayerGetCurrentFrame = false
    end if
end function

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub ClipPlayerPlay()
    oClip[iClip].oClipChannel.Play(0)
end sub

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub ClipPlayerPause()
    oClip[iClip].oClipChannel.Pause()
end sub

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub ClipPlayerContinue()
    oClip[iClip].oClipChannel.Continue()
end sub

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub ClipPlayerStop()
    oClip[iClip].oClipChannel.Stop()
end sub

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub ClipPlayerFlush()
    oClip[iClip].oClipChannel.Flush()
end sub

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
function ClipPlayerScrub( iScrubFrame as Integer ) as Boolean
    if oClip[iClip].iMode == 3 AND oClip[iClip].iCurrentFrame <> iScrubFrame then
        oClip[iClip].iCurrentFrame = iScrubFrame
        oClip[iClip].oClipChannel.scrub( oClip[iClip].iCurrentFrame )
        ClipPlayerScrub = true
        println( "[" & iClip & "]ClipPlayerScrub" & oClip[iClip].iCurrentFrame & ")" )
    else
        ClipPlayerScrub = false
    end if
end function


' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub ClipPlayerSetLiveUpdate( bLiveUpdate as Boolean )
    oClip[iClip].bLiveUpdate = bLiveUpdate
    if oClip[iClip].bLiveUpdate then
        ClipPlayerRegisterChanges()
    else
        ClipPlayerUnRegisterChanges()
    end if
end sub

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub ClipPlayerRegisterChanges()
    oClip[iClip].oClipChannel.SetRegisterChangedClipMode ( oClip[iClip].szShmKeyModeChanged  )
    oClip[iClip].oClipChannel.SetRegisterChangedClipFrame( oClip[iClip].szShmKeyFrameChanged )
end sub

' ---------------------------------------------------------------------
'
' ---------------------------------------------------------------------
sub ClipPlayerUnRegisterChanges()
    oClip[iClip].oClipChannel.SetRegisterChangedClipMode ("")
    oClip[iClip].oClipChannel.SetRegisterChangedClipFrame("")
end sub


你可能感兴趣的:(Viz,Artist,Script)