pygame documentation | || Home || Help Contents || || pygame || cdrom || constants || cursor || display || draw || || event || font || image || joystick || key || mixer || || mixer_music || mouse || movie || sndarray || surfarray || time || || transform || || CD || Channel || Clock || Font || Joystick || Movie || || Overlay || Rect || Sound || Surface || || color || cursors || sprite ||

## Movie

The Movie object represents an opened MPEG file. You control playback similar to a Sound object.
Movie objects have a target display Surface. The movie is rendered to this Surface in a background thread. If the Surface is the display surface, and the system supports it, the movie will render into a Hardware YUV overlay plane. If you don't set a display Surface, it will default to the display Surface.
Movies are played back in background threads, so there is very little management needed on the user end. Just load the Movie, set the destination, and Movie.play()
Movies will only playback audio if the pygame.mixer module is not initialized. It is easy to temporarily call pygame.mixer.quit() to disable audio, then create and play your movie. Finally calling pygame.mixer.init() again when finished with the Movie.
NOTE: When disabling the mixer so a movie may play audio, you must disable the audio before calling pygame.movie.Movie or the movie will not realise that it may access the audio. Before reinitialising the mixer, You must remove all references to the movie before calling pygame.mixer.init() or the init will fail, leading to errors when you attempt to use the mixer.
eg. pygame.mixer.quit() movie=pygame.movie.Movie(\"my.mpg\") movie.play() # process events until movie finished here movie.stop() movie=None # if you don't do this bit the init will fail pygame.mixer.init()

get_busy | - query the playback state
get_busy | - query the playback state
get_frame | - query the current frame in the movie
get_frame | - query the current frame in the movie
get_length | - query playback time of the movie
get_length | - query playback time of the movie
get_size | - query the size of the video image
get_size | - query the size of the video image
get_time | - query the current time in the movie
get_time | - query the current time in the movie
has_audio | - query if movie stream has audio
has_audio | - query if movie stream has audio
has_video | - query if movie stream has video
has_video | - query if movie stream has video
pause | - pause/resume movie playback
pause | - pause/resume movie playback
play | - start movie playback
play | - start movie playback
render_frame | - Render a specfic numbered frame.
rewind | - set playback position to the beginning of the movie
rewind | - set playback position to the beginning of the movie
set_display | - change the video output surface
set_display | - change the video output surface
set_volume | - change volume for sound
set_volume | - change volume for sound
skip | - skip the movie playback position forward
skip | - skip ahead a given amount of time
stop | - stop movie playback
stop | - stop movie playback

get_busy
`Movie.get_busy() -> bool`

Returns true if the movie is currently playing.

get_busy
`Movie.get_busy() -> bool`

Returns true if the movie is currently playing.

get_frame
`Movie.get_frame() -> int`

Gets the current video frame number for the movie.

get_frame
`Movie.get_frame() -> int`

Gets the current video frame number for the movie.

get_length
`Movie.get_length() -> float`

Returns the total time (in seconds) of the movie.

get_length
`Movie.get_length() -> float`

Returns the total time (in seconds) of the movie.

get_size
`Movie.get_size() -> width,height`

Returns the size of the video image the mpeg provides.

get_size
`Movie.get_size() -> width,height`

Returns the size of the video image the mpeg provides.

get_time
`Movie.get_time() -> float`

Gets the current time (in seconds) for the movie. (currently not working? SMPEG always reports 0)

get_time
`Movie.get_time() -> float`

Gets the current time (in seconds) for the movie.

has_audio
`Movie.has_audio() -> bool`

Returns a true value when the Movie object has a valid audio stream.

has_audio
`Movie.has_audio() -> bool`

Returns a true value when the Movie object has a valid audio stream.

has_video
`Movie.has_video() -> bool`

Returns a true value when the Movie object has a valid video stream.

has_video
`Movie.has_video() -> bool`

Returns a true value when the Movie object has a valid video stream.

pause
`Movie.pause() -> None`

This will temporarily stop playback of the movie. When called a second time, playback will resume where it left off.

pause
`Movie.pause() -> None`

This will temporarily stop playback of the movie. When called a second time, playback will resume where it left off.

play
`Movie.play(loops=0) -> None`

Starts playback of a movie. If audio or video is enabled for the Movie, those outputs will be created.
You can specify an optional argument which will be the number of times the movie loops while playing.

play
`Movie.play() -> None`

Starts playback of a movie. If audio or video is enabled for the Movie, those outputs will be created.

render_frame
`Movie.render_frame(framenum) -> int`

Returns the current frame number.

rewind
`Movie.rewind() -> None`

Sets the movie playback position to the start of the movie.

rewind
`Movie.rewind() -> None`

Sets the movie playback position to the start of the movie. This can raise a ValueError if the movie cannot be rewound.
The movie will automatically start playing if the movie is currently playing.
If rewinding the movie fails, it will invalidate this Movie object.

set_display
`Movie.set_display(Surface, [pos]) -> None`

Set the output surface for the Movie's video. You may also specify a position for the topleft corner of the video. The position defaults to (0,0) if not given.
The position argument can optionally be a rectangle, in which case the video will be stretched to fill the rectangular area.
You may also pass None as the destination Surface, and no video will be rendered for the movie playback.

set_display
`Movie.set_display(Surface, [rect]) -> None`

Set the output surface for the Movie's video. You may also specify a position for the topleft corner of the video.
The position argument must be a rectstyle if given. The video will be stretched to fill the rectangular area.
You may also pass None as the destination Surface, and no video will be rendered for the movie playback.

set_volume
`Movie.set_volume(val) -> None`

Set the play volume for this Movie. The volume value is between 0.0 and 1.0.

set_volume
`Movie.set_volume(val) -> None`

Set the play volume for this Movie. The volume value is between 0.0 and 1.0.

skip
`Movie.skip(seconds) -> None`

Sets the movie playback position ahead by the given amount of seconds. the seconds value is a floating point value

skip
`Movie.skip(seconds) -> None`

Skips ahead in the movie a given number of seconds. Totally experimental, and doesn't work very foos.

stop
`Movie.stop() -> None`

Stops playback of a movie. If sound and video are being rendered, both will be stopped at their current position.

stop
`Movie.stop() -> None`

Stops playback of a movie. If sound and video are being rendered, both will be stopped at their current position.