logo

Live Production Software Forums


Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

27 Pages«<252627
Options
Go to last post Go to first unread
doggy  
#521 Posted : Saturday, December 28, 2024 9:20:44 PM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,396
Belgium
Location: Belgium

Thanks: 300 times
Was thanked: 993 time(s) in 823 post(s)
Display remaining time of a list playout on a title ( for shits and giggles)

in response to https://forums.vmix.com/...ing-countdown#post116907

Code:
'Get the total duration of a List script by Doggy

'assuming the first item in that list is selected !!!
'playout is set to Auto Next and Auto First !!!
'Things that ight offset the time between countdown and play are transitions used for the list

Dim listInput as integer = 3   'input number of list
Dim titleInp as integer = 5    'input number of title
Dim textIndex as Integer = 0   ' textfield to set countdown 

' Takes a while to Process , depending on number of items in the list !!

dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(API.XML())

Dim nodeList As XmlNodeList = x.SelectNodes("//list/item")
dim count as integer = nodeList.count() 
dim selected as string
dim duration as integer

' if first item is not selected add a routine here to do so 

' skip to each item in list to get the duration and tally up
for i as integer = 0 to count-1
  x.loadxml(API.XML())
  nodeList = x.SelectNodes("//list/item")
  duration += x.SelectSingleNode("//input[@number='3']/@duration").Value
  API.Function("NextItem", Input:=3)
  sleep(300)
next

' Convert ms the time 
Dim ts as Timespan= TimeSpan.FromMilliseconds(duration )
Sleep(300)


'Optional
'setting countdown and starting list playback and Countdown

API.Function("StopCountDown", Input:=titleInp ,SelectedIndex:=textIndex )
sleep(100)
API.Function("SetCountDown", Input:=titleInp ,SelectedIndex:=textIndex ,Value:= ts.ToString("hh\:mm\:ss"))
API.Function("ListPlayout",Input:=listInput)
sleep(500)  'adjusting for function calls time
Api.Function("StartCountdown",Input:=titleInp )
API.Function("OverlayInput1In",Input:=titleInp )

'Can add triggers on CountdownCompleted to remove overlay and make a transition 


thanks 1 user thanked doggy for this useful post.
nikosman88 on 12/28/2024(UTC)
NicholasLowFK  
#522 Posted : Thursday, January 2, 2025 6:46:24 PM(UTC)
NicholasLowFK

Rank: Newbie

Groups: Registered
Joined: 1/2/2025(UTC)
Posts: 2
Malaysia
Location: Kuala Lumpur

hi guys,
i have a problem with my scripting, i wish to get my recording status for my following action, for instance, when i toggle my script, if recording status is active i would like to have my title transition out and stop my recording, whereby if recording was not active upon toggling the script i would like to have my recording active and transition in for my title, is it possible?
doggy  
#523 Posted : Thursday, January 2, 2025 7:22:22 PM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,396
Belgium
Location: Belgium

Thanks: 300 times
Was thanked: 993 time(s) in 823 post(s)
Originally Posted by: NicholasLowFK Go to Quoted Post
hi guys,
i have a problem with my scripting, i wish to get my recording status for my following action, for instance, when i toggle my script, if recording status is active i would like to have my title transition out and stop my recording, whereby if recording was not active upon toggling the script i would like to have my recording active and transition in for my title, is it possible?


Sure it can , what have you tried so far (can post it here) ? (as there are meny examples in this thread)









https://forums.vmix.com/...ng-for-Dummies#post71124
doggy  
#524 Posted : Friday, February 7, 2025 8:39:23 PM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,396
Belgium
Location: Belgium

Thanks: 300 times
Was thanked: 993 time(s) in 823 post(s)
Duration, position and time remaining of current playing clip of List

Code:
' timeleft clip in list

dim position as string = ""
dim duration as string = ""
dim activeinput as string = ""

dim pos as decimal=0
dim dur as decimal =0
dim Timeleft as decimal = 0

do while true
   dim xml as string = API.XML()
   dim x as new system.xml.xmldocument
   x.loadxml(xml)

   activeinput = (x.SelectSingleNode("//active").InnerText)

   if activeinput = "3"  ' the # of list input

      duration = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@duration").Value)/1000
      position = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@position").Value)/1000

      if decimal.TryParse(duration ,dur) then
               dur = Math.Truncate(dur)
      end if

      if decimal.TryParse(position ,pos) then
               pos = Math.Truncate(pos)
      end if
      Timeleft = Math.Truncate(dur - pos)
    
    ' display in title input 4 first Textfield duration/position/time remaining
    API.Function("SetText",Input:="4",SelectedIndex:="0",Value:=dur.tostring() & " / " &  pos.tostring() & " / " & Timeleft.tostring())
  
  end if
  sleep(100)
loop
AngusFindlay  
#525 Posted : Friday, June 13, 2025 3:24:54 AM(UTC)
AngusFindlay

Rank: Member

Groups: Registered
Joined: 8/24/2018(UTC)
Posts: 23
Location: Canada

Thanks: 10 times
Originally Posted by: Xtreemtec Media Go to Quoted Post
So based on 2 programs above from Doggy,

I made a Video player time left title display that you can add on top of the Clock source by using the Multiview to stack upon.

While the code is not 100% perfect yet and only displays MM;SS But it gives you some idea and it's workable.

Till 60 seconds it's green, Turns then orange, and the last 10 seconds it's red.


I've updated the script to always display the minutes. Thanks to the original poster for their work!

Code:

' Checking time left of active running video and display this as an title. 
' and do some stuff at certain time remaining

dim position as string = ""
dim duration as string = ""
dim activeinput as string = ""
dim Timeleft as double = 0
dim triggertime as integer = 10      '10 seconds before end
dim triggerduration as integer = 2000   'fade duration, could be different than trigger

do while true

   dim xml as string = API.XML()
   dim x as new system.xml.xmldocument
   x.loadxml(xml)

activeinput = (x.SelectSingleNode("//active").InnerText)
duration = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@duration").Value)
position = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@position").Value)

Timeleft= Double.Parse(duration)-Double.Parse(position)

Timeleft = Timeleft / 100

dim Timingleft as integer = CInt(Timeleft)
Timingleft = Timingleft / 10

dim Minutes as integer = Timingleft \ 60
dim Seconds as integer = Timingleft Mod 60

'used at debugging stage
  ' console.writeline(Timingleft)
  ' console.writeline(Seconds)

dim ThisTime as string 
ThisTime = Minutes.ToString("00") + ":" + Seconds.ToString("00")
API.Function("SetText",Input:="Text Middle Centre Outline.gtzip",SelectedIndex:="0" ,Value:=ThisTime)


if Timingleft < 60
   'put a response in a title and change color accordingly
  
    if Timingleft < 30 
       API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="red")
    else
       API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="orange")
    end if  
else
    API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="green")
 end if


sleep(50)
Loop

Roy Sinclair  
#526 Posted : Friday, June 13, 2025 1:05:13 PM(UTC)
Roy Sinclair

Rank: Advanced Member

Groups: Registered
Joined: 11/23/2020(UTC)
Posts: 199
United States
Location: Wichita

Thanks: 11 times
Was thanked: 27 time(s) in 23 post(s)
Originally Posted by: AngusFindlay Go to Quoted Post
Originally Posted by: Xtreemtec Media Go to Quoted Post
So based on 2 programs above from Doggy,

I made a Video player time left title display that you can add on top of the Clock source by using the Multiview to stack upon.

While the code is not 100% perfect yet and only displays MM;SS But it gives you some idea and it's workable.

Till 60 seconds it's green, Turns then orange, and the last 10 seconds it's red.


I've updated the script to always display the minutes. Thanks to the original poster for their work!

Code:

' Checking time left of active running video and display this as an title. 
' and do some stuff at certain time remaining

dim position as string = ""
dim duration as string = ""
dim activeinput as string = ""
dim Timeleft as double = 0
dim triggertime as integer = 10      '10 seconds before end
dim triggerduration as integer = 2000   'fade duration, could be different than trigger

do while true

   dim xml as string = API.XML()
   dim x as new system.xml.xmldocument
   x.loadxml(xml)

activeinput = (x.SelectSingleNode("//active").InnerText)
duration = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@duration").Value)
position = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@position").Value)

Timeleft= Double.Parse(duration)-Double.Parse(position)

Timeleft = Timeleft / 100

dim Timingleft as integer = CInt(Timeleft)
Timingleft = Timingleft / 10

dim Minutes as integer = Timingleft \ 60
dim Seconds as integer = Timingleft Mod 60

'used at debugging stage
  ' console.writeline(Timingleft)
  ' console.writeline(Seconds)

dim ThisTime as string 
ThisTime = Minutes.ToString("00") + ":" + Seconds.ToString("00")
API.Function("SetText",Input:="Text Middle Centre Outline.gtzip",SelectedIndex:="0" ,Value:=ThisTime)


if Timingleft < 60
   'put a response in a title and change color accordingly
  
    if Timingleft < 30 
       API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="red")
    else
       API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="orange")
    end if  
else
    API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="green")
 end if


sleep(50)
Loop




I see a major problem with this script. You have NO provision to exit the script when the video ends, it just loops FOREVER which means the script can't be started for another video and of course is consuming resources long after it's actual job has been done and in fact until it's force stopped or vMix is shut down.

All you need do to fix it is change the initial value of TimeLeft to 1.0 and then change the Do While statement to "Do While TimeLeft > 0.0".

A second problem is the "sleep(50)", for each second of time that passes this loop will execute 20 times. That's at least twice as often as it needs to run, try setting it to "sleep(300)" and see if it isn't updating regularly enough to be indistinguishable from the "sleep (50)" version.

Still you have provided what several have asked for and since the problems are easily solved I say you've done good!


Users browsing this topic
Guest
27 Pages«<252627
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.