Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / program continues before movie is fully loaded

Author
Message
Jcoggins
18
Years of Service
User Offline
Joined: 6th May 2006
Location:
Posted: 9th Apr 2008 06:44
I have learned through trial and error that DBPro programs do not wait on .avi movies to load before they continue executing the next line. For example, look at the code below:



If you create a significantly sized movie and load it using the above code you will notice the word "testing" will appear on the right side of the movie before the movie finishes loading and starts playing (assuming the movie doesn't cover the entire screen).

I was lead to beleive (somewhere) that DBPro would not continue with the next line until after it had successfully performed the current line it was on.

Jason
pcRaider
17
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 9th Apr 2008 10:02
Do you wish you wait?

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th Apr 2008 15:39
Although I personally believe that goto's are not inherently bad, littering your code with them where there is absolutely no need to *IS* bad.



Twinsen
18
Years of Service
User Offline
Joined: 20th Jun 2006
Location: Romania
Posted: 9th Apr 2008 15:50
what ? now this is another dumb thing I discover ... how's this possible ??? each command should be executed at a time ... how can this be ??? it's like the code gives the loading instruction and then goes on, not caring if the file was indeed loaded or not ... what if someone needs to play the movie the next line ??? a fatal error would occur saying "The animation at line xx was not found" or something like that ...

Could you help me treat my injured Dino-Fly ?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th Apr 2008 15:58
No, what's dumb is jumping in without thinking about WHY it is this way.

For an entire class of media - animations, sound and music - you DON'T want them to stop your program until they finish. What kind of game would it be if the program froze every time you took a shot? Or a game without an intro movie that plays while it's loading everything else?

Twinsen
18
Years of Service
User Offline
Joined: 20th Jun 2006
Location: Romania
Posted: 9th Apr 2008 16:03
well that makes sense now but the dumb thing was that in a previous thread (I think you'll still find it on the first page ) inside the Newcomer's section, someone was asking for a way to implement a loading screen while loading the media files and someone said at one point that the program doesn't do anything else until it completely loads the files ... so that's why I took that for granted I also agreed at one point after seeing that thread (I think I replied to it) ... anyway, thanks ... things are much clearer now but still ... how can I be sure that the movie is loaded before I call it with a PLAY command ??? cause depending on the hardware, the loading time is different so I can't make a timed waiting period ...

Could you help me treat my injured Dino-Fly ?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th Apr 2008 16:15
The load command won't return until it has done enough to actually allow the animation/sound/music to play.

You then start it off using the appropriate PLAY command - it's that command does not wait and will return immediately. There may even be a delay before it fully starts (video codecs and mp3 codecs in particular are slow to start).

Twinsen
18
Years of Service
User Offline
Joined: 20th Jun 2006
Location: Romania
Posted: 9th Apr 2008 16:24
so it does halt the program for a bit, but not for the whole file ... it's like the buffer streaming on the internet, right ?

Could you help me treat my injured Dino-Fly ?
pcRaider
17
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 9th Apr 2008 16:58
This technique is used a lot.

PLAY SOUND
PLAY MUSIC
PLAY ANIMATION
PLAY OBJECT
Twinsen
18
Years of Service
User Offline
Joined: 20th Jun 2006
Location: Romania
Posted: 9th Apr 2008 17:09
what do you mean ???

Could you help me treat my injured Dino-Fly ?
Jcoggins
18
Years of Service
User Offline
Joined: 6th May 2006
Location:
Posted: 9th Apr 2008 17:10
I want the program to display a graphic, start loading the movie and then, after the movie has finished loading, delete the graphic and then play the movie. Check out the pseudo code below:



The problem is that DBPro currently loads the image, displays the image, starts loading the animation and then deletes the image before the animation is fully loaded then starts playing the animation after it is finished loading.

There needs to be an "animation loaded" command that returns 1 if the animation has fully loaded or 0 if not. Then the program would be:



Jason
Jcoggins
18
Years of Service
User Offline
Joined: 6th May 2006
Location:
Posted: 9th Apr 2008 17:18
Also, if there is a delay before the video or audio codec starts is there a way to initialize them (or get them started and on standby) before they are actually called by the play command? If this were so would it not be possible to get the codecs ready when the program first starts before they are needed and then quickly call them when needed?

Jason
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 9th Apr 2008 17:36 Edited at: 9th Apr 2008 17:45
It was me that answered the other thread.

My logic was sound, but I didn't know that DBPro wouldn't treat the movie file much the same as it does any other file, such as loading a large object and all of it's textures..

I would think there's some way to tell when a movie is done playing though. Isn't there?

[edit]
ANIMATION PLAYING returns a 1 if the movie is playing, and a 0 if it's not.
[/edit]

Twinsen
18
Years of Service
User Offline
Joined: 20th Jun 2006
Location: Romania
Posted: 9th Apr 2008 17:53
well we'd need a command which can tell us when a file is fully uploaded into memory ... like some ANIMATION LOADED()=1 if the file is loaded and 0 if the file is not loaded or currently loading

Could you help me treat my injured Dino-Fly ?
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 9th Apr 2008 18:51
That would be nice, but I'm not sure how necessary it would be. They likely thought that since the animation can be played very shortly after the load is started, if not right away, then there's no need to figure out when it's finished loading. Also, for movies that are much to large to fit in memory it simply wouldn't be feasible.

So one example of how to handle this situation might be..

- Load a static graphic. A "load screen".
- Run the LOAD ANIMATION command.
- Create a plain and position it to fill the screen (behind the load screen that's showing)
- Play the animation to an image
- Texture the image to the plain
- Fade the load screen out to reveal your animation playing on the plain.
- Loop checking for ANIMATION PLAYING = 0 which tells you the movie is done (or check for escapekey as well)
- Continue on with your program.

It sounds like the animation will simply stream while it's loading.

Jcoggins
18
Years of Service
User Offline
Joined: 6th May 2006
Location:
Posted: 9th Apr 2008 18:53
The "animation playing" command does return 1 if playing and 0 otherwise but, according to IanM, DBPro only loads enough of the animation for it to start playing and then it returns from the "load animation" command and continues with the program. If the "play animation" and then the "animation playing" commands are started immediately after the "load animation" command it will return a 1 even though the animation hasn't fully loaded yet.

Jason
Jcoggins
18
Years of Service
User Offline
Joined: 6th May 2006
Location:
Posted: 9th Apr 2008 18:59
KISTech, What do you mean by a "plain"?

Sorry, I am a beginner.

Jason
Twinsen
18
Years of Service
User Offline
Joined: 20th Jun 2006
Location: Romania
Posted: 9th Apr 2008 19:44
by plain, he refers to a "layer" ... think of a sheet of paper behind another one ... in fact you have a plain in front of another and on this paper (or plain), you can draw anything including an animation

Could you help me treat my injured Dino-Fly ?
D Ogre
20
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 11th Apr 2008 02:21
I've played with DirectShow in C++ a little. When playing a movie, a buffer
is allocated in memory for it. When the movie fills this buffer with enough
samples packets from the stream, decoding is done and played through the AV
ouput renders. So, basicly the entire file does not load all at once unless
the file size is less than the buffer. There will always be a lag because
a thread has to be built to stream, decode, and render the video using several
filters and codecs registered on your system. This is the perfered method
which reduces the amount of memory usage. It also allows multiple threads to be
created to play more than one movie. Hence, the animation numbers in DBPro for
example. So, what IanM had said is correct about only loading enough to be played.
You can see the actual thread process, if you ever used GraphEdit.

Btw, KISTech means to actually use a DBPro 3D plain object and play the animation
to an image which the plain has been texture with. Look in the help files under
ANIMATION and BASIC 3D commands.

Login to post a reply

Server time is: 2024-11-15 18:11:31
Your offset time is: 2024-11-15 18:11:31