This script reads the current title of a playlist and writes it formatted into a field of a title input
In this example I use the title included in vMix " Title 33- On the shelf- Peach.gtzip " and I write the text in 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 audiofiles. 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.
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=[h]'2'[/h]]/@title").Value
word = word.remove(word.Length - 4)
dim wordArr as String() = word.Split("-")
Dim result0 as String = wordArr(0)
Dim result1 as String = wordArr(1)
Dim result2 as String = wordArr(2)
Dim result3 as String = wordArr(3)
Dim result4 as String = wordArr(4)
dim fullname as string = result1 + " " + result2 + " " + result4
API.Function("SetText",Input:="Title 33- On the shelf- Peach.gtzip",SelectedName:="Headline.Text",Value:=result1)
sleep(1000)
API.Function("SetText",Input:="Title 33- On the shelf- Peach.gtzip",SelectedName:="Headline.Text",Value:=result2)
sleep(1000)
API.Function("SetText",Input:="Title 33- On the shelf- Peach.gtzip",SelectedName:="Headline.Text",Value:=result4)
sleep(1000)
API.Function("SetText",Input:="Title 33- On the shelf- Peach.gtzip",SelectedName:="Headline.Text",Value:=fullname)
sleep(1000)
loop
The script can be started with a shortcut. If the list is cleared, the script stops itself due to an error.
explanation of the different sections‘do / loop, loops the script infinitedo
‘Reads all API information that vMix has to offerdim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)
‘Extracts the currently playing name of the list-inputs-2 into the string worddim word as string = x.SelectSingleNode("//input[@number='2']/@title").Value
‘truncates the last 4 characters of the string word (.mp3)word = word.REMOVE(word.Length - 4)
‘Splits the remaining string into word parts. In this example the name is divided with hyphens -.
‘Depending on the filename of your list, this may or may not be necessary.dim wordArr as String() = word.Split("-")
‘Defines the individual word parts as individual strings.
‘Depending on the filename of your list, this may or may not be necessary.‘Attention: The array must not be larger than it has word parts.[/h]
Dim result0 as String = wordArr(0)
Dim result1 as String = wordArr(1)
Dim result2 as String = wordArr(2)
Dim result3 as String = wordArr(3)
Dim result4 as String = wordArr(4)
‘Composes a new string from band name, album and title (fullname)dim fullname as string = result1 + " " + result2 + " " + result4
'If the filename only contains the title, you can use the variable word instead of result1
‘Writes bandname and waits one secondAPI.Function("SetText",Input:="Title 33- On the shelf- Peach.gtzip",SelectedName:="Headline.Text",Value:=result1)
sleep(1000)
‘Writes albumname and waits one secondAPI.Function("SetText",Input:="Title 33- On the shelf- Peach.gtzip",SelectedName:="Headline.Text",Value:=result2)
sleep(1000)
‘Writes title and waits one secondAPI.Function("SetText",Input:="Title 33- On the shelf- Peach.gtzip",SelectedName:="Headline.Text",Value:=result4)
sleep(1000)
‘Writes Fullname and waits one secondAPI.Function("SetText",Input:="Title 33- On the shelf- Peach.gtzip",SelectedName:="Headline.Text",Value:=fullname)
sleep(1000)
‘loops back to the beginningloop