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.

  • ptr

    Untyped pointer to the underlying GtkMediaStream instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • media_stream_ptr Default implementation

    Typed 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)

MediaStream Class

  • 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 transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return 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:value:) Extension method

    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

MediaStream Class: MediaStreamProtocol extension (methods and fields)

  • getEnded() Extension method

    Pauses the media stream and marks it as ended.

    This is a hint only, calls to [methodGtk.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()
  • Sets self into an error state using a printf()-style format string.

    This is a utility function that calls [methodGtk.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 [methodGtk.MediaStream.get_error] in your GtkMediaStream.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 [methodGtk.MediaStream.unprepared].

    Declaration

    Swift

    @inlinable
    func gerror<GLibErrorT>(error: GLibErrorT) where GLibErrorT : ErrorProtocol
  • getDuration() Extension method

    Gets the duration of the stream.

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

    Declaration

    Swift

    @inlinable
    func getDuration() -> gint64
  • getEnded() Extension method

    Returns whether the streams playback is finished.

    Declaration

    Swift

    @inlinable
    func getEnded() -> Bool
  • getError() Extension method

    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 [methodGtk.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 method

    Returns whether the stream is set to loop.

    See [methodGtk.MediaStream.set_loop] for details.

    Declaration

    Swift

    @inlinable
    func getLoop() -> Bool
  • getMuted() Extension method

    Returns whether the audio for the stream is muted.

    See [methodGtk.MediaStream.set_muted] for details.

    Declaration

    Swift

    @inlinable
    func getMuted() -> Bool
  • getPlaying() Extension method

    Return whether the stream is currently playing.

    Declaration

    Swift

    @inlinable
    func getPlaying() -> Bool
  • getTimestamp() Extension method

    Returns the current presentation timestamp in microseconds.

    Declaration

    Swift

    @inlinable
    func getTimestamp() -> gint64
  • getVolume() Extension method

    Returns the volume of the audio for the stream.

    See [methodGtk.MediaStream.set_volume] for details.

    Declaration

    Swift

    @inlinable
    func getVolume() -> CDouble
  • hasAudio() Extension method

    Returns whether the stream has audio.

    Declaration

    Swift

    @inlinable
    func hasAudio() -> Bool
  • hasVideo() Extension method

    Returns whether the stream has video.

    Declaration

    Swift

    @inlinable
    func hasVideo() -> Bool
  • pause() Extension method

    Pauses playback of the stream.

    If the stream is not playing, do nothing.

    Declaration

    Swift

    @inlinable
    func pause()
  • play() Extension method

    Starts playing the stream.

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

    Declaration

    Swift

    @inlinable
    func play()
  • 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 a GdkGLContext or sync to the GdkFrameClock.

    Whoever calls this function is responsible for calling [methodGtk.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 [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 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 [propertyGtk.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 method

    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 [methodGtk.MediaStream.seek_success] for the other way of ending a seek.

    Declaration

    Swift

    @inlinable
    func seekFailed()
  • seekSuccess() Extension method

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

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

    See [methodGtk.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 method

    Pauses the media stream and marks it as ended.

    This is a hint only, calls to [methodGtk.MediaStream.play] may still happen.

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

    Declaration

    Swift

    @inlinable
    func streamEnded()
  • 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 [methodGtk.MediaStream.stream_unprepared].

    Declaration

    Swift

    @inlinable
    func streamPrepared(hasAudio: Bool, hasVideo: Bool, seekable: Bool, duration: gint64)
  • streamUnprepared() Extension method

    Resets a given media stream implementation.

    [methodGtk.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 method

    Same 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 method

    The stream’s duration in microseconds or 0 if unknown.

    Declaration

    Swift

    @inlinable
    var duration: gint64 { get }
  • ended Extension method

    Set when playback has finished.

    Declaration

    Swift

    @inlinable
    var ended: Bool { get }
  • error Extension method

    nil for a properly working stream or the GError that the stream is in.

    Declaration

    Swift

    @inlinable
    var error: GLib.ErrorRef! { get }
  • isPrepared Extension method

    Returns 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 method

    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 [methodGtk.MediaStream.seek] on a non-seekable stream, though it will not do anything.

    Declaration

    Swift

    @inlinable
    var isSeekable: Bool { get }
  • isSeeking Extension method

    Checks if there is currently a seek operation going on.

    Declaration

    Swift

    @inlinable
    var isSeeking: Bool { get }
  • loop Extension method

    Try to restart the media from the beginning once it ended.

    Declaration

    Swift

    @inlinable
    var loop: Bool { get nonmutating set }
  • muted Extension method

    Whether the audio stream should be muted.

    Declaration

    Swift

    @inlinable
    var muted: Bool { get nonmutating set }
  • playing Extension method

    Whether the stream is currently playing.

    Declaration

    Swift

    @inlinable
    var playing: Bool { get nonmutating set }
  • timestamp Extension method

    The current presentation timestamp in microseconds.

    Declaration

    Swift

    @inlinable
    var timestamp: gint64 { get }
  • volume Extension method

    Volume of the audio stream.

    Declaration

    Swift

    @inlinable
    var volume: CDouble { get nonmutating set }
  • parentInstance Extension method

    Undocumented

    Declaration

    Swift

    @inlinable
    var parentInstance: GObject { get }