DrawMovie

Blitz3D Forums/Blitz3D Programming/DrawMovie

Amanda Dearheart(Posted 2012) [#1]
I want to play an movie continuously until a user presses a key.

I have a drawmovie command in a repeat..until loop such as

repeat
if keyhit(1) then exit
drawmovie movie, x, y, w, h
flip
until


(not actual code)

The movie plays once, then stops. I want it to keep playing.
P.s. I also tried to use a while..wend loop for the program!


Kryzon(Posted 2012) [#2]
An idea. The first time you play it, cache each frame.

After it finishes, start playing from the cache.
Untested:
Local movieLength# = 3.45 ;Seconds. 
Local movieFPS = 30 ;Rate with which you wish to capture\reproduce the movie.
Local TOTAL_FRAMES# = (movieLength * movieFPS) + 3 ;The '+3' is to add some safety padding.
Local captureTimer = CreateTimer(movieFPS)
Local captureFrame = 0

Local cachedMovie = CreateImage(w, h, Int(TOTAL_FRAMES)) ;Create an AnimImage.
Local originalMovie = OpenMovie("movie.avi")

;First time:
While MoviePlaying(originalMovie)
	WaitTimer(movieFPS)	

	DrawMovie originalMovie, x, y, w, h
	GrabImage cachedMovie, 0, 0, captureFrame
	captureFrame = captureFrame + 1	

	Flip
Wend

;Second time, up to eternity:

Local tempFrame = 0
While Not KeyHit(1)
	WaitTimer(movieFPS)

	DrawImage cachedMovie, x, y, tempFrame
	tempFrame = tempFrame + 1
	If tempFrame > captureFrame then tempFrame = 0 ;Loop the footage.

	Flip
Wend

End
EDIT: A much safer way is to externally convert the movie file to a sequence of JPEGs etc., then load, capture and free each separate image with GrabImage as a frame of a single Blitz3D AnimImage - you're not required to use an AnimImage, but having all frames stored inside the single Blitz3D Image is slightly more convenient (and I think you have less memory footprint than keeping each frame as a separate Blitz3D Image).

Last edited 2012


Matty(Posted 2012) [#3]
You have to load the movie a second and subsequent time...the documentation says this itself - drawmovie plays a movie once through only.


EPS(Posted 2012) [#4]
Try this (it's german but anyway usefull) http://qbasic.east-power-soft.de/index.php?menu=blitzbasic_blitzbasic_codes_blitzvideo


Kryzon(Posted 2012) [#5]
You have to load the movie a second and subsequent time

The harddisk I/O would stall execution. It wouldn't be smooth.