Page 1 of 1

Wait till video is finished?

Posted: Sat Feb 23, 2019 2:47 pm
by Jan
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.

Re: Wait till video is finished?

Posted: Sat Feb 23, 2019 8:02 pm
by Jan
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

Re: Wait till video is finished?

Posted: Sat Feb 23, 2019 10:54 pm
by Bugala
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"

Re: Wait till video is finished?

Posted: Sat Feb 23, 2019 11:51 pm
by airsoftsoftwair
@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.

Re: Wait till video is finished?

Posted: Sun Feb 24, 2019 11:25 am
by Jan
Thank you for your replies and advices. I did not think about the CPU cycles. Great forum!