Wait till video is finished?

Find quick help here to get you started with Hollywood
Post Reply
Jan
Posts: 8
Joined: Sun Sep 17, 2017 10:28 am

Wait till video is finished?

Post by Jan » Sat Feb 23, 2019 2:47 pm

Another newbie question, please.

I've downloaded AVCodec video so I can use PlayVideo() in my script. However if it's the last command, the script finishes and video closes after 1-2 seconds. How can I tell Hollywood to wait till the video is finished? I don't want to use WaitLeftMouse command.

One more thing, please. How can I compile a complete standalone executable so it includes the codec and the video too?

Thank you in advance.

Jan
Posts: 8
Joined: Sun Sep 17, 2017 10:28 am

Re: Wait till video is finished?

Post by Jan » Sat Feb 23, 2019 8:02 pm

I think I figured it out. It works but can anyone confirm it's the right method?

playing = IsVideoPlaying(1)

While playing = True
playing = IsVideoPlaying(1)
Wend

End

Bugala
Posts: 759
Joined: Sun Feb 14, 2010 7:11 pm

Re: Wait till video is finished?

Post by Bugala » Sat Feb 23, 2019 10:54 pm

Havent played with videos, but at least your idea seems right.

Regarding adding plugins to exe, you just need to link them to your exe.

Dont recall it from memory, but i think it is putting at beginning of your code something like this:

Code: Select all

@INCLUDE "pluginname.plg"

User avatar
airsoftsoftwair
Posts: 3027
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Wait till video is finished?

Post by airsoftsoftwair » Sat Feb 23, 2019 11:51 pm

@Bugala:
@INCLUDE is used for scripts, not for plugins.

@Jan:
You can do it like this:

Code: Select all

@REQUIRE "avcodec", {Link = True}
@VIDEO 1, "test.mpg"

PlayVideo(1)
playing = IsVideoPlaying(1)

While playing = True
    playing = IsVideoPlaying(1)
    VWait
Wend
Note that I have added a VWait() here. Otherwise your loop will be polling the video state as many times as the CPU allows, which is very bad. There should be some throttle to prevent wasting CPU cycles. VWait() is a convenient solution, you could of course also use a timer.

Jan
Posts: 8
Joined: Sun Sep 17, 2017 10:28 am

Re: Wait till video is finished?

Post by Jan » Sun Feb 24, 2019 11:25 am

Thank you for your replies and advices. I did not think about the CPU cycles. Great forum!

Post Reply