Trait gtk4::prelude::MediaStreamExt [−][src]
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<P: IsA<Surface>>(&self, surface: &P);
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<P: IsA<Surface>>(&self, surface: &P);
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
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.
Sets self
into an error state using a printf()
-style format string.
This is a utility function that calls MediaStreamExtManual::set_error()
.
See that function for details.
domain
error domain
code
error code
format
printf()
-style format for error message
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
fn is_playing(&self) -> bool
fn is_playing(&self) -> bool
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
fn is_prepared(&self) -> bool
fn is_prepared(&self) -> bool
fn 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
fn is_seeking(&self) -> bool
fn is_seeking(&self) -> bool
Starts playing the stream.
If the stream is in error or already playing, do nothing.
Same as 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
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 seek()
during an
ongoing seek operation, the new seek will override
any pending seek.
timestamp
timestamp to seek to.
fn 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.
fn 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.
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
fn set_playing(&self, playing: bool)
fn set_playing(&self, playing: bool)
fn 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
fn 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.
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
fn 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.
fn unprepared(&self)
fn unprepared(&self)
Undoes a previous call to 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
fn 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.