logo

Live Production Software Forums


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

Notification

Icon
Error

2 Pages<12
Options
Go to last post Go to first unread
Sondrey  
#21 Posted : Friday, January 13, 2017 10:04:35 AM(UTC)
Sondrey

Rank: Advanced Member

Groups: Registered
Joined: 4/25/2014(UTC)
Posts: 41
Man
Location: Norway

Thanks: 2 times
Was thanked: 18 time(s) in 10 post(s)
You don't need to use any 3rd party applications for this... You only need to use the Datasources.
vMix is allready hosting a web API with all the info about the inputs.

Add your songs in a list (NOT playlist) Doubleclick the list, and rename it " " (Only a space). Go to Data Sources, add a XAML source, enter the settings;
URL/Filename: http://127.0.0.1:8088/api
XPath: /vmix/inputs/input
Click OK

in a few sec, you will get a list of all your inputs and their properties. Turn off all auto next functions and so on.

Next add a new text xaml.
Go to Title Editor, and click on data sources on the top of whatever field you want to add the datasource to.

Then select;
Data Source: XML
Table: XML
Column: Title
thanks 1 user thanked Sondrey for this useful post.
doggy on 1/13/2017(UTC)
coolnetgr  
#22 Posted : Friday, January 13, 2017 10:20:49 AM(UTC)
coolnetgr

Rank: Newbie

Groups: Registered
Joined: 9/6/2014(UTC)
Posts: 5

Thanks: 9 times
Was thanked: 1 time(s) in 1 post(s)
I was able to export the title but is there the ability to trigger the xaml on an overlay 20secs before the end of the video and on the start of every video on the list?
thanks 1 user thanked coolnetgr for this useful post.
giulliu on 3/27/2018(UTC)
wtmuradiotv  
#23 Posted : Monday, April 10, 2017 4:09:45 PM(UTC)
wtmuradiotv

Rank: Advanced Member

Groups: Registered
Joined: 7/4/2015(UTC)
Posts: 65
Man
United States

Thanks: 3 times
Was thanked: 3 time(s) in 3 post(s)
Instead of going by the playlist can someone modify this to run manually ???? Also where do i add this in since i updated to 4k
jaredquinn  
#24 Posted : Friday, May 5, 2017 12:14:52 AM(UTC)
jaredquinn

Rank: Member

Groups: Registered
Joined: 11/13/2015(UTC)
Posts: 16
Location: Sydney NSW Australia

Here's the powershell script I use; that was adapted from something I found here:

It locates an input whose name begins with "Background Music" to locate the currently playing track and updates a description in a title named "Music Title"; you can adjust the names of these in the top section; I removed the input boxes as I wanted to launch automatically, while the title transition in and out are commented out so the producer can show/hide the title on demand.. it's designed for our standard production configuration, but may be of use to others.

Code:

#Finds the First Playlist and Grabs the currently playing filename. Removes extension and sends it to the user defined title. Designed to run minimized every second. Hitting "q" in the console will close it.
[string]$input_no = "Music Title"
[string]$title_name = "Description"
[string]$trans_no = "10"
[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')

$lasttitle = ""
$xmlurl = "http://localhost:8088/API/"
$apicallurl1 = "http://localhost:8088/API/?Function=SetText&Input=$input_no&SelectedName=$title_name&Value="
$transinurl = "http://localhost:8088/API/?Function=OverlayInput1In&Input=$input_no"
$transouturl = "http://localhost:8088/API/?Function=OverlayInput1Out&Input=$input_no"
$transcount = 0

[xml]$data = (New-Object System.Net.WebClient).DownloadString($xmlurl)
$nodes = $data.SelectNodes("/vmix/inputs/input")

$c = 0;
write-host 'Scanning Inputs'

$nodes | ForEach-Object {
	$title = ($_ | Select-Object -ExpandProperty title | Out-String) 
	if($title.StartsWith('Background ')) {
		$counter = $c
		write-host $title
	}
	$c++
}

write-host 'Selected.'


while ($true) {
	[xml]$data = (New-Object System.Net.WebClient).DownloadString($xmlurl)
	$nodes = $data.SelectNodes("/vmix/inputs/input")
	$node = $nodes[$counter]
	$position = ($node | Select-Object -ExpandProperty position)
	$duration = ($node | Select-Object -ExpandProperty duration)


	$title = ($node | Select-Object -ExpandProperty title | Out-String) 
	$state = ($node | Select-Object -ExpandProperty state | Out-String)
	$state = $state.Trim().replace("``n", "")
	$title = $title.split('.')[0]
	$title = $title.replace("Background Music - ", "")
	write-host $state " " $title " " $position '/' $duration
	if ($lasttitle -ne $title) { 
		write-host "Updating Vmix input $input_no - $title_name"
		write-host "$state With: $title"
		$apicallurl = $apicallurl1 + $title
		write-host $apicallurl
		(New-Object System.Net.WebClient).DownloadString("$apicallurl")
		Start-Sleep -Seconds 2
# Uncommet if you want auto transition in
#		if ($state -eq "Running") {
#			write-host "Is Running so Transitioning $input_no In"
#		(New-Object System.Net.WebClient).DownloadString("$transinurl")
#			$transcount = 1
#		}
	}	
	write-host "------waiting-------" 
	Start-Sleep -Seconds 1
	$lasttitle = $title
# Uncomment if you want the auto out
#	if ($transcount -eq $trans_no) {
#		write-host "Transitioning $input_no Out"
#		(New-Object System.Net.WebClient).DownloadString("$transouturl")
#	}
	$transcount++
}


RichShumaker  
#25 Posted : Wednesday, October 18, 2017 1:24:17 AM(UTC)
RichShumaker

Rank: Advanced Member

Groups: Registered
Joined: 4/4/2016(UTC)
Posts: 233
United States
Location: Not Los Angeles CA

Thanks: 86 times
Was thanked: 28 time(s) in 23 post(s)
+1 for the original request as I would love to see this as a data source in the future.(Title or Metadata of any sort inside vMix)
+1 for the script to do it as that is awesome and will help me a lot.
-1 for Rich needing to learn the code behind it, heheh.

Thanks everyone.

Rich Shumaker
Speegs  
#26 Posted : Wednesday, October 18, 2017 1:51:35 AM(UTC)
Speegs

Rank: Advanced Member

Groups: Registered
Joined: 8/3/2013(UTC)
Posts: 405
Location: Gold Coast, Australia

Thanks: 27 times
Was thanked: 76 time(s) in 58 post(s)
I wrote the "original", data sources didn't exist back then. I'm surprised Vmix hasn't made a more elegant solution, I made the script for one job in 2015. Saw people with the same need and figured others might use/enhance it for their own needs.

Suggestion: VMix could have some special variables you could use in your own titles to negate the need for anything tricky.

eg:

Now Playing {playlist1_currentfilename_noextension}

Maybe some triggers (with on-change function and pre-change function) to fade the title in/out when item changes as well.

I'm not a Vmix Programmer, but if you could have some special template variables you can use like the time/date ones in the counter that access the current playing items. Seems like a great feature for those who don't want to make code or learn powershell or vb.net.


wtmuradiotv  
#27 Posted : Thursday, December 14, 2017 7:19:48 PM(UTC)
wtmuradiotv

Rank: Advanced Member

Groups: Registered
Joined: 7/4/2015(UTC)
Posts: 65
Man
United States

Thanks: 3 times
Was thanked: 3 time(s) in 3 post(s)
JAIRODJ wrote:
@coolnetgr thanks for the help, with the corrections for me this perfect works very well.

As for the "zoom", in the "position" script corresponds to the elapsed time of the video ...
in Spanish it is "Position" and I name it so, maybe that confuses. Does not refer to the space of positioning an object in X or Y

The parameters that vmix of each entry are:

<input key="ad177ff1-9827-439f-84fb-8d4d8841b902" number="1" type="Video" title="Afrojack Spree Wilson - The Spark ft. Spree Wilson.mp4" state="Paused" position="485" duration="243555" loop="False" muted="True" volume="100" balance="0" solo="False" audiobusses="M" meterF1="0" meterF2="0">Afrojack Spree Wilson - The Spark ft. Spree Wilson.mp4</input>




One issue i get when running the script is that when i have a station id opposite on the screen attached with a gifthe script seems to ignore the file name and puts the gif name from the id have no clue why
polar  
#28 Posted : Wednesday, February 7, 2018 2:05:52 PM(UTC)
polar

Rank: Newbie

Groups: Registered
Joined: 1/29/2018(UTC)
Posts: 7
Location: Norway

Hi Speegs (and other contributors),

While doing my research on vMix I came across the topic "Auto update NOW PLAYING graphic overlay". The last comment was from january 2017, and I wanted to make sure that if I would post something there, that you would get a notification.

Reason is that you wrote a script in PowerShell to get this NOW PLAYING working. Cool :). The fact that you have the knowledge to program in PowerShell AND know your way around in vMix was what draw my attention.

Let me explain. I posted this message on Fiverr a few says ago:

"I'm running a radio software (RadioDJ) on Windows 7. The software uses mySQL as back-end.

What needs to be automated is following: I want to run a query in a table that holds the songID and the position the tracks have in the play queue list (quelist is updated automatically as it progresses by RadioDJ). The songIDs need to be queried against a second table that stores all the information about the track. In this case what is important is the artist, track title and location on the server.

Finally a playlist.m3u file needs to be build (in the required format) that automatically needs to be loaded into vMix, most likely with the help vTask if this would seem not feasible with PowerShell or other tools.

This entire routine needs to be repeated every "XX" minutes to synchronize the latest status of the queue list over to vMix (video broadcasting server).

You are experienced with PowerShell. Can this be done? If so, what would it cost. For use in private video jukebox :)"


I've got a few responses, but what strikes me is that nobody really know vMix that well. So maybe you could be interested in helping me out with some pointers, or whatever you feel you can contribute with.

One of the things I'm trying to understand is following.

- I run a routine to export the RadioDJ playqueue to radiodj.m3u every xx minutes. (as described above)
- I need to use the vMix API to load/reload radiodj.m3u into vMix
- I would like to crossfade the transition, overlapping for about 3 seconds.
- I would like to have the now playing on screen plus next-up.

Can all this be automated by programming with PowerShell? If so, would you advice to open a new topic so others can learn from it as well? And would you be interested in helping me? I'm in the middle of renovating our house, my son is moving out and has asked me for help, and with working 5 days a week I feel swamped and have no time for hobbies right now. So help would be very welcome.

Looking forward to your reply.

Best regards from Norway
Speegs  
#29 Posted : Friday, February 9, 2018 12:55:50 AM(UTC)
Speegs

Rank: Advanced Member

Groups: Registered
Joined: 8/3/2013(UTC)
Posts: 405
Location: Gold Coast, Australia

Thanks: 27 times
Was thanked: 76 time(s) in 58 post(s)
Polar,

I believe it can be done. Short answer: No, I will not do it, time poor, demanding job.

Hints:

You can get powershell to read a MySQL Database. There are examples on that https://www.cogmotive.co...ng-mysql-from-powershell is the first one I've seen.

Powershell can update the VMix API very efficiently, it can create playlist files efficiently which are essentially text files.

I have very little experience with vTask (looked due to curiosity once). So someone else is best to answer how to make a connection with that.

I can not see why a programmer can't accomplish this, potentially in Powershell or even PHP which another person used. Powershell was my choice because you didn't have to install a single thing (I keep my Vmix rigs as minimal as I can as far as bloatware goes) and I write a few scripts for basic server maintenance jobs in the language.

Sorry I'm not the right man for the job, simply because I have too much other work and I'm unlikely to follow it through. (Heading into my peak period as well)

Hopefully others can help. I can see from those modifying the little kick starter script they have figured it out and enhancing it. So I think you can do 95% or possibly even 100% of your list. vMix themselves might be interested.

I'm not a super powershell programmer, I would expect after 70-100 hours labor at my skill level would have something very close to version 1 (you would want it well tested). I just don't have that spare time and money is unlikely to motivate me, unless it's ridiculously lucrative.

After all my 10+ hours of time I invested in the script. I used it twice (in production) and gave it to the forum. I wrote this code for a Charity Auction Event. I was not paid, but happy to give my skill for the charity. It was to show the names of the current playing videos, which related to the items for sale. The order of the items was not set the auctioneer needed the ability to jump around. I also had to enter all the bid prices and could not type fast enough doing both. Nothing to do with "Now Playing" for music, but essentially saw that could be done too after about 1 hour extra changes to the script I made rather flexible.

I have a demanding IT job at an auction company which uses Vmix for some aspects, so I guess I knew exactly what to do for a charity auction.

Thanks for thinking of me :) It's a cool project, someone younger should use it to improve their skills. Possibly a university student in Norway looking for practical experience project to finish off an IT or Multimedia degree.
polar  
#30 Posted : Tuesday, February 13, 2018 4:43:54 PM(UTC)
polar

Rank: Newbie

Groups: Registered
Joined: 1/29/2018(UTC)
Posts: 7
Location: Norway

Thx for the extensive answer. I totally see your situation and respect that. You're in the same boat as I am :). I'll do some more research and will fiddle with the script when I find some spare time, see where it gets me. Or I can try one the Fiverr offers. I guess it is finding the right way to run vMix solely on API commands.

I hope I can post my findings here on this forum so that you or others can comment and guide me in the right direction.

Regards,

Polar
mikeel74  
#31 Posted : Thursday, February 15, 2018 2:09:08 AM(UTC)
mikeel74

Rank: Newbie

Groups: Registered
Joined: 11/4/2015(UTC)
Posts: 3
Location: philippines

Thanks: 1 times
[Hi Sir my regards,


I need your help, I am using vmix as a movie player for my channel. i am using a scheduler and your script vmix-running- mon , but everytime i use an overlay crawl text, it is automatically detected by the script and the movie title changes.


Can you please help me with this..

Thank you

Mike
GERDAN4  
#32 Posted : Monday, February 18, 2019 1:50:39 AM(UTC)
GERDAN4

Rank: Newbie

Groups: Registered
Joined: 2/16/2019(UTC)
Posts: 4
Argentina

Hello, sorry for the English (I write from Argentina and I am using the Google translator). This is my first comment in the forum. In fact, I registered here only a couple of days ago.

Apparently, this is an inactive topic for some time; however, maybe someone will answer.

I would like to know if someone has an idea or solution, using this script (specifically the JAIRODJ version), to divide the titles in a xaml with two TextBlock, obtaining the name of the song on one hand and the artist's name on the other.

It is probably a basic operation (I do not know), but I can not find the answer: my knowledge about scripting is really poor. I have tried with .split ("-"), but I can not associate the remaining text with the second TextBlock.

If anyone can guide me, it would be wonderful. Otherwise, we still have to thank Speegs in the first place, and then JAIRODJ.

Greetings. And sorry for the length (I have a serious tendency to write a lot).
GERDAN4  
#33 Posted : Tuesday, February 19, 2019 1:02:59 AM(UTC)
GERDAN4

Rank: Newbie

Groups: Registered
Joined: 2/16/2019(UTC)
Posts: 4
Argentina

Anything else. When the @state = Running is replaced by @type = Video, the title does not play, the script throws errors in the Powershell window and, of course, raises the consumption of the PC memory. But, if it is replaced by AudioFile or VideoList, everything runs fine. I do not understand why type = video does not work.
I'm trying that, when an audio file is executed, play a video overlay (in truth, a sequence of images in a loop, so as not to generate conflicts with the video file being played and the title take the data from this video) .
OldHans  
#34 Posted : Wednesday, November 29, 2023 2:21:14 PM(UTC)
OldHans

Rank: Member

Groups: Registered
Joined: 3/10/2021(UTC)
Posts: 11
Man
Germany
Location: Vicinity of Hamburg/Germany

Thanks: 2 times
Even your post and script is a long time ago, @Speegs, it was a good base for me.

Here I will provide an improved version to the vMix community.

Put the name of the currently playing video file list into a Title Input and shows this title as an overlay

Features:

  1. at script start the user is prompted for Title Input Number, Title text field, Video List Input and Overlay number with predefined values.
  2. automatically removes preceeding title text like "List - " as well as file extension.
  3. shows overlay after 1.5 sec after video starts playing and hides overlay 2.5 sec before video ends (times can be changed, see section User Definable Variables).
  4. overlay to be shown requires the Video List Input is active in vMix program window.
  5. while the specified overlay is displayed, the vMix operator is free to set another Title Input into that overlay. If the overlay is switched off by the vMix operator, the specifed Title input will be re-displayed automatically.
  6. if a playing video stopped exactly at it's end and no further video is played, the vMix operator may display any Title Input in the specified overlay without interference by this script.
  7. runs in Microsoft PowerShell on the vMix computer or an remote computer in the same network (see section "User Definable Variables").
  8. successfully tested with vMix 4K v25.0.0.34 under Windows 10 Pro v1909, English
  9. by default, this script can be used "as is" on the local vMix computer


Personal note: even though I had apx 30 years experience in professional software development beginning in early 1980, I never dealt (now I know why ;-) ) with PowerShell, VisualBasic nor XML and .NET stuff. So I need to learn a lot the last days, which took a while at my age. For PowerShell experts there might be some possible optimizations.

Beside functionality, automation, I made the variable names more readable, formatted the code for better readabilty (here someone may see my Pascal background ;-) ) as well as a lot of comments.

Best regards,
OldHans


Code:

# Original by: 30-NOV-2015 / Speegs (https://forums.vmix.com/posts/t1177-Auto-update-NOW-PLAYING-graphic-overlay)
# Last change: 29-NOV-2023 / OldHans
#
# Put the name of the currently playing video file list into a Title Input and shows this title as an overlay
#
# Features:
#
# 1. at script start the user is prompted for Title Input Number, Title text field, Video List Input and Overlay
#    number with predefined values.
#
# 2. automatically removes preceeding title text like "List - " as well as file extension.
#
# 3. shows overlay after 1.5 sec after video starts playing and hides overlay 2.5 sec before video ends
#    (times can be changed, see section User Definable Variables).
#
# 4. overlay to be shown requires the Video List Input is active in vMix program window.
#
# 5. while the specified overlay is displayed, the vMix operator is free to set another Title Input
#    into that overlay. If the overlay is switched off by the vMix operator, the specifed Title input
#    will be re-displayed automatically.
# 
# 6. if a playing video stopped exactly at it's end and no further video is played, the vMix operator 
#    may display any Title Input in the specified overlay without interference by this script.
#
# 7. runs in Microsoft PowerShell on the vMix computer or an remote computer in the same network
#    (see section "User Definable Variables").
# 
# 8. successfully tested with vMix 4K v25.0.0.34 under Windows 10 Pro v1909, English
#
# 9. by default, this script can be used "as is" on the local vMix computer
#
# Notes:
#
# 1. in a batch file (.BAT) call this script using (without quotes)
#
#       "PowerShell.exe -ExecutionPolicy ByPass -File ./vmix-playlist-mon.ps1"
#
# 2. if script runs in "PowerShell ISE", then launch "PowerShell ISE" using "Run As Administrator", then
#    in the Console Windows execute the command "Set-ExecutionPolicy -ExecutionPolicy Bypass".
#
# 3. the desired vMix Preset should be loaded before running this Script
#
# 4. ensure that the text field of the Title Input is not linked to a Data Source
#
# Actual Problems:
#
# 1. Non ASCII characters (often used in german, french, spanisch, etc.) that are allowed in Windows filenames are not
#    correctly handled from within PowerShell. This is due to the complexity of dealing with Unicode, UTF8 etc., as well
#    as the character set used by PowerShell.
#    Using the $TitleText.Replace(unicode, newcode) method will crash the script at least on german Umlauts.
#    No generally working solution found yet.
#

#------------------------------------------------------------------------------------------------------------------
# Preset of variables that will actually be entered by the user at script start

param (
       [string]$TitleInputNumber = "24",
       [string]$TitleInputField  = "Description.Text",
       [string]$ListInputNumber  = "44",
       [string]$OvlNumber        = "2"
      )

#------------------------------------------------------------------------------------------------------------------
# Assembly für Visual Basic in die PowerShell-Umgebung laden.
# Hierdurch können Funktionen in der Visual Basic-Library aufgerufen werden, z.B [Microsoft.VisualBasic.Interaction]::InputBox

[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')

#------------------------------------------------------------------------------------------------------------------
# Benutzereingabe im Konsolenfenster:

# The input number for the vMix Title to change
$TitleInputNumber = [Microsoft.VisualBasic.Interaction]::InputBox("Number or Name of vMix Input to be displayed in overlay, eg: NewsHD.xaml)", "Number/Title", $TitleInputNumber)

# The name of the title field to modify, e.g. Description.Text or Ticker.Text
$TitleInputField = [Microsoft.VisualBasic.Interaction]::InputBox("Name of the text field in Input $TitleInputNumber to modify (eg: Description.Text)", "Text field to modify", $TitleInputField)

# Nummer des vMix Inputs vom Typ "List" mit den Videos
$ListInputNumber = [Microsoft.VisualBasic.Interaction]::InputBox("Numer of vMix Input of type List with videos", "List Input Nubmer", $ListInputNumber)

# Nummer des vMix Inputs vom Typ "List" mit den Videos
$OvlNumber = [Microsoft.VisualBasic.Interaction]::InputBox("Numer of vMix Overlay", "Overlay Number", $OvlNumber)

#------------------------------------------------------------------------------------------------------------------
# User Definable Variables 

# URL to retrieve all data from vMix API in XML format
$xmlurl = "http://localhost:8088/API/"

# URL to set the text in the specified field of a dedicated Title Input
$UrlSetTitleText   = $xmlurl + "?Function=SetText&Input=" + $TitleInputNumber + "&SelectedName=" + $TitleInputField + "&Value="

# URL to fade-in the Title Input into Overlay
$UrlSetOvlFadeIn   =  $xmlurl + "?Function=OverlayInput" + $OvlNumber + "In&Input=" + $TitleInputNumber

# URL to fade-out the Title Input into Overlay
$UrlSetOvlFadeOut  =  $xmlurl + "?Function=OverlayInput" + $OvlNumber + "Out&Input=" + $TitleInputNumber

# Overlay Control
$OvlControlEnabled = $true   # set to $false to disable the overlay fade in/out feature
$OvlFadeInDelay    = 1500    # 0 oder Zeit in msec zum Einblenden des Overlays nachdem das Video gestartet ist
$OvlFadeOutDelay   = 2500    # 0 oder Zeit in msec zum Ausblenden des Overlays bevor das Video endet

#------------------------------------------------------------------------------------------------------------------
# Internal Variables

$TitleText     = ""        # current Title Text
$LastTitleText = ""        # last Title Text used for comparision with the actual one

$VideoState    = ""        # state of video "Paused" | "Running"
$VideoDuration = 0         # video duration in msec
$VideoPosition = 0         # video position in msec
$OverlayState  = $false    # is overlay activated
$ActiveInput   = 0         # number of active input (the input shown in "program")

$i             = 0         # string index variable
$fileExtPos    = 0         # position of file extension in a string

$BeAliveCount  = 0         # every 60 seconds write the "be alive dot" in a new line in the PowerShell Console

#------------------------------------------------------------------------------------------------------------------
# Main Program Loop

Write-Host ""
Write-Host "Parameter Summary"
Write-Host "------------------------------------------------------------------"
Write-Host "vMix URL                             : " $xmlurl 
Write-Host "Number of vMix Input shown in overlay: " $TitleInputNumber
Write-Host "Text field for video title           : " $TitleInputField
Write-Host "Overlay Number                       : " $OvlNumber
Write-Host "Overlay Fade-In delay                : " $OvlFadeInDelay " msec"
Write-Host "Overlay Fade-Out delay               : " $OvlFadeOutDelay " msec"
Write-Host "Input Number with list of videos     : " $ListInputNumber
Write-Host "------------------------------------------------------------------"
Write-Host "Press 'q' to quit" 
Write-Host ""

# hide the overlay because it might be that some other input is currently displayed
(New-Object System.Net.WebClient).DownloadString("$UrlSetOvlFadeOut")

while ($true) 
   {
    # fetch XML data from vMix Web API
    [xml]$XmlData = (New-Object System.Net.WebClient).DownloadString($xmlurl)
    
    # read XML node of the List Input by it's vMix Input Number (or name)
    $XmlNode = $XmlData.SelectNodes("/vmix/inputs/input[@number='$ListInputNumber']")

    # get the actual title of the vMix List Input that contains the video files. The title consists of 'Name of Input" + " - " + filename currently played.
    # In case the specifed vMix List Input does not exist, $TitleText.Length = 0 - so no errors will be displayed, the script will not crash.
    $TitleText         = ($XmlNode | Select-Object -ExpandProperty title    | Out-String) 

    $VideoState        = ($XmlNode | Select-Object -ExpandProperty state    | Out-String)     # "Paused" | "Running"
    $VideoDuration     = ($XmlNode | Select-Object -ExpandProperty duration | Out-String)     # duration in msec
    $VideoPositionTemp = ($XmlNode | Select-Object -ExpandProperty position | Out-String)     # current position in msec

    # Because there are two properties named "position" in the XML, the variable "$VideoPositionTemp" will not only have the numeric position value but this:
    #
    #    123456789
    #    
    #    panY   zoomX zoomY
    #    ----   ----- -----
    #    -0.063 0.8   0.8  
    #
    # The first number is the "position"-value we are looking for. The following loop will extract this number in a classic way:

    $VideoPosition = ""
    $i = 0
    while ( ($i -lt $VideoPositionTemp.Length) -and ($VideoPositionTemp.Chars($i) -ge "0") -and ($VideoPositionTemp.Chars($i) -le "9") )
       {
        $VideoPosition = $VideoPosition + $VideoPositionTemp.Chars($i)
        $i = $i + 1
       } # while

    if ($LastTitleText -ne $TitleText) 
       # title changed, vMix Title Input needs to be updated 
       {    
        # at first place store the new unmodified title as the last inquired title text to detect changes in the next loop
        $LastTitleText = $TitleText

        # remove the file extension beginning at the last dot found in the name
        $fileExtPos = $TitleText.LastIndexOf(".")
        if ($fileExtPos -gt 0)
           {
            $TitleText = $TitleText.Substring(0, $fileExtPos);
           }
           
        # the "shortTitle" read from the vMix Input is the same as the text the vMix Input's full title begins with
        $ShortTitleText = ($XmlNode | Select-Object -ExpandProperty shortTitle | Out-String)
        
        # but for some unknown reason $ShortTitleText has 2 invisible chars more at the end, so Trim() helps here
        $ShortTitleText = $ShortTitleText.Trim()

        # return the right part of the title string beginning at index + 3 for " - "
        $TitleText = $TitleText.Substring($ShortTitleText.Length + 3)

        # in a URL the following characters must be encoded as "%" + hex value
        $TitleText = $TitleText -replace "#", "%23"           # pound character
        $TitleText = $TitleText -replace "&", "%26"           # ampersand
        $TitleText = $TitleText -replace [char]0x0060, "%60"  # grave accent

        # write information on the PowerShell Console
        write-host ""
        write-host "Updating vMix input: $TitleInputNumber - $TitleInputField" -ForegroundColor Yellow
        write-host "With: " $TitleText -ForegroundColor Yellow
        
        # temporary create an URL to set the new title text
        $TempURL = $UrlSetTitleText + $TitleText

        # write information on the PowerShell Console
        write-host $TempURL -ForegroundColor Green

        # write the new title text into the text object of the vMix Input
        (New-Object System.Net.WebClient).DownloadString("$TempURL")
        # in PowerShell Console the text "Function completed successfully." will be shown implicitly

       } # if ($LastTitleText -ne $TitleText)

    
    if ($OvlControlEnabled = $true)
       # handle overlay fade in/out only if generally enabled
       {
        # check whether there is any vMix Input displayed in the overlay $OvlNumber
        # 
        $OverlayInputNumber = $XmlData.SelectSingleNode("/vmix/overlays/overlay[$OvlNumber]").InnerXml
        $OverlayState = ($OverlayInputNumber -ne "")

        # get the number of the active input in vMix
        $ActiveInput = $XmlData.SelectSingleNode("/vmix/active").InnerXml

        # Check if the overlay needs to be shown
        # Note: the variables needs to be forced (type casted) to be interpreted as a 64-Bit Integer value. Otherwise they would be treated as strings which will not give the expected results.

        if ( (($ActiveInput -ne $ListInputNumber) -and ($OverlayState -eq $true)) -or ( ($OverlayState -eq $true) -and ([int64]$VideoPosition -ge ([int64]$VideoDuration - [int64]$OvlFadeOutDelay)) -and ([int64]$VideoPosition -ne [int64]$VideoDuration) ) )
           # if the Video List Input is the active program AND 
           # the overlay not already visible AND 
           # the current video position is past the fade-in AND 
           # before fade-out time, then show the overlay
           {
            write-host ""
            write-host "Overlay $OvlNumber fade IN" -ForegroundColor Yellow
            (New-Object System.Net.WebClient).DownloadString("$UrlSetOvlFadeIn")
            $OverlayState = $true
           }

        # Check if the overlay needs to be hidden. If the current video position equals it's duration, this is when the video is at it's end and stopped, the vMix operator may show any Input in the overlay.
        # Note: the variables needs to be forced (type casted) to be interpreted as a 64-Bit Integer value. Otherwise they would be treated as strings which will not give the expected results.

        if ( (($ActiveInput -ne $ListInputNumber) -and ($OverlayInputNumber -eq $TitleInputNumber)) -or ( ($OverlayState -eq $true) -and ([int64]$VideoPosition -ge ([int64]$VideoDuration - [int64]$OvlFadeOutDelay)) -and ([int64]$VideoPosition -ne [int64]$VideoDuration) ) )
           # if the Video List Input is not the active program AND the title input is in the overlay, OR
           # the overlay is visible AND 
           # the current video position has passed the fade-out time before the end AND 
           # the video position is not exactly at the end, then hide the overlay.
           #
           # The last condition ("the video position is not exactly at the end") makes sure, that 
           # the vMix operation may manually show an Title Input in the overlay if a video ended 
           # and the video list stops. Otherwise the overlay would be immediatly hidden again 
           # because of the preceeding conditions are true.
           {
            write-host ""
            write-host "Overlay $OvlNumber fade OUT" -ForegroundColor Yellow
            (New-Object System.Net.WebClient).DownloadString("$UrlSetOvlFadeOut")
            $OverlayState = $false
           }
       } # if ($OvlControlEnabled = $true)
    
    # Write a dot as a "be alive" signal in the PowerShell Console
    $BeAliveCount = $BeAliveCount + 1
    if ($BeAliveCount -ge 60)
       {
        write-host "."      # after the 60th dot make a new line
        $BeAliveCount = 0
       }
    else
       {
        write-host "." -NoNewLine
       }

    # pause this script for 1 second
    Start-Sleep -Seconds 1

    # check whether the user has pressed "q" on the keyboard. If yes, then terminate this script.
    if ($Host.UI.RawUI.KeyAvailable -and ("q" -eq $Host.UI.RawUI.ReadKey("IncludeKeyUp,NoEcho").Character)) 
       {
        Write-Host ""
        Write-Host "Exiting now..."
        break;
       } # if

   } # WHILE

#------------------------------------------------------------------------------------------------------------------

Users browsing this topic
Guest
Similar Topics
Auto update NOW PLAYING graphic overlay - Modified (3rd Party Software and Development)
by JAIRODJ 1/12/2017 9:41:52 AM(UTC)
2 Pages<12
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.