MediaStreamProtocol
public protocol MediaStreamProtocol : ObjectProtocol, PaintableProtocol
GtkMediaStream
is the integration point for media playback inside GTK.
GTK provides an implementation of the GtkMediaStream
interface that
is called [classGtk.MediaFile
].
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:
[methodGtk.MediaStream.prepared
],
[methodGtk.MediaStream.unprepared
],
[methodGtk.MediaStream.update
],
[methodGtk.MediaStream.ended
],
[methodGtk.MediaStream.seek_success
],
[methodGtk.MediaStream.seek_failed
],
[methodGtk.MediaStream.gerror
],
[methodGtk.MediaStream.error
],
[methodGtk.MediaStream.error_valist
].
The MediaStreamProtocol
protocol exposes the methods and properties of an underlying GtkMediaStream
instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see MediaStream
.
Alternatively, use MediaStreamRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkMediaStream
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
media_stream_ptr
Default implementationTyped pointer to the underlying
GtkMediaStream
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkMediaStream
instance.Declaration
Swift
var media_stream_ptr: UnsafeMutablePointer<GtkMediaStream>! { get }
-
Required Initialiser for types conforming to
MediaStreamProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
MediaStreamPropertyName
source property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: MediaStreamPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol
Parameters
source_property
the source property to bind
target
the target object to bind to
target_property
the target property to bind to
flags
the flags to pass to the
Binding
transform_from
ValueTransformer
to use for forward transformationtransform_to
ValueTransformer
to use for backwards transformationReturn Value
binding reference or
nil
in case of an error -
get(property:
Extension method) Get the value of a MediaStream property
Declaration
Swift
@inlinable func get(property: MediaStreamPropertyName) -> GLibObject.Value
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
set(property:
Extension methodvalue: ) Set the value of a MediaStream property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: MediaStreamPropertyName, value v: GLibObject.Value)
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
getEnded()
Extension methodPauses the media stream and marks it as ended.
This is a hint only, calls to [method
Gtk.MediaStream.play
] may still happen.The media stream must be prepared when this function is called.
ended is deprecated: Use [method@Gtk.MediaStream.stream_ended] instead
Declaration
Swift
@available(*, deprecated) @inlinable func getEnded()
-
errorValist(domain:
Extension methodcode: format: args: ) Sets
self
into an error state using aprintf()
-style format string.This is a utility function that calls [method
Gtk.MediaStream.gerror
]. See that function for details.Declaration
Swift
@inlinable func errorValist(domain: GQuark, code: Int, format: UnsafePointer<CChar>!, args: CVaListPointer)
-
gerror(error:
Extension method) Sets
self
into an error state.This will pause the stream (you can check for an error via [method
Gtk.MediaStream.get_error
] in yourGtkMediaStream.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 [method
Gtk.MediaStream.unprepared
].Declaration
Swift
@inlinable func gerror<GLibErrorT>(error: GLibErrorT) where GLibErrorT : ErrorProtocol
-
getDuration()
Extension methodGets the duration of the stream.
If the duration is not known, 0 will be returned.
Declaration
Swift
@inlinable func getDuration() -> gint64
-
getEnded()
Extension methodReturns whether the streams playback is finished.
Declaration
Swift
@inlinable func getEnded() -> Bool
-
getError()
Extension methodIf 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 [method
Gtk.MediaStream.play
] or [methodGtk.MediaStream.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 [classGtk.MediaFile
] will unset errors when a new source is set, e.g. with [methodGtk.MediaFile.set_file
].Declaration
Swift
@inlinable func getError() -> GLib.ErrorRef!
-
getLoop()
Extension methodReturns whether the stream is set to loop.
See [method
Gtk.MediaStream.set_loop
] for details.Declaration
Swift
@inlinable func getLoop() -> Bool
-
getMuted()
Extension methodReturns whether the audio for the stream is muted.
See [method
Gtk.MediaStream.set_muted
] for details.Declaration
Swift
@inlinable func getMuted() -> Bool
-
getPlaying()
Extension methodReturn whether the stream is currently playing.
Declaration
Swift
@inlinable func getPlaying() -> Bool
-
getTimestamp()
Extension methodReturns the current presentation timestamp in microseconds.
Declaration
Swift
@inlinable func getTimestamp() -> gint64
-
getVolume()
Extension methodReturns the volume of the audio for the stream.
See [method
Gtk.MediaStream.set_volume
] for details.Declaration
Swift
@inlinable func getVolume() -> CDouble
-
hasAudio()
Extension methodReturns whether the stream has audio.
Declaration
Swift
@inlinable func hasAudio() -> Bool
-
hasVideo()
Extension methodReturns whether the stream has video.
Declaration
Swift
@inlinable func hasVideo() -> Bool
-
pause()
Extension methodPauses playback of the stream.
If the stream is not playing, do nothing.
Declaration
Swift
@inlinable func pause()
-
play()
Extension methodStarts playing the stream.
If the stream is in error or already playing, do nothing.
Declaration
Swift
@inlinable func play()
-
prepared(hasAudio:
Extension methodhasVideo: seekable: duration: ) Same as
gtk_media_stream_stream_prepared()
.prepared is deprecated: Use [method@Gtk.MediaStream.stream_prepared] instead.
Declaration
Swift
@available(*, deprecated) @inlinable func prepared(hasAudio: Bool, hasVideo: Bool, seekable: Bool, duration: gint64)
-
realize(surface:
Extension method) 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 aGdkGLContext
or sync to theGdkFrameClock
.Whoever calls this function is responsible for calling [method
Gtk.MediaStream.unrealize
] before either the stream orsurface
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 [methodGtk.MediaStream.unrealize
].It is not required to call this function to make a media stream work.
Declaration
Swift
@inlinable func realize<SurfaceT>(surface: SurfaceT) where SurfaceT : SurfaceProtocol
-
seek(timestamp:
Extension method) Start a seek operation on
self
totimestamp
.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
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.Declaration
Swift
@inlinable func seek(timestamp: gint64)
-
seekFailed()
Extension methodEnds 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 [method
Gtk.MediaStream.seek_success
] for the other way of ending a seek.Declaration
Swift
@inlinable func seekFailed()
-
seekSuccess()
Extension methodEnds a seek operation started via
GtkMediaStream.seek()
successfully.This function will unset the GtkMediaStream:ended property if it was set.
See [method
Gtk.MediaStream.seek_failed
] for the other way of ending a seek.Declaration
Swift
@inlinable func seekSuccess()
-
set(loop:
Extension method) 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.
Declaration
Swift
@inlinable func set(loop: Bool)
-
set(muted:
Extension method) 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.
Declaration
Swift
@inlinable func set(muted: Bool)
-
set(playing:
Extension method) Starts or pauses playback of the stream.
Declaration
Swift
@inlinable func set(playing: Bool)
-
set(volume:
Extension method) 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.
Declaration
Swift
@inlinable func set(volume: CDouble)
-
streamEnded()
Extension methodPauses the media stream and marks it as ended.
This is a hint only, calls to [method
Gtk.MediaStream.play
] may still happen.The media stream must be prepared when this function is called.
Declaration
Swift
@inlinable func streamEnded()
-
streamPrepared(hasAudio:
Extension methodhasVideo: 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
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 [method
Gtk.MediaStream.stream_unprepared
].Declaration
Swift
@inlinable func streamPrepared(hasAudio: Bool, hasVideo: Bool, seekable: Bool, duration: gint64)
-
streamUnprepared()
Extension methodResets a given media stream implementation.
[method
Gtk.MediaStream.stream_prepared
] can then be called again.This function will also reset any error state the stream was in.
Declaration
Swift
@inlinable func streamUnprepared()
-
unprepared()
Extension methodSame as
gtk_media_stream_stream_unprepared()
.unprepared is deprecated: Use [method@Gtk.MediaStream.stream_unprepared] instead.
Declaration
Swift
@available(*, deprecated) @inlinable func unprepared()
-
unrealize(surface:
Extension method) Undoes a previous call to
gtk_media_stream_realize()
.This causes the stream to release all resources it had allocated from
surface
.Declaration
Swift
@inlinable func unrealize<SurfaceT>(surface: SurfaceT) where SurfaceT : SurfaceProtocol
-
update(timestamp:
Extension method) 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.
Declaration
Swift
@inlinable func update(timestamp: gint64)
-
duration
Extension methodThe stream’s duration in microseconds or 0 if unknown.
Declaration
Swift
@inlinable var duration: gint64 { get }
-
ended
Extension methodSet when playback has finished.
Declaration
Swift
@inlinable var ended: Bool { get }
-
error
Extension methodnil
for a properly working stream or theGError
that the stream is in.Declaration
Swift
@inlinable var error: GLib.ErrorRef! { get }
-
isPrepared
Extension methodReturns whether the stream has finished initializing.
At this point the existence of audio and video is known.
Declaration
Swift
@inlinable var isPrepared: Bool { get }
-
isSeekable
Extension methodChecks 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 returnsfalse
, streams are guaranteed to not be seekable and user interfaces may hide controls that allow seeking.It is allowed to call [method
Gtk.MediaStream.seek
] on a non-seekable stream, though it will not do anything.Declaration
Swift
@inlinable var isSeekable: Bool { get }
-
isSeeking
Extension methodChecks if there is currently a seek operation going on.
Declaration
Swift
@inlinable var isSeeking: Bool { get }
-
loop
Extension methodTry to restart the media from the beginning once it ended.
Declaration
Swift
@inlinable var loop: Bool { get nonmutating set }
-
muted
Extension methodWhether the audio stream should be muted.
Declaration
Swift
@inlinable var muted: Bool { get nonmutating set }
-
playing
Extension methodWhether the stream is currently playing.
Declaration
Swift
@inlinable var playing: Bool { get nonmutating set }
-
timestamp
Extension methodThe current presentation timestamp in microseconds.
Declaration
Swift
@inlinable var timestamp: gint64 { get }
-
volume
Extension methodVolume of the audio stream.
Declaration
Swift
@inlinable var volume: CDouble { get nonmutating set }
-
parentInstance
Extension methodUndocumented
Declaration
Swift
@inlinable var parentInstance: GObject { get }