class Gtk::MediaStream
- Gtk::MediaStream
- GObject::Object
- Reference
- Object
Overview
Gtk::MediaStream
is the integration point for media playback inside GTK.
GTK provides an implementation of the Gtk::MediaStream
interface that
is called Gtk::MediaFile
.
Apart from application-facing API for stream playback, Gtk::MediaStream
has a number of APIs that are only useful for implementations and should
not be used in applications:
Gtk::MediaStream#prepared
,
Gtk::MediaStream#unprepared
,
Gtk::MediaStream#update
,
Gtk::MediaStream#ended
,
Gtk::MediaStream#seek_success
,
Gtk::MediaStream#seek_failed
,
Gtk::MediaStream#gerror
,
Gtk::MediaStream#error
,
Gtk::MediaStream#error_valist
.
Included Modules
Direct Known Subclasses
Defined in:
lib/gi-crystal/src/auto/gtk-4.0/media_stream.crConstructors
-
.new
Initialize a new
MediaStream
. - .new(*, duration : Int64 | Nil = nil, ended : Bool | Nil = nil, error : GLib::Error | Nil = nil, has_audio : Bool | Nil = nil, has_video : Bool | Nil = nil, loop : Bool | Nil = nil, muted : Bool | Nil = nil, playing : Bool | Nil = nil, prepared : Bool | Nil = nil, seekable : Bool | Nil = nil, seeking : Bool | Nil = nil, timestamp : Int64 | Nil = nil, volume : Float64 | Nil = nil)
Class Method Summary
-
.g_type : UInt64
Returns the type id (GType) registered in GLib type system.
Instance Method Summary
-
#==(other : self)
Returns
true
if this reference is the same as other. -
#duration : Int64
Gets the duration of the stream.
-
#ended : Bool
Returns whether the streams playback is finished.
- #ended? : Bool
-
#error : GLib::Error | Nil
If the stream is in an error state, returns the
GError
explaining that state. -
#gerror(error : GLib::Error) : Nil
Sets self into an error state.
-
#has_audio : Bool
Returns whether the stream has audio.
- #has_audio? : Bool
-
#has_video : Bool
Returns whether the stream has video.
- #has_video? : Bool
-
#hash(hasher)
See
Object#hash(hasher)
-
#is_prepared : Bool
Returns whether the stream has finished initializing.
-
#is_seekable : Bool
Checks if a stream may be seekable.
-
#is_seeking : Bool
Checks if there is currently a seek operation going on.
-
#loop : Bool
Returns whether the stream is set to loop.
-
#loop=(loop : Bool) : Nil
Sets whether the stream should loop.
- #loop? : Bool
-
#muted : Bool
Returns whether the audio for the stream is muted.
-
#muted=(muted : Bool) : Nil
Sets whether the audio stream should be muted.
- #muted? : Bool
-
#pause : Nil
Pauses playback of the stream.
-
#play : Nil
Starts playing the stream.
-
#playing : Bool
Return whether the stream is currently playing.
-
#playing=(playing : Bool) : Nil
Starts or pauses playback of the stream.
- #playing? : Bool
- #prepared=(value : Bool) : Bool
- #prepared? : Bool
-
#realize(surface : Gdk::Surface) : Nil
Called by users to attach the media stream to a
Gdk::Surface
they manage. -
#seek(timestamp : Int64) : Nil
Start a seek operation on self to timestamp.
-
#seek_failed : Nil
Ends a seek operation started via Gtk::MediaStream.seek() as a failure.
-
#seek_success : Nil
Ends a seek operation started via Gtk::MediaStream.seek() successfully.
- #seekable? : Bool
- #seeking? : Bool
-
#stream_ended : Nil
Pauses the media stream and marks it as ended.
-
#stream_prepared(has_audio : Bool, has_video : Bool, seekable : Bool, duration : Int64) : Nil
Called by
Gtk::MediaStream
implementations to advertise the stream being ready to play and providing details about the stream. -
#stream_unprepared : Nil
Resets a given media stream implementation.
-
#timestamp : Int64
Returns the current presentation timestamp in microseconds.
-
#unrealize(surface : Gdk::Surface) : Nil
Undoes a previous call to gtk_media_stream_realize().
-
#update(timestamp : Int64) : Nil
Media stream implementations should regularly call this function to update the timestamp reported by the stream.
-
#volume : Float64
Returns the volume of the audio for the stream.
-
#volume=(volume : Float64) : Nil
Sets the volume of the audio stream.
Instance methods inherited from module Gdk::Paintable
compute_concrete_size(specified_width : Float64, specified_height : Float64, default_width : Float64, default_height : Float64, concrete_width : Float64, concrete_height : Float64) : Nil
compute_concrete_size,
current_image : Gdk::Paintable
current_image,
flags : Gdk::PaintableFlags
flags,
intrinsic_aspect_ratio : Float64
intrinsic_aspect_ratio,
intrinsic_height : Int32
intrinsic_height,
intrinsic_width : Int32
intrinsic_width,
invalidate_contents : Nil
invalidate_contents,
invalidate_contents_signal
invalidate_contents_signal,
invalidate_size : Nil
invalidate_size,
invalidate_size_signal
invalidate_size_signal,
snapshot(snapshot : Gdk::Snapshot, width : Float64, height : Float64) : Nil
snapshot,
to_unsafe
to_unsafe
Constructor methods inherited from module Gdk::Paintable
cast(obj : GObject::Object) : self
cast
Class methods inherited from module Gdk::Paintable
cast?(obj : GObject::Object) : self | Nil
cast?,
g_type : UInt64
g_type,
new_empty(intrinsic_width : Int32, intrinsic_height : Int32) : Gdk::Paintable
new_empty
Instance methods inherited from class GObject::Object
==(other : self)
==,
bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding
bind_property,
bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding
bind_property_full,
data(key : String) : Pointer(Void) | Nil
data,
finalize
finalize,
freeze_notify : Nil
freeze_notify,
getv(names : Enumerable(String), values : Enumerable(_)) : Nil
getv,
hash(hasher)
hash,
notify(property_name : String) : Nil
notify,
notify_by_pspec(pspec : GObject::ParamSpec) : Nil
notify_by_pspec,
notify_signal
notify_signal,
property(property_name : String, value : _) : Nil
property,
qdata(quark : UInt32) : Pointer(Void) | Nil
qdata,
ref_count : UInt32
ref_count,
run_dispose : Nil
run_dispose,
set_data(key : String, data : Pointer(Void) | Nil) : Nil
set_data,
set_property(property_name : String, value : _) : Nil
set_property,
steal_data(key : String) : Pointer(Void) | Nil
steal_data,
steal_qdata(quark : UInt32) : Pointer(Void) | Nil
steal_qdata,
thaw_notify : Nil
thaw_notify,
to_unsafe : Pointer(Void)
to_unsafe,
watch_closure(closure : GObject::Closure) : Nil
watch_closure
Constructor methods inherited from class GObject::Object
cast(obj : GObject::Object) : self
cast,
new(pointer : Pointer(Void), transfer : GICrystal::Transfer)new new, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv
Class methods inherited from class GObject::Object
cast?(obj : GObject::Object) : self | Nil
cast?,
compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64
compat_control,
g_type : UInt64
g_type,
interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec
interface_find_property,
interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec)
interface_list_properties
Macros inherited from class GObject::Object
previous_vfunc(*args)
previous_vfunc,
previous_vfunc!(*args)
previous_vfunc!,
signal(signature)
signal
Constructor Detail
Class Method Detail
Returns the type id (GType) registered in GLib type system.
Instance Method Detail
Returns true
if this reference is the same as other. Invokes same?
.
Gets the duration of the stream.
If the duration is not known, 0 will be returned.
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 Gtk::MediaStream#play
or
Gtk::MediaStream#seek
will not have any effect.
Gtk::MediaStream
itself does not provide a way to unset
an error, but implementations may provide options. For example,
a Gtk::MediaFile
will unset errors when a new source is
set, e.g. with Gtk::MediaFile#file=
.
Sets self into an error state.
This will pause the stream (you can check for an error
via Gtk::MediaStream#error
in your
Gtk::MediaStream.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
.
Returns whether the stream has finished initializing.
At this point the existence of audio and video is known.
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 Gtk::MediaStream#seek
on a non-seekable
stream, though it will not do anything.
Returns whether the stream is set to loop.
See Gtk::MediaStream#loop=
for details.
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.
Returns whether the audio for the stream is muted.
See Gtk::MediaStream#muted=
for details.
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.
Starts playing the stream.
If the stream is in error or already playing, do nothing.
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
Gtk::MediaStream#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
Gtk::MediaStream#unrealize
.
It is not required to call this function to make a media stream work.
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 Gtk::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.
Ends a seek operation started via Gtk::MediaStream.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 Gtk::MediaStream#seek_success
for the other way of
ending a seek.
Ends a seek operation started via Gtk::MediaStream.seek() successfully.
This function will unset the Gtk::MediaStream:ended property if it was set.
See Gtk::MediaStream#seek_failed
for the other way of
ending a seek.
Pauses the media stream and marks it as ended.
This is a hint only, calls to Gtk::MediaStream#play
may still happen.
The media stream must be prepared when this function is called.
Called by Gtk::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 Gtk::MediaStream#stream_unprepared
.
Resets a given media stream implementation.
Gtk::MediaStream#stream_prepared
can then be called again.
This function will also reset any error state the stream was in.
Undoes a previous call to gtk_media_stream_realize().
This causes the stream to release all resources it had allocated from surface.
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.
Returns the volume of the audio for the stream.
See Gtk::MediaStream#volume=
for details.
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.