pub trait MediaStreamExt: 'static {
Show 45 methods fn ended(&self); fn duration(&self) -> i64; fn is_ended(&self) -> bool; fn error(&self) -> Option<Error>; fn is_loop(&self) -> bool; fn is_muted(&self) -> bool; fn is_playing(&self) -> bool; fn timestamp(&self) -> i64; fn volume(&self) -> f64; fn has_audio(&self) -> bool; fn has_video(&self) -> bool; fn is_prepared(&self) -> bool; fn is_seekable(&self) -> bool; fn is_seeking(&self) -> bool; fn pause(&self); fn play(&self); fn prepared(
        &self,
        has_audio: bool,
        has_video: bool,
        seekable: bool,
        duration: i64
    ); fn realize(&self, surface: &impl IsA<Surface>); fn seek(&self, timestamp: i64); fn seek_failed(&self); fn seek_success(&self); fn set_loop(&self, loop_: bool); fn set_muted(&self, muted: bool); fn set_playing(&self, playing: bool); fn set_volume(&self, volume: f64); fn stream_ended(&self); fn stream_prepared(
        &self,
        has_audio: bool,
        has_video: bool,
        seekable: bool,
        duration: i64
    ); fn stream_unprepared(&self); fn unprepared(&self); fn unrealize(&self, surface: &impl IsA<Surface>); fn update(&self, timestamp: i64); fn set_prepared(&self, prepared: bool); fn connect_duration_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_ended_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_error_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_has_audio_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_has_video_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_loop_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_muted_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_playing_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_prepared_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_seekable_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_seeking_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_timestamp_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; fn connect_volume_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
}
Expand description

Trait containing all MediaStream methods.

Implementors

MediaFile, MediaStream

Required Methods§

Pauses the media stream and marks it as ended.

This is a hint only, calls to play() may still happen.

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

Deprecated since 4.4

Use stream_ended() instead

Gets the duration of the stream.

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

Returns

the duration of the stream or 0 if not known.

Returns whether the streams playback is finished.

Returns

true if playback is finished

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 play() or seek() will not have any effect.

MediaStream itself does not provide a way to unset an error, but implementations may provide options. For example, a MediaFile will unset errors when a new source is set, e.g. with MediaFileExt::set_file().

Returns

None if not in an error state or the GError of the stream

Returns whether the stream is set to loop.

See set_loop() for details.

Returns

true if the stream should loop

Returns whether the audio for the stream is muted.

See set_muted() for details.

Returns

true if the stream is muted

Return whether the stream is currently playing.

Returns

true if the stream is playing

Returns the current presentation timestamp in microseconds.

Returns

the timestamp in microseconds

Returns the volume of the audio for the stream.

See set_volume() for details.

Returns

volume of the stream from 0.0 to 1.0

Returns whether the stream has audio.

Returns

true if the stream has audio

Returns whether the stream has video.

Returns

true if the stream has video

Returns whether the stream has finished initializing.

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

Returns

true if the stream is prepared

Checks if a stream may be seekable.

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

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

Returns

true if the stream may support seeking

Checks if there is currently a seek operation going on.

Returns

true if a seek operation is ongoing.

Pauses playback of the stream.

If the stream is not playing, do nothing.

Starts playing the stream.

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

Same as gtk_media_stream_stream_prepared().

Deprecated since 4.4

Use stream_prepared() instead.

has_audio

true if the stream should advertise audio support

has_video

true if the stream should advertise video support

seekable

true if the stream should advertise seekability

duration

The duration of the stream or 0 if unknown

Called by users to attach the media stream to a gdk::Surface they manage.

The stream can then access the resources of @surface for its rendering purposes. In particular, media streams might want to create a gdk::GLContext or sync to the gdk::FrameClock.

Whoever calls this function is responsible for calling 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 unrealize().

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

surface

a gdk::Surface

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 property::MediaStream::seeking property will be set.

When calling gtk_media_stream_seek() during an ongoing seek operation, the new seek will override any pending seek.

timestamp

timestamp to seek to.

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 seek_success() for the other way of ending a seek.

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

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

See seek_failed() for the other way of ending a seek.

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.

loop_

true if the stream should loop

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.

muted

true if the stream should be muted

Starts or pauses playback of the stream.

playing

whether to start or pause playback

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.

volume

New volume of the stream from 0.0 to 1.0

Available on crate feature v4_4 only.

Pauses the media stream and marks it as ended.

This is a hint only, calls to play() may still happen.

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

Available on crate feature v4_4 only.

Called by MediaStream 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 true. 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 stream_unprepared().

has_audio

true if the stream should advertise audio support

has_video

true if the stream should advertise video support

seekable

true if the stream should advertise seekability

duration

The duration of the stream or 0 if unknown

Available on crate feature v4_4 only.

Resets a given media stream implementation.

stream_prepared() can then be called again.

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

Same as gtk_media_stream_stream_unprepared().

Deprecated since 4.4

Use stream_unprepared() instead.

Undoes a previous call to gtk_media_stream_realize().

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

surface

the gdk::Surface the stream was realized with

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.

timestamp

the new timestamp

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

Implementors§