vMix Forums
»
General
»
Feature Requests
»
Make OnCompletion also work of it's not in Program1/Output1
Rank: Advanced Member
Groups: Registered
Joined: 8/2/2013(UTC) Posts: 462
Thanks: 38 times Was thanked: 39 time(s) in 35 post(s)
|
I just tried to trigger OnCompletion with a video that runs on Mix2, so that it would change to something else when it is finished.
Unfortunately, right now it seems not to work if your video is not in Program1/Output1.
It would make sense to open this trigger to other Mixes as well.
|
|
|
|
Rank: Member
Groups: Registered
Joined: 9/4/2020(UTC) Posts: 22 Was thanked: 1 time(s) in 1 post(s)
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 4/24/2021(UTC) Posts: 1 Location: Berlin
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 8/24/2018(UTC) Posts: 22 Location: Canada
Thanks: 9 times
|
+1 - It also doesn't trigger if a video is in a multiview layer.
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 11/23/2020(UTC) Posts: 170 Location: Wichita Thanks: 10 times Was thanked: 24 time(s) in 20 post(s)
|
Originally Posted by: Rinsky I just tried to trigger OnCompletion with a video that runs on Mix2, so that it would change to something else when it is finished.
Unfortunately, right now it seems not to work if your video is not in Program1/Output1.
It would make sense to open this trigger to other Mixes as well. I have a script I use that is triggered by an X-Key to play various MP3 files, it first checks to make sure no other MP3 is playing then turns off automatic actions that could cause it to be messed up if someone were to make it "Live" (which shouldn't happen but you never know when the cat is going to walk onto the keyboard) and then starts playing the MP3. It watches until it sees the MP3 has finished playing whereupon it resets the audio outputs. The "watching for completion" code can be used with a video so you might be able to adapt this code to meet your needs. Code:
'Script to be triggered by a Keypadkey or X-Key to start playing an MP3 as background audio
' When you add a new MP3 player, you need to add it's key to this array
Dim PlayerKeys() as String = {"86fecea6-0bec-43b2-8989-4c548973b94f","a8bac9b2-0898-46ad-87b8-ef668d1f3147","0b59d4f0-a95d-4bbf-b6f5-3259045d8955","32fbcbd5-a1ff-4222-ac16-319c88b1d596","da73d4fd-0713-482b-966a-bd871c89f7a7","5700a5c0-a78d-4e7a-8848-23f11f4bcd34","c31f2b8b-0768-4e76-a0ab-f6668f1078a0","4c20abe9-e44b-4caa-8ab6-918bdb4704b3"}
Dim vMixState as new system.xml.xmldocument
vMixState.LoadXML(API.XML)
Dim PlayerNumber as integer = 0 ' This is the only line that needs to be changed to change the player number, note it's zero based here and one based in the names
Dim PlayerKey as string = PlayerKeys(PlayerNumber) ' Get the Key for our player from the XML
Dim PlayerTitle as string = vMixState.SelectSingleNode("//input[@key='" & PlayerKeys(PlayerNumber) & "']/@title").Value ' Get the Title for our Player
' ----------- Check to make sure no MP3 player is currently running before we start another one ----------------------
Dim PlayerIndex as integer
Dim OKToPlay = true
For PlayerIndex = 0 to PlayerKeys.Length - 1
Dim state as string = vMixState.SelectSingleNode("//input[@key='" & PlayerKeys(PlayerIndex) & "']/@state").Value
if state = "Running"
console.writeline(vMixState.SelectSingleNode("//input[@key='" & PlayerKeys(PlayerIndex) & "']/@title").Value & " is currently running, " & PlayerTitle & " cannot be started")
OKToPlay = false
'Else
' console.writeline("Player number " & CStr(PlayerIndex + 1) & " is not running")
end if
Next
If OKToPlay ' I would have liked to just quit executing in the above For statement if another player is running but there's no Quit statement implementation here so we have to use a honking big IF instead to bypass the functional code
'--------------
Dim MP3Player as Object = Input.Find(PlayerTitle) ' Should use the Key but it's BROKEN!!!!! so we have to use the Title instead
console.writeline(PlayerTitle & " is now starting " & PlayerKey)
' Configure Input to match requirements in case this is a newly added MP3 player - only needed once but doesn't hurt to change again
MP3Player.Function("AutoPauseOff") ' Don't pause if someone sets this as "live" and then switches away from it, shouldn't happen but let's be safe
MP3Player.Function("AutoPlayOff") ' Likewise don't start playing it if someone switches it "live"
MP3Player.Function("AutoRestartOff") ' And don't restart it automatically either -- essentially we turn off the automatic actions
MP3Player.Function("LoopOff") ' We are setting these to only play once, may need another script for repeat plays
MP3Player.Function("AudioBusOff","M") ' Audio doesn't go to the master bus, it will get fed to the master through the local sound board
MP3Player.Function("AudioBusOn","A") ' Audio goes to BUS A which feeds to our local sound board
' Now to set the MP3 to play
MP3Player.Function("Restart") ' Make sure we play from the start
MP3Player.Function("AudioOn") ' Turn on audio for this input
MP3Player.Function("BusAAudioOn") ' Turn on Bus A to the sound board
MP3Player.Function("Play") ' Start the MP3 playing (finally!)
console.writeline ( PlayerTitle & " should be playing")
Dim MP3IsPlaying as boolean = true
Do While MP3IsPlaying ' Now we loop until the MP3 finishes playing
sleep(1000) ' Start the loop by waiting 1 seecond (1000 milliseconds)
vMixState.loadxml( API.XML() ) ' Load that XML into a document tree
Dim Duration as string = vMixState.SelectSingleNode("//input[@key='" & PlayerKey & "']/@duration").Value ' Find the "Duration" of the MP3 (in milliseconds)
Dim Position as string = vMixState.SelectSingleNode("//input[@key='" & PlayerKey & "']/@position").Value ' Find the current playing point of the MP3 (in millseconds)
'console.writeline("Duration=" & Duration & " Position=" & Position)
If Duration = Position ' If the position is the same as the duration then it's finished playing
MP3IsPlaying = false
end if
Loop
console.writeline(PlayerTitle & " finished playing")
MP3Player.Function("AudioOff") ' Done so turn off the audio for this input
MP3Player.Function("BusAAudioOff") ' And turn off the input from Bus A (problematic, if we have any other input also playing through the local sound board!)
console.writeline("Audio reset after " & PlayerTitle & " finished, script terminating")
end if
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 11/21/2017(UTC) Posts: 124 Location: Philadephia, PA Thanks: 31 times Was thanked: 13 time(s) in 8 post(s)
|
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 7/4/2021(UTC) Posts: 310 Thanks: 8 times Was thanked: 40 time(s) in 35 post(s)
|
Originally Posted by: Rinsky I just tried to trigger OnCompletion with a video that runs on Mix2, so that it would change to something else when it is finished.
Unfortunately, right now it seems not to work if your video is not in Program1/Output1.
It would make sense to open this trigger to other Mixes as well. From the vMix help page:Quote:Restrictions
The Mix input is intended as a basic video mixer/switcher only, as a result the following features are not available:
...
Auto play/pause/restart of inputs. (This is to prevent unexpected situations where inputs are used by both the main mix and an input mix)
This would seem to be open to presenting the same issue that they've taken deliberate steps to avoid, would it not?
|
|
|
|
vMix Forums
»
General
»
Feature Requests
»
Make OnCompletion also work of it's not in Program1/Output1
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The vMix Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close