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.

  • List of the event types that are supported by MediaPlaybackTrait.

    Declaration

    Swift

    static let supportedEventTypes: [any Event.Type]
  • List of the commands that are supported by MediaPlaybackTrait.

    Declaration

    Swift

    static let supportedCommandTypes: [any Command.Type]
  • The trait identifier.

    Declaration

    Swift

    static let identifier: String
  • Metadata about this Trait.

    Declaration

    Swift

    let metadata: TraitMetadata
  • List of attributes for the MediaPlaybackTrait.

    Declaration

    Swift

    let attributes: Matter.MediaPlaybackTrait.Attributes
  • 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.

  • 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
  • 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
  • Attributes for the MediaPlaybackTrait.

    Declaration

    Swift

    struct Attributes
  • 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.

  • 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)
  • A playback position within a media stream.

    Declaration

    Swift

    struct PlaybackPositionStruct
  • Whether the device supports the play command for this trait.

    Declaration

    Swift

    var supportsPlayCommand: Bool { get }
  • 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>
  • Whether the device supports the pause command for this trait.

    Declaration

    Swift

    var supportsPauseCommand: Bool { get }
  • 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>
  • Whether the device supports the stop command for this trait.

    Declaration

    Swift

    var supportsStopCommand: Bool { get }
  • 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>
  • Whether the device supports the startOver command for this trait.

    Declaration

    Swift

    var supportsStartOverCommand: Bool { get }
  • 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>
  • Whether the device supports the previous command for this trait.

    Declaration

    Swift

    var supportsPreviousCommand: Bool { get }
  • 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>
  • Whether the device supports the next command for this trait.

    Declaration

    Swift

    var supportsNextCommand: Bool { get }
  • 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>
  • Whether the device supports the rewind command for this trait.

    Declaration

    Swift

    var supportsRewindCommand: Bool { get }
  • 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>
  • Whether the device supports the fastForward command for this trait.

    Declaration

    Swift

    var supportsFastForwardCommand: Bool { get }
  • 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>
  • Whether the device supports the skipForward command for this trait.

    Declaration

    Swift

    var supportsSkipForwardCommand: Bool { get }
  • 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>
  • Whether the device supports the skipBackward command for this trait.

    Declaration

    Swift

    var supportsSkipBackwardCommand: Bool { get }
  • 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>
  • Whether the device supports the seek command for this trait.

    Declaration

    Swift

    var supportsSeekCommand: Bool { get }
  • 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>
  • Whether the device supports the activateAudioTrack command for this trait.

    Declaration

    Swift

    var supportsActivateAudioTrackCommand: Bool { get }
  • The batchable version of activateAudioTrack command above.

    See also

    activateAudioTrack

    Declaration

    Swift

    func activateAudioTrackBatchable(trackID: String, audioOutputIndex: UInt8) throws -> BatchableCommand<Void>
  • Whether the device supports the activateTextTrack command for this trait.

    Declaration

    Swift

    var supportsActivateTextTrackCommand: Bool { get }
  • The batchable version of activateTextTrack command above.

    See also

    activateTextTrack

    Declaration

    Swift

    func activateTextTrackBatchable(trackID: String) throws -> BatchableCommand<Void>
  • Whether the device supports the deactivateTextTrack command for this trait.

    Declaration

    Swift

    var supportsDeactivateTextTrackCommand: Bool { get }
  • The batchable version of deactivateTextTrack command above.

    See also

    deactivateTextTrack

    Declaration

    Swift

    func deactivateTextTrackBatchable() throws -> BatchableCommand<Void>
  • Playback states.

    Declaration

    Swift

    enum PlaybackStateEnum
  • Playback statuses.

    Declaration

    Swift

    enum StatusEnum
  • The MediaPlayback cluster FeatureMap.

    Declaration

    Swift

    struct Feature