1.120 <GtkMediaStream>

Class: <GtkMediaStream>

It derives from <GObject>.

The integration point for media playback inside GTK.

GTK provides an implementation of the <GtkMediaStream> interface that is called <GtkMediaFile>.

Apart from application-facing API for stream playback, <GtkMediaStream> has a number of APIs that are only useful for implementations and should not be used in applications: Gtk.MediaStream.prepared, Gtk.MediaStream.unprepared, media-stream:update, Gtk.MediaStream.ended, media-stream:seek-success, media-stream:seek-failed, media-stream:gerror, Gtk.MediaStream.error, Gtk.MediaStream.error_valist.

Fields

parent-instance

Properties

Property: media-stream:duration self

The stream’s duration in microseconds or 0 if unknown.

Its value is a 64-bit integer.

It is read only.

Property: media-stream:ended self

Set when playback has finished.

Its value is a boolean.

It is read only.

Property: media-stream:error self

#f for a properly working stream or the <GError> that the stream is in.

Its value is a <GError>, or #f.

It is read only.

Property: media-stream:has-audio self

Whether the stream contains audio.

Its value is a boolean.

It is read only.

Property: media-stream:has-video self

Whether the stream contains video.

Its value is a boolean.

It is read only.

Property: media-stream:loop self

Try to restart the media from the beginning once it ended.

Its value is a boolean.

Set it with (set! (media-stream:loop self) value).

Property: media-stream:muted self

Whether the audio stream should be muted.

Its value is a boolean.

Set it with (set! (media-stream:muted self) value).

Property: media-stream:playing self

Whether the stream is currently playing.

Its value is a boolean.

Set it with (set! (media-stream:playing self) value).

Property: media-stream:prepared self

Whether the stream has finished initializing and existence of audio and video is known.

Its value is a boolean.

It is read only.

Property: media-stream:seekable self

Set unless the stream is known to not support seeking.

Its value is a boolean.

It is read only.

Property: media-stream:seeking self

Set while a seek is in progress.

Its value is a boolean.

It is read only.

Property: media-stream:timestamp self

The current presentation timestamp in microseconds.

Its value is a 64-bit integer.

It is read only.

Property: media-stream:volume self

Volume of the audio stream.

Its value is a real number.

Set it with (set! (media-stream:volume self) value).

Procedures

Method: media-stream:gerror self error
Method: gerror self error

Sets self into an error state.

This will pause the stream (you can check for an error via media-stream:get-error in your GtkMediaStream.pause() implementation), abort pending seeks and mark the stream as prepared.

if the stream is already in an error state, this call will be ignored and the existing error will be retained.

To unset an error, the stream must be reset via a call to Gtk.MediaStream.unprepared.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

error

Passed: a <GError>.

the <GError> to set

Method: media-stream:get-duration self ⇒ %return
Method: get-duration self ⇒ %return

Gets the duration of the stream.

If the duration is not known, 0 will be returned.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

%return

Returned: a 64-bit integer.

the duration of the stream or 0 if not known.

Method: media-stream:get-ended? self ⇒ %return
Method: get-ended? self ⇒ %return

Returns whether the streams playback is finished.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

%return

Returned: a boolean.

#t if playback is finished

Method: media-stream:get-error self ⇒ %return
Method: get-error self ⇒ %return

If the stream is in an error state, returns the <GError> explaining that state.

Any type of error can be reported here depending on the implementation of the media stream.

A media stream in an error cannot be operated on, calls like media-stream:play or media-stream:seek will not have any effect.

<GtkMediaStream> itself does not provide a way to unset an error, but implementations may provide options. For example, a <GtkMediaFile> will unset errors when a new source is set, e.g. with media-file:set-file.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

%return

Returned: a <GError>, or #f.

#f if not in an error state or the <GError> of the stream

Method: media-stream:get-loop? self ⇒ %return
Method: get-loop? self ⇒ %return

Returns whether the stream is set to loop.

See media-stream:set-loop for details.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

%return

Returned: a boolean.

#t if the stream should loop

Method: media-stream:get-muted? self ⇒ %return
Method: get-muted? self ⇒ %return

Returns whether the audio for the stream is muted.

See media-stream:set-muted for details.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

%return

Returned: a boolean.

#t if the stream is muted

Method: media-stream:get-playing? self ⇒ %return
Method: get-playing? self ⇒ %return

Return whether the stream is currently playing.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

%return

Returned: a boolean.

#t if the stream is playing

Method: media-stream:get-timestamp self ⇒ %return
Method: get-timestamp self ⇒ %return

Returns the current presentation timestamp in microseconds.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

%return

Returned: a 64-bit integer.

the timestamp in microseconds

Method: media-stream:get-volume self ⇒ %return
Method: get-volume self ⇒ %return

Returns the volume of the audio for the stream.

See media-stream:set-volume for details.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

%return

Returned: a real number.

volume of the stream from 0.0 to 1.0

Method: media-stream:has-audio? self ⇒ %return
Method: has-audio? self ⇒ %return

Returns whether the stream has audio.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

%return

Returned: a boolean.

#t if the stream has audio

Method: media-stream:has-video? self ⇒ %return
Method: has-video? self ⇒ %return

Returns whether the stream has video.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

%return

Returned: a boolean.

#t if the stream has video

Method: media-stream:is-prepared? self ⇒ %return
Method: is-prepared? self ⇒ %return

Returns whether the stream has finished initializing.

At this point the existence of audio and video is known.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

%return

Returned: a boolean.

#t if the stream is prepared

Method: media-stream:is-seekable? self ⇒ %return
Method: is-seekable? self ⇒ %return

Checks if a stream may be seekable.

This is meant to be a hint. Streams may not allow seeking even if this function returns #t. However, if this function returns #f, streams are guaranteed to not be seekable and user interfaces may hide controls that allow seeking.

It is allowed to call media-stream:seek on a non-seekable stream, though it will not do anything.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

%return

Returned: a boolean.

#t if the stream may support seeking

Method: media-stream:is-seeking? self ⇒ %return
Method: is-seeking? self ⇒ %return

Checks if there is currently a seek operation going on.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

%return

Returned: a boolean.

#t if a seek operation is ongoing.

Method: media-stream:pause self
Method: pause self

Pauses playback of the stream.

If the stream is not playing, do nothing.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

Method: media-stream:play self
Method: play self

Starts playing the stream.

If the stream is in error or already playing, do nothing.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

Method: media-stream:realize self surface
Method: realize self surface

Called by users to attach the media stream to a <GdkSurface> they manage.

The stream can then access the resources of surface for its rendering purposes. In particular, media streams might want to create a <GdkGLContext> or sync to the <GdkFrameClock>.

Whoever calls this function is responsible for calling media-stream:unrealize before either the stream or surface get destroyed.

Multiple calls to this function may happen from different users of the video, even with the same surface. Each of these calls must be followed by its own call to media-stream:unrealize.

It is not required to call this function to make a media stream work.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

surface

Passed: a <GdkSurface>.

a <GdkSurface>

Method: media-stream:seek self timestamp
Method: seek self timestamp

Start a seek operation on self to timestamp.

If timestamp is out of range, it will be clamped.

Seek operations may not finish instantly. While a seek operation is in process, the media-stream:seeking property will be set.

When calling media-stream:seek during an ongoing seek operation, the new seek will override any pending seek.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

timestamp

Passed: a 64-bit integer.

timestamp to seek to.

Method: media-stream:seek-failed self
Method: seek-failed self

Ends a seek operation started via GtkMediaStream.seek() as a failure.

This will not cause an error on the stream and will assume that playback continues as if no seek had happened.

See media-stream:seek-success for the other way of ending a seek.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

Method: media-stream:seek-success self
Method: seek-success self

Ends a seek operation started via GtkMediaStream.seek() successfully.

This function will unset the GtkMediaStream:ended property if it was set.

See media-stream:seek-failed for the other way of ending a seek.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

Method: media-stream:set-loop self loop
Method: set-loop self loop

Sets whether the stream should loop.

In this case, it will attempt to restart playback from the beginning instead of stopping at the end.

Not all streams may support looping, in particular non-seekable streams. Those streams will ignore the loop setting and just end.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

loop

Passed: a boolean.

#t if the stream should loop

Method: media-stream:set-muted self muted
Method: set-muted self muted

Sets whether the audio stream should be muted.

Muting a stream will cause no audio to be played, but it does not modify the volume. This means that muting and then unmuting the stream will restore the volume settings.

If the stream has no audio, calling this function will still work but it will not have an audible effect.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

muted

Passed: a boolean.

#t if the stream should be muted

Method: media-stream:set-playing self playing
Method: set-playing self playing

Starts or pauses playback of the stream.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

playing

Passed: a boolean.

whether to start or pause playback

Method: media-stream:set-volume self volume
Method: set-volume self volume

Sets the volume of the audio stream.

This function call will work even if the stream is muted.

The given volume should range from 0.0 for silence to 1.0 for as loud as possible. Values outside of this range will be clamped to the nearest value.

If the stream has no audio or is muted, calling this function will still work but it will not have an immediate audible effect. When the stream is unmuted, the new volume setting will take effect.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

volume

Passed: a real number.

New volume of the stream from 0.0 to 1.0

Method: media-stream:stream-ended self
Method: stream-ended self

Pauses the media stream and marks it as ended.

This is a hint only, calls to media-stream:play may still happen.

The media stream must be prepared when this function is called.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

Method: media-stream:stream-prepared self has-audio has-video seekable duration
Method: stream-prepared self has-audio has-video seekable duration

Called by <GtkMediaStream> implementations to advertise the stream being ready to play and providing details about the stream.

Note that the arguments are hints. If the stream implementation cannot determine the correct values, it is better to err on the side of caution and return #t. User interfaces will use those values to determine what controls to show.

This function may not be called again until the stream has been reset via media-stream:stream-unprepared.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

has-audio

Passed: a boolean.

#t if the stream should advertise audio support

has-video

Passed: a boolean.

#t if the stream should advertise video support

seekable

Passed: a boolean.

#t if the stream should advertise seekability

duration

Passed: a 64-bit integer.

The duration of the stream or 0 if unknown

Method: media-stream:stream-unprepared self
Method: stream-unprepared self

Resets a given media stream implementation.

media-stream:stream-prepared can then be called again.

This function will also reset any error state the stream was in.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

Method: media-stream:unrealize self surface
Method: unrealize self surface

Undoes a previous call to media-stream:realize.

This causes the stream to release all resources it had allocated from surface.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream> previously realized

surface

Passed: a <GdkSurface>.

the <GdkSurface> the stream was realized with

Method: media-stream:update self timestamp
Method: update self timestamp

Media stream implementations should regularly call this function to update the timestamp reported by the stream.

It is up to implementations to call this at the frequency they deem appropriate.

The media stream must be prepared when this function is called.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

timestamp

Passed: a 64-bit integer.

the new timestamp

Virtual methods

Virtual method: media-stream:do-pause implementor self

Pauses playback of the stream.

If the stream is not playing, do nothing.

To override it in a new class, give register-type #:vfuncs `((pause . ,procedure)). The procedure is called as (procedure self).

implementor

Passed: the class whose implementation to call: <GtkMediaStream>, or a class that derives from it, or its GType number.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

Virtual method: media-stream:do-play implementor self ⇒ %return

To override it in a new class, give register-type #:vfuncs `((play . ,procedure)). The procedure is called as (procedure self) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GtkMediaStream>, or a class that derives from it, or its GType number.

self

Passed: a <GtkMediaStream>.

%return

Returned: a boolean.

Virtual method: media-stream:do-realize implementor self surface

Called by users to attach the media stream to a <GdkSurface> they manage.

The stream can then access the resources of surface for its rendering purposes. In particular, media streams might want to create a <GdkGLContext> or sync to the <GdkFrameClock>.

Whoever calls this function is responsible for calling media-stream:unrealize before either the stream or surface get destroyed.

Multiple calls to this function may happen from different users of the video, even with the same surface. Each of these calls must be followed by its own call to media-stream:unrealize.

It is not required to call this function to make a media stream work.

To override it in a new class, give register-type #:vfuncs `((realize . ,procedure)). The procedure is called as (procedure self surface).

implementor

Passed: the class whose implementation to call: <GtkMediaStream>, or a class that derives from it, or its GType number.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

surface

Passed: a <GdkSurface>.

a <GdkSurface>

Virtual method: media-stream:do-seek implementor self timestamp

Start a seek operation on self to timestamp.

If timestamp is out of range, it will be clamped.

Seek operations may not finish instantly. While a seek operation is in process, the media-stream:seeking property will be set.

When calling media-stream:seek during an ongoing seek operation, the new seek will override any pending seek.

To override it in a new class, give register-type #:vfuncs `((seek . ,procedure)). The procedure is called as (procedure self timestamp).

implementor

Passed: the class whose implementation to call: <GtkMediaStream>, or a class that derives from it, or its GType number.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream>

timestamp

Passed: a 64-bit integer.

timestamp to seek to.

Virtual method: media-stream:do-unrealize implementor self surface

Undoes a previous call to media-stream:realize.

This causes the stream to release all resources it had allocated from surface.

To override it in a new class, give register-type #:vfuncs `((unrealize . ,procedure)). The procedure is called as (procedure self surface).

implementor

Passed: the class whose implementation to call: <GtkMediaStream>, or a class that derives from it, or its GType number.

self

Passed: a <GtkMediaStream>.

a <GtkMediaStream> previously realized

surface

Passed: a <GdkSurface>.

the <GdkSurface> the stream was realized with

Virtual method: media-stream:do-update-audio implementor self muted volume

To override it in a new class, give register-type #:vfuncs `((update-audio . ,procedure)). The procedure is called as (procedure self muted volume).

implementor

Passed: the class whose implementation to call: <GtkMediaStream>, or a class that derives from it, or its GType number.

self

Passed: a <GtkMediaStream>.

muted

Passed: a boolean.

volume

Passed: a real number.