Class pyglet.media.Source

Known Subclasses:
StaticSource, StreamingSource
An audio and/or video source.

Methods

ManagedSoundPlayer play(self)
Play the source.
pyglet.image.Animation get_animation(self)
Import all video frames into memory as an Animation.
float get_next_video_timestamp(self)
Get the timestamp of the next video frame.
pyglet.image.AbstractImage get_next_video_frame(self)
Get the next video frame.

Properties

float duration
The length of the source, in seconds.

Instance Variables

AudioFormat audio_format = None
Format of the audio in this source, or None if the source is silent.
VideoFormat video_format = None
Format of the video in this source, or None if there is no video.

Method Details

play

play(self)

Play the source.

This is a convenience method which creates a ManagedSoundPlayer for this source and plays it immediately.

Returns: ManagedSoundPlayer

get_animation

get_animation(self)

Import all video frames into memory as an Animation.

An empty animation will be returned if the source has no video. Otherwise, the animation will contain all unplayed video frames (the entire source, if it has not been queued on a player). After creating the animation, the source will be at EOS.

This method is unsuitable for videos running longer than a few seconds.

Returns: pyglet.image.Animation

Since: pyglet 1.1

get_next_video_timestamp

get_next_video_timestamp(self)
Get the timestamp of the next video frame.
Returns:
float: The next timestamp, or None if there are no more video frames.

Since: pyglet 1.1

get_next_video_frame

get_next_video_frame(self)

Get the next video frame.

Video frames may share memory: the previous frame may be invalidated or corrupted when this method is called unless the application has made a copy of it.

Returns:
pyglet.image.AbstractImage: The next video frame image, or None if there are no more video frames.

Since: pyglet 1.1


Property Details

duration

The length of the source, in seconds.

Not all source durations can be determined; in this case the value is None.

Read-only.

Type:
float