logo

Live Production Software Forums


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

Notification

Icon
Error

Options
Go to last post Go to first unread
Ham4u62  
#1 Posted : Saturday, August 10, 2024 11:33:17 PM(UTC)
Ham4u62

Rank: Member

Groups: Registered
Joined: 7/15/2021(UTC)
Posts: 11
Iran (Islamic Republic Of)
Location: Mashhad

Thanks: 5 times
Hi

I have a play list of items. I want to overlay an input every time that one of specific item plays in my list and if that one is not play turn the overlay off.
I'm not good at scripting but I used the blow code:

Code:
dim xml as string = API.XML()
dim GetInputNumber as string = ""
dim GetInputName as string = ""

dim x as new system.xml.xmldocument
x.loadxml(xml)

GetInputNumber = (x.SelectSingleNode("/vmix/active").InnerText)
GetInputName = (x.SelectSingleNode("//input[@number='"& GetInputNumber &"']/@title").Value)

do while true
if GetInputName = "List - B" then

sleep (500)
API.Function("OverlayInput1In", Input:="2")

else

API.Function("OverlayInput1out")

end if
sleep (500)
loop


My problem is this code works one time and not work every time But my playlist is in the loop.
doggy  
#2 Posted : Sunday, August 11, 2024 12:22:36 AM(UTC)
doggy

Rank: Advanced Member

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

Thanks: 288 times
Was thanked: 946 time(s) in 781 post(s)
Originally Posted by: Ham4u62 Go to Quoted Post
Hi

I have a play list of items. I want to overlay an input every time that one of specific item plays in my list and if that one is not play turn the overlay off.
I'm not good at scripting but I used the blow code:

dim xml as string = API.XML()
dim GetInputNumber as string = ""
dim GetInputName as string = ""

dim x as new system.xml.xmldocument
x.loadxml(xml)

GetInputNumber = (x.SelectSingleNode("/vmix/active").InnerText)
GetInputName = (x.SelectSingleNode("//input[@number='"& GetInputNumber &"']/@title").Value)

do while true
if GetInputName = "List - B" then

sleep (500)
API.Function("OverlayInput1In", Input:="2")

else

API.Function("OverlayInput1out")

end if
sleep (500)
loop

My problem is this code works one time and not work every time But my playlist is in the loop.


GetInputName is never (able) to change within the loop ie the IF has always the same result !

thanks 1 user thanked doggy for this useful post.
Ham4u62 on 8/11/2024(UTC)
Ham4u62  
#3 Posted : Sunday, August 11, 2024 2:29:05 AM(UTC)
Ham4u62

Rank: Member

Groups: Registered
Joined: 7/15/2021(UTC)
Posts: 11
Iran (Islamic Republic Of)
Location: Mashhad

Thanks: 5 times
Is there any solution to solve this problem?
doggy  
#4 Posted : Sunday, August 11, 2024 2:38:59 AM(UTC)
doggy

Rank: Advanced Member

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

Thanks: 288 times
Was thanked: 946 time(s) in 781 post(s)
Originally Posted by: Ham4u62 Go to Quoted Post
Is there any solution to solve this problem?


Yes. It was given in the response.

your testing for a change but the change is not possible as the variable to check is not updated within the loop so it wil never change the the outcome within the loop
Correct the logic of the script
Ham4u62  
#5 Posted : Sunday, August 11, 2024 2:53:18 AM(UTC)
Ham4u62

Rank: Member

Groups: Registered
Joined: 7/15/2021(UTC)
Posts: 11
Iran (Islamic Republic Of)
Location: Mashhad

Thanks: 5 times
I don't want change anything. I want to read active input name and turn on an overlay base on my condition.If condition not met turn an overlays off and do this through loop always.
can you give me a true logic based on my need
nikosman88  
#6 Posted : Sunday, August 11, 2024 3:02:03 AM(UTC)
nikosman88

Rank: Advanced Member

Groups: Registered
Joined: 12/24/2021(UTC)
Posts: 429
Greece
Location: athens

Thanks: 116 times
Was thanked: 65 time(s) in 61 post(s)
Originally Posted by: Ham4u62 Go to Quoted Post
I don't want change anything. I want to read active input name and turn on an overlay base on my condition.If condition not met turn an overlays off and do this through loop always.
can you give me a true logic based on my need

Hello. Try this one
Code:

dim xml as string = ""
dim GetInputNumber as string = ""
dim GetInputName as string = ""

dim x as new system.xml.xmldocument

do while true
    xml = API.XML()  ' Fetch the current XML each time inside the loop
    x.loadxml(xml)

    GetInputNumber = x.SelectSingleNode("/vmix/active").InnerText
    GetInputName = x.SelectSingleNode("//input[@number='"& GetInputNumber &"']/@title").Value

    if GetInputName = "List - B" then
        API.Function("OverlayInput1In", Input:="2")
    else
        API.Function("OverlayInput1Out")
    end if

    sleep(500)  ' You can adjust this sleep if needed
loop


thanks 1 user thanked nikosman88 for this useful post.
Ham4u62 on 8/11/2024(UTC)
doggy  
#7 Posted : Sunday, August 11, 2024 4:19:27 AM(UTC)
doggy

Rank: Advanced Member

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

Thanks: 288 times
Was thanked: 946 time(s) in 781 post(s)
Originally Posted by: Ham4u62 Go to Quoted Post
I don't want change anything. I want to read active input name and turn on an overlay base on my condition.If condition not met turn an overlays off and do this through loop always.
can you give me a true logic based on my need


Well you will have to , at least the logic of your script to get the desired intent !
Advice is to study how to programm , is only way to learn for future , instead of relying on a fixed answer especially a basic one like this (Google is a good friend)

I repeat , the solution was given , now Nikosman88 gave you the written solution , hope you will see that the provious answer were correct regarding the logic
Compare Yours and his and learn.
thanks 1 user thanked doggy for this useful post.
Ham4u62 on 8/11/2024(UTC)
Ham4u62  
#8 Posted : Sunday, August 11, 2024 4:58:11 AM(UTC)
Ham4u62

Rank: Member

Groups: Registered
Joined: 7/15/2021(UTC)
Posts: 11
Iran (Islamic Republic Of)
Location: Mashhad

Thanks: 5 times
Thank you doggy for your piece of advice. I'm learning scripting and specially logic first and said I'm not good at scripting.I searched and didn't find proper solution and decided to ask here.
nikosman88  
#9 Posted : Sunday, August 11, 2024 5:33:03 AM(UTC)
nikosman88

Rank: Advanced Member

Groups: Registered
Joined: 12/24/2021(UTC)
Posts: 429
Greece
Location: athens

Thanks: 116 times
Was thanked: 65 time(s) in 61 post(s)
Originally Posted by: doggy Go to Quoted Post
Compare Yours and his and learn

I like to be honest. My answer to an allready 99% made script from Ham4u62 is AI generated answer and i dont feel any shame for it. At 2024 we also have a great tool to do things and personally im using it when i think it can help.
thanks 1 user thanked nikosman88 for this useful post.
Ham4u62 on 8/11/2024(UTC)
Ham4u62  
#10 Posted : Sunday, August 11, 2024 5:35:25 AM(UTC)
Ham4u62

Rank: Member

Groups: Registered
Joined: 7/15/2021(UTC)
Posts: 11
Iran (Islamic Republic Of)
Location: Mashhad

Thanks: 5 times
Originally Posted by: nikosman88 Go to Quoted Post
Originally Posted by: doggy Go to Quoted Post
Compare Yours and his and learn

I like to be honest. My answer to an allready 99% made script from Ham4u62 is AI generated answer and i dont feel any shame for it. At 2024 we also have a great tool to do things and personally im using it when i think it can help.

Two Thumbs Up
It works Properly and fine
nikosman88  
#11 Posted : Sunday, August 11, 2024 5:36:46 AM(UTC)
nikosman88

Rank: Advanced Member

Groups: Registered
Joined: 12/24/2021(UTC)
Posts: 429
Greece
Location: athens

Thanks: 116 times
Was thanked: 65 time(s) in 61 post(s)
Originally Posted by: Ham4u62 Go to Quoted Post
Thank you doggy for your piece of advice. I'm learning scripting and specially logic first and said I'm not good at scripting.I searched and didn't find proper solution and decided to ask here.

That`s the right way. First think how to do it and if you dont know,search. This is also how i work. For example if you didnt have the most script and go to chatgpt and ask from 0 to do it,it will fail.
Users browsing this topic
Guest (5)
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.