Trait gtk4::prelude::MediaStreamExt
source · pub trait MediaStreamExt: 'static {
Show 45 methods
// Required 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
Required Methods§
sourcefn ended(&self)
fn ended(&self)
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
sourcefn duration(&self) -> i64
fn duration(&self) -> i64
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.
sourcefn error(&self) -> Option<Error>
fn error(&self) -> Option<Error>
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
sourcefn is_loop(&self) -> bool
fn is_loop(&self) -> bool
Returns whether the stream is set to loop.
See set_loop()
for details.
Returns
true
if the stream should loop
sourcefn is_muted(&self) -> bool
fn is_muted(&self) -> bool
Returns whether the audio for the stream is muted.
See set_muted()
for details.
Returns
true
if the stream is muted
sourcefn is_playing(&self) -> bool
fn is_playing(&self) -> bool
sourcefn volume(&self) -> f64
fn volume(&self) -> f64
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
sourcefn is_prepared(&self) -> bool
fn is_prepared(&self) -> bool
sourcefn is_seekable(&self) -> bool
fn is_seekable(&self) -> bool
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
sourcefn is_seeking(&self) -> bool
fn is_seeking(&self) -> bool
sourcefn play(&self)
fn play(&self)
Starts playing the stream.
If the stream is in error or already playing, do nothing.
sourcefn prepared(
&self,
has_audio: bool,
has_video: bool,
seekable: bool,
duration: i64
)
fn prepared( &self, has_audio: bool, has_video: bool, seekable: bool, duration: i64 )
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
sourcefn realize(&self, surface: &impl IsA<Surface>)
fn realize(&self, surface: &impl IsA<Surface>)
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
sourcefn seek(&self, timestamp: i64)
fn seek(&self, timestamp: i64)
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 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.
sourcefn seek_failed(&self)
fn 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 seek_success()
for the other way of
ending a seek.
sourcefn seek_success(&self)
fn 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 seek_failed()
for the other way of
ending a seek.
sourcefn set_loop(&self, loop_: bool)
fn set_loop(&self, loop_: bool)
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
sourcefn set_muted(&self, muted: bool)
fn set_muted(&self, muted: bool)
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
sourcefn set_playing(&self, playing: bool)
fn set_playing(&self, playing: bool)
sourcefn set_volume(&self, volume: f64)
fn set_volume(&self, volume: f64)
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
sourcefn stream_ended(&self)
fn stream_ended(&self)
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.
sourcefn stream_prepared(
&self,
has_audio: bool,
has_video: bool,
seekable: bool,
duration: i64
)
fn stream_prepared( &self, has_audio: bool, has_video: bool, seekable: bool, duration: i64 )
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
sourcefn stream_unprepared(&self)
fn stream_unprepared(&self)
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.
sourcefn unprepared(&self)
fn unprepared(&self)
sourcefn unrealize(&self, surface: &impl IsA<Surface>)
fn unrealize(&self, surface: &impl IsA<Surface>)
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
sourcefn update(&self, timestamp: i64)
fn update(&self, timestamp: i64)
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
sourcefn set_prepared(&self, prepared: bool)
fn set_prepared(&self, prepared: bool)
Whether the stream has finished initializing and existence of audio and video is known.