vMix Forums
»
General
»
General Discussion
»
Fetch Name and author of song via script
Rank: Newbie
Groups: Registered
Joined: 9/2/2022(UTC) Posts: 7 Location: metn Thanks: 3 times
|
Hello guys,
I am new here and was looking for help with something,
I have a list input with multiple videos that are looping,
I have a lower third that has two text inputs lets say (Title, Subtitle)
is there a way to automatically trigger this lower third and have it load the name and author of the video automatically via scripting on each new video ?
any help would be appreciated,
Thank you in advance
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,246 Location: Belgium Thanks: 294 times Was thanked: 961 time(s) in 795 post(s)
|
Originally Posted by: jhak15 Hello guys,
I am new here and was looking for help with something,
I have a list input with multiple videos that are looping,
I have a lower third that has two text inputs lets say (Title, Subtitle)
is there a way to automatically trigger this lower third and have it load the name and author of the video automatically via scripting on each new video ?
any help would be appreciated,
Thank you in advance If the title and subtitle are part of the videoname sure it could be done by extracting the current details from the API XML (http://127.0.0.1:8088/api) Have you checked this forum regarding the subject scripting ?
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 9/2/2022(UTC) Posts: 7 Location: metn Thanks: 3 times
|
Thank you for the quick reply, no i did not see it, can u please show me where?
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,246 Location: Belgium Thanks: 294 times Was thanked: 961 time(s) in 795 post(s)
|
Originally Posted by: jhak15 Thank you for the quick reply, no i did not see it, can u please show me where? https://forums.vmix.com/...86-Scripting-for-Dummies and other posts or Search on keywords top of this page The followig code wil get you the currently playing ;ist item name Some vb.net coding will allow you to extract parts of the name to send to a title or whatever response you program within Code:'Get title of currently playing list item
do while true
dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)
dim Title as string = (x.SelectSingleNode("//input[5]/@title").InnerText)
console.writeline(Title) 'or API to send to title
sleep(500)
loop
|
1 user thanked doggy for this useful post.
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 1/25/2019(UTC) Posts: 303 Thanks: 17 times Was thanked: 79 time(s) in 60 post(s)
|
I have this script published here before, but have not found it in a hurry. it should work like this, with some work of your own to adapt this to your title and naming of your files. This script reads the current title of a playlist and writes it formatted into a field of a vMix GT-Title. In this example I use the title “Title 33- On the shelf- Peach.gtzip”, contained in vMix and write the text into the field “Headline.Text”. My list input is Input2. Please adapt this (title, field and list input number) for your project. I use a list of MP3 audio files. These are named as follows: Anni Piper - Two's Company - 01 - Blues Before Sunrise.mp3 Anni Piper - Two's Company - 02 - Live To Play.mp3 Anni Piper - Two's Company - 03 - Man's Woman.mp3 The goal is to extract a usable name from this string. this line gets the active title name from your playlist Code:dim word as string = (x.SelectSingleNode("//input[@number=2]/@title").InnerText)
this line removes ".mp3" Code:word = word.remove(word.Length - 4)
this line defines the separator, in this case the - Code:Dim parts() As String = word.Split(New Char() {"-"c}, StringSplitOptions.RemoveEmptyEntries
the variables parts(i) are holding the individual parts, parts(1) = Anni Piper etc. the script shows you individual variables(part(1) , part(2) ..) for 1 second in the title “Title 33- On the shelf- Peach.gtzip” The finished script looks like this: Code:'script playing now
do
dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)
dim word as string = (x.SelectSingleNode("//input[@number=2]/@title").InnerText)
word = word.remove(word.Length - 4)
' Split the string by "-"
Dim parts() As String = word.Split(New Char() {"-"c}, StringSplitOptions.RemoveEmptyEntries)
' Trim each part to remove leading and trailing spaces
For i As Integer = 0 To parts.Length - 1
parts(i) = parts(i).Trim()
Next
'gets number of parts
Dim number As Integer = parts.Length -1
'shows each part of the tile for a second
for ii as integer = 1 to number
API.Function("SetText",Input:="Title 33- On the shelf- Peach.gtzip",SelectedName:="Headline.Text",Value:=parts(ii))
sleep(1000)
next
loop
|
2 users thanked Peter1000 for this useful post.
|
|
|
Rank: Newbie
Groups: Registered
Joined: 9/2/2022(UTC) Posts: 7 Location: metn Thanks: 3 times
|
This is great, thank you very much, it works, if i want to split the part of the file name and put the first part as a title in my gtzip file and the second as subtitle, make the gtzip overlay in and then fade out after a certain amount of time and loop every certain amount of minutes can you help out with the code ?
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 9/2/2022(UTC) Posts: 7 Location: metn Thanks: 3 times
|
i think i got it,
'script playing now
do dim xml as string = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml) dim word as string = (x.SelectSingleNode("//input[@number=1]/@title").InnerText) word = word.remove(word.Length - 4)
' Split the string by "-" Dim parts() As String = word.Split(New Char() {"-"c}, StringSplitOptions.RemoveEmptyEntries)
' Trim each part to remove leading and trailing spaces For i As Integer = 0 To parts.Length - 1 parts(i) = parts(i).Trim() Next
'gets number of parts Dim number As Integer = parts.Length -1
'shows each part of the tile for a second for ii as integer = 1 to number API.Function("SetText",Input:="Title 7- Horizontal Red.gtzip",SelectedName:="Headline.Text",Value:=parts(1)) API.Function("SetText",Input:="Title 7- Horizontal Red.gtzip",SelectedName:="Description.Text",Value:=parts(2)) Overlay.Find(1).In("Title 7- Horizontal Red.gtzip") sleep(5000) Overlay.Find(1).Out next sleep(10000) loop
Thank you so much guys, does this method work on as many lists i have or should i do a script for each one ? with triggers on overlay in? what do u suggest,
EDIT: i also noted that if the video in the list is over, and the above graphic is still on air it will not change the value because it is still in the loop which makes sense, so is there a way to trigger this script in a way to show the details every time a new video plays ?
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 1/25/2019(UTC) Posts: 303 Thanks: 17 times Was thanked: 79 time(s) in 60 post(s)
|
there are several options. one could be 4 triggers on your list input. trigger.PNG (13kb) downloaded 0 time(s).the 1st trigger starts a script, if yout List input goes online(OnTransitionIn), in this example the Script is named "overlay", this script starts also your "playing now" script" and fades overlay1 IN and OUT for your defined amount of time, loops if needed the 2nd trigger takes the overlay1 out, if your list input is taken off the program (OnTransitionOut) the 3rd trigger stops your script "overlay", if your list input is taken off the program (OnTransitionOut) the 4th trigger stops your script "playing now", if your list input is taken off the program (OnTransitionOut) overlay Code:'script overlay
'this script starts the other script "playing now" and shows your title for 2 seconds, every 10 seconds
API.Function("ScriptStart", Value:="playing now")
do
API.Function("OverlayInput1In", Input:="Title 7- Horizontal Red.gtzip")
sleep(2000)
API.Function("OverlayInput1Out", Input:="Title 7- Horizontal Red.gtzip")
sleep(10000)
loop
and modify your script playing now. you can remove some unneeded parts and make the script faster, to change the title name imediate, if your list input changes. modified script playing now Code:'script playing now
do
dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)
dim word as string = (x.SelectSingleNode("//input[@number=1]/@title").InnerText)
word = word.remove(word.Length - 4)
' Split the string by "-"
Dim parts() As String = word.Split(New Char() {"-"c}, StringSplitOptions.RemoveEmptyEntries)
' Trim each part to remove leading and trailing spaces
For i As Integer = 0 To parts.Length - 1
parts(i) = parts(i).Trim()
Next
'adjusts the two text fields to the currently running title
API.Function("SetText",Input:="Title 7- Horizontal Red.gtzip",SelectedName:="Headline.Text",Value:=parts(1))
API.Function("SetText",Input:="Title 7- Horizontal Red.gtzip",SelectedName:="Description.Text",Value:=parts(4))
sleep(200)
loop
This should give you enough information to try to solve future problems yourself. The best training is still in doing it on your own. :-)
|
1 user thanked Peter1000 for this useful post.
|
|
|
Rank: Newbie
Groups: Registered
Joined: 9/2/2022(UTC) Posts: 7 Location: metn Thanks: 3 times
|
great, can u provide me with a code that can switch a millisecond value into hh:mm:ss and set it in a counter ?
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,246 Location: Belgium Thanks: 294 times Was thanked: 961 time(s) in 795 post(s)
|
Originally Posted by: jhak15 great, can u provide me with a code that can switch a millisecond value into hh:mm:ss and set it in a counter ? With all due respect a little bit of search effort would not hurt and help you learn (or hire a programmer) https://www.syncfusion.c...t-milliseconds-into-timeAlso check out the available shortcuts that also are usefull as scripting functions
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 9/2/2022(UTC) Posts: 7 Location: metn Thanks: 3 times
|
i wrote the code to get the duration of each video from the list,
i created a text input in vmix and added the xml in the data source manager, i then chose the duration column to always display in the text input and then accessed this information via script to trigger everything
Do ' Extract the duration value from the Message attribute in input 3 Dim xmlDoc As New System.Xml.XmlDocument() xmlDoc.Load("http://localhost:8088/api") Dim durationValue As String = xmlDoc.SelectSingleNode("/vmix/inputs/input[@number='3']/text[@name='Message']").InnerText
' Convert the duration value to the milliseconds Dim durationMilliseconds As Long = Long.Parse(durationValue)
' Calculate the hours, minutes, and seconds Dim hours As Integer = CInt((durationMilliseconds \ (1000 * 60 * 60)) Mod 24) Dim minutes As Integer = CInt((durationMilliseconds \ (1000 * 60)) Mod 60) Dim seconds As Integer = CInt((durationMilliseconds \ 1000) Mod 60)
' Construct the query string with the calculated values Dim apiUrl As String = "http://localhost:8088/api" Dim queryString As String = "Function=SetCountdown&Input=2&Title=txtClock&Value=" & hours.ToString("D2") & ":" & minutes.ToString("D2") & ":" & seconds.ToString("D2") Dim requestUrl As String = apiUrl & "?" & queryString
' Send the request to the desired endpoint Dim client As New System.Net.WebClient() Dim response As String = client.DownloadString(requestUrl)
' Process the response as needed Console.WriteLine(response)
' Wait for a certain interval before repeating the loop Threading.Thread.Sleep(5000) ' 5 seconds Loop While True
|
|
|
|
vMix Forums
»
General
»
General Discussion
»
Fetch Name and author of song via script
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