MediaPlaybackTrait

struct MediaPlaybackTrait

This trait provides an interface for controlling media playback (play, pause, and so forth) on a media device such as a TV, set-top box, or smart speaker.

  • Returns a Boolean value indicating whether two values are equal.

    Equality is the inverse of inequality. For any values a and b, a == b implies that a != b is false.

    Declaration

    Swift

    static func == (lhs: Matter.MediaPlaybackTrait, rhs: Matter.MediaPlaybackTrait) -> Bool

    Parameters

    lhs

    A value to compare.

    rhs

    Another value to compare.

  • Attributes for the MediaPlaybackTrait.

    Declaration

    Swift

    struct Attributes
  • The MediaPlayback cluster FeatureMap.

    Declaration

    Swift

    struct Feature
  • A playback position within a media stream.

    Declaration

    Swift

    struct PlaybackPositionStruct
  • Playback states.

    Declaration

    Swift

    enum PlaybackStateEnum
  • Playback statuses.

    Declaration

    Swift

    enum StatusEnum
  • The batchable version of activateAudioTrack command above.

    See also

    activateAudioTrack

    Declaration

    Swift

    func activateAudioTrackBatchable(trackID: String, audioOutputIndex: UInt8) throws -> BatchableCommand<Void>
  • The batchable version of activateTextTrack command above.

    See also

    activateTextTrack

    Declaration

    Swift

    func activateTextTrackBatchable(trackID: String) throws -> BatchableCommand<Void>
  • List of attributes for the MediaPlaybackTrait.

    Declaration

    Swift

    let attributes: Matter.MediaPlaybackTrait.Attributes
  • The batchable version of deactivateTextTrack command above.

    See also

    deactivateTextTrack

    Declaration

    Swift

    func deactivateTextTrackBatchable() throws -> BatchableCommand<Void>
  • Writes this object to the given TraitEncoder. Throws HomeError.encodingFailed if the data could not be encoded.

    Declaration

    Swift

    func encode(with encoder: TraitEncoder) throws
  • Fast forward the current media.

    Declaration

    Swift

    func fastForward(optionalArgsProvider: ((Matter.MediaPlaybackTrait.FastForwardCommand.OptionalArgs) -> Void)? = nil) async throws -> Matter.MediaPlaybackTrait.FastForwardCommandResponse

    Return Value

    The outcome of the FastForward command.

  • The batchable version of fastForward command above.

    See also

    fastForward

    Declaration

    Swift

    func fastForwardBatchable(optionalArgsProvider: ((Matter.MediaPlaybackTrait.FastForwardCommand.OptionalArgs) -> Void)? = nil) throws -> BatchableCommand<Matter.MediaPlaybackTrait.FastForwardCommandResponse>
  • This API provides the ability to invalidate state retrieved through subscriptions to the target device in the cases where state is not being reported correctly, either intentionally (e.g attributes in Matter traits with the “C” quality) or unintentionally due to poor implementations.

    When successful, this API will result in a forced read of the convening scope as specified by the sub-class and return the result through existing Trait subscriptions if present and active.

    This API is to be used sparingly as it can impact the performance and battery life of the target device. As such, this API may be throttled by the platform. Callers SHALL be prepared to deal with HomeErrors thrown by this call.

    Declaration

    Swift

    func forceRead() async throws
  • Hashes the essential components of this value by feeding them into the given hasher.

    Implement this method to conform to the Hashable protocol. The components used for hashing must be the same as the components compared in your type’s == operator implementation. Call hasher.combine(_:) with each of these components.

    Important

    In your implementation of hash(into:), don’t call finalize() on the hasher instance provided, or replace it with a different instance. Doing so may become a compile-time error in the future.

    Declaration

    Swift

    func hash(into hasher: inout Hasher)
  • The trait identifier.

    Declaration

    Swift

    static let identifier: String
  • Creates a new Trait instance using data read from the given TraitDecoder.

    Throws

    HomeError.parseError when parsing fails.

    Declaration

    Swift

    init(decoder: TraitDecoder, interactionProxy: (any InteractionProxy)?, metadata: TraitMetadata) throws

    Parameters

    decoder

    The raw data representing this Trait.

    interactionProxy

    Proxy to the Interaction Client.

    metadata

    Metadata about this Trait.

  • Metadata about this Trait.

    Declaration

    Swift

    let metadata: TraitMetadata
  • Move to the next item in the media.

    Declaration

    Swift

    func next() async throws -> Matter.MediaPlaybackTrait.NextCommandResponse

    Return Value

    The outcome of the Next command.

  • The batchable version of next command above.

    See also

    next

    Declaration

    Swift

    func nextBatchable() throws -> BatchableCommand<Matter.MediaPlaybackTrait.NextCommandResponse>
  • Pause the current media.

    Declaration

    Swift

    func pause() async throws -> Matter.MediaPlaybackTrait.PauseCommandResponse

    Return Value

    The outcome of the Pause command.

  • The batchable version of pause command above.

    See also

    pause

    Declaration

    Swift

    func pauseBatchable() throws -> BatchableCommand<Matter.MediaPlaybackTrait.PauseCommandResponse>
  • Play the current media.

    Declaration

    Swift

    func play() async throws -> Matter.MediaPlaybackTrait.PlayCommandResponse

    Return Value

    The outcome of the Play command.

  • The batchable version of play command above.

    See also

    play

    Declaration

    Swift

    func playBatchable() throws -> BatchableCommand<Matter.MediaPlaybackTrait.PlayCommandResponse>
  • Move to the previous item in the current media.

    Declaration

    Swift

    func previous() async throws -> Matter.MediaPlaybackTrait.PreviousCommandResponse

    Return Value

    The outcome of the Previous command.

  • The batchable version of previous command above.

    See also

    previous

    Declaration

    Swift

    func previousBatchable() throws -> BatchableCommand<Matter.MediaPlaybackTrait.PreviousCommandResponse>
  • Rewind the current media.

    Declaration

    Swift

    func rewind(optionalArgsProvider: ((Matter.MediaPlaybackTrait.RewindCommand.OptionalArgs) -> Void)? = nil) async throws -> Matter.MediaPlaybackTrait.RewindCommandResponse

    Return Value

    The outcome of the Rewind command.

  • The batchable version of rewind command above.

    See also

    rewind

    Declaration

    Swift

    func rewindBatchable(optionalArgsProvider: ((Matter.MediaPlaybackTrait.RewindCommand.OptionalArgs) -> Void)? = nil) throws -> BatchableCommand<Matter.MediaPlaybackTrait.RewindCommandResponse>
  • Change the playback position in the current media to the specified position.

    Declaration

    Swift

    func seek(position: UInt64) async throws -> Matter.MediaPlaybackTrait.SeekCommandResponse

    Parameters

    position

    The position to seek to, relative to the start of the media, in milliseconds.

    Return Value

    The outcome of the Seek command.

  • The batchable version of seek command above.

    See also

    seek

    Declaration

    Swift

    func seekBatchable(position: UInt64) throws -> BatchableCommand<Matter.MediaPlaybackTrait.SeekCommandResponse>
  • Skip backward by a specified amount of time within the current media.

    Declaration

    Swift

    func skipBackward(deltaPositionMilliseconds: UInt64) async throws -> Matter.MediaPlaybackTrait.SkipBackwardCommandResponse

    Parameters

    deltaPositionMilliseconds

    The duration of the time span to skip backward in the media, in milliseconds.

    Return Value

    The outcome of the SkipBackward command.

  • The batchable version of skipBackward command above.

    See also

    skipBackward

    Declaration

    Swift

    func skipBackwardBatchable(deltaPositionMilliseconds: UInt64) throws -> BatchableCommand<Matter.MediaPlaybackTrait.SkipBackwardCommandResponse>
  • Skip forward by a specified amount of time within the current media.

    Declaration

    Swift

    func skipForward(deltaPositionMilliseconds: UInt64) async throws -> Matter.MediaPlaybackTrait.SkipForwardCommandResponse

    Parameters

    deltaPositionMilliseconds

    The duration of the time span to skip forward in the media, in milliseconds.

    Return Value

    The outcome of the SkipForward command.

  • The batchable version of skipForward command above.

    See also

    skipForward

    Declaration

    Swift

    func skipForwardBatchable(deltaPositionMilliseconds: UInt64) throws -> BatchableCommand<Matter.MediaPlaybackTrait.SkipForwardCommandResponse>
  • Start over from the beginning of the current media.

    Declaration

    Swift

    func startOver() async throws -> Matter.MediaPlaybackTrait.StartOverCommandResponse

    Return Value

    The outcome of the StartOver command.

  • The batchable version of startOver command above.

    See also

    startOver

    Declaration

    Swift

    func startOverBatchable() throws -> BatchableCommand<Matter.MediaPlaybackTrait.StartOverCommandResponse>
  • Stop playing the current media.

    Declaration

    Swift

    func stop() async throws -> Matter.MediaPlaybackTrait.StopCommandResponse

    Return Value

    The outcome of the Stop command.

  • The batchable version of stop command above.

    See also

    stop

    Declaration

    Swift

    func stopBatchable() throws -> BatchableCommand<Matter.MediaPlaybackTrait.StopCommandResponse>
  • List of the commands that are supported by MediaPlaybackTrait.

    Declaration

    Swift

    static let supportedCommandTypes: [any Command.Type]
  • List of the event types that are supported by MediaPlaybackTrait.

    Declaration

    Swift

    static let supportedEventTypes: [any Event.Type]
  • Whether the device supports the activateAudioTrack command for this trait.

    Declaration

    Swift

    var supportsActivateAudioTrackCommand: Bool { get }
  • Whether the device supports the activateTextTrack command for this trait.

    Declaration

    Swift

    var supportsActivateTextTrackCommand: Bool { get }
  • Whether the device supports the deactivateTextTrack command for this trait.

    Declaration

    Swift

    var supportsDeactivateTextTrackCommand: Bool { get }
  • Whether the device supports the fastForward command for this trait.

    Declaration

    Swift

    var supportsFastForwardCommand: Bool { get }
  • Whether the device supports the next command for this trait.

    Declaration

    Swift

    var supportsNextCommand: Bool { get }
  • Whether the device supports the pause command for this trait.

    Declaration

    Swift

    var supportsPauseCommand: Bool { get }
  • Whether the device supports the play command for this trait.

    Declaration

    Swift

    var supportsPlayCommand: Bool { get }
  • Whether the device supports the previous command for this trait.

    Declaration

    Swift

    var supportsPreviousCommand: Bool { get }
  • Whether the device supports the rewind command for this trait.

    Declaration

    Swift

    var supportsRewindCommand: Bool { get }
  • Whether the device supports the seek command for this trait.

    Declaration

    Swift

    var supportsSeekCommand: Bool { get }
  • Whether the device supports the skipBackward command for this trait.

    Declaration

    Swift

    var supportsSkipBackwardCommand: Bool { get }
  • Whether the device supports the skipForward command for this trait.

    Declaration

    Swift

    var supportsSkipForwardCommand: Bool { get }
  • Whether the device supports the startOver command for this trait.

    Declaration

    Swift

    var supportsStartOverCommand: Bool { get }
  • Whether the device supports the stop command for this trait.

    Declaration

    Swift

    var supportsStopCommand: Bool { get }