struct MediaPlaybackTraitThis 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.parseErrorwhen parsing fails.Declaration
Swift
init(decoder: TraitDecoder, interactionProxy: (any InteractionProxy)?, metadata: TraitMetadata) throwsParameters
decoderThe raw data representing this Trait.
interactionProxyProxy to the Interaction Client.
metadataMetadata about this Trait.
-
Writes this object to the given
TraitEncoder. ThrowsHomeError.encodingFailedif 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
aandb,a == bimplies thata != bisfalse.Declaration
Parameters
lhsA value to compare.
rhsAnother value to compare.
-
Hashes the essential components of this value by feeding them into the given hasher.
Implement this method to conform to the
Hashableprotocol. The components used for hashing must be the same as the components compared in your type’s==operator implementation. Callhasher.combine(_:)with each of these components.Important
In your implementation of
hash(into:), don’t callfinalize()on thehasherinstance 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
playcommand for this trait.Declaration
Swift
var supportsPlayCommand: Bool { get } -
Play the current media.
Declaration
Swift
func play() async throws -> Matter.MediaPlaybackTrait.PlayCommandResponseReturn Value
The outcome of the
Playcommand. -
The batchable version of play command above.
See also
playDeclaration
Swift
func playBatchable() throws -> BatchableCommand<Matter.MediaPlaybackTrait.PlayCommandResponse> -
Whether the device supports the
pausecommand for this trait.Declaration
Swift
var supportsPauseCommand: Bool { get } -
Pause the current media.
Declaration
Swift
func pause() async throws -> Matter.MediaPlaybackTrait.PauseCommandResponseReturn Value
The outcome of the
Pausecommand. -
The batchable version of pause command above.
See also
pauseDeclaration
Swift
func pauseBatchable() throws -> BatchableCommand<Matter.MediaPlaybackTrait.PauseCommandResponse> -
Whether the device supports the
stopcommand for this trait.Declaration
Swift
var supportsStopCommand: Bool { get } -
Stop playing the current media.
Declaration
Swift
func stop() async throws -> Matter.MediaPlaybackTrait.StopCommandResponseReturn Value
The outcome of the
Stopcommand. -
The batchable version of stop command above.
See also
stopDeclaration
Swift
func stopBatchable() throws -> BatchableCommand<Matter.MediaPlaybackTrait.StopCommandResponse> -
Whether the device supports the
startOvercommand 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.StartOverCommandResponseReturn Value
The outcome of the
StartOvercommand. -
The batchable version of startOver command above.
See also
startOverDeclaration
Swift
func startOverBatchable() throws -> BatchableCommand<Matter.MediaPlaybackTrait.StartOverCommandResponse> -
Whether the device supports the
previouscommand 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.PreviousCommandResponseReturn Value
The outcome of the
Previouscommand. -
The batchable version of previous command above.
See also
previousDeclaration
Swift
func previousBatchable() throws -> BatchableCommand<Matter.MediaPlaybackTrait.PreviousCommandResponse> -
Whether the device supports the
nextcommand 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.NextCommandResponseReturn Value
The outcome of the
Nextcommand. -
The batchable version of next command above.
See also
nextDeclaration
Swift
func nextBatchable() throws -> BatchableCommand<Matter.MediaPlaybackTrait.NextCommandResponse> -
Whether the device supports the
rewindcommand for this trait.Declaration
Swift
var supportsRewindCommand: Bool { get } -
Whether the device supports the
fastForwardcommand for this trait.Declaration
Swift
var supportsFastForwardCommand: Bool { get } -
Whether the device supports the
skipForwardcommand 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.SkipForwardCommandResponseParameters
deltaPositionMillisecondsThe duration of the time span to skip forward in the media, in milliseconds.
Return Value
The outcome of the
SkipForwardcommand. -
The batchable version of skipForward command above.
See also
skipForwardDeclaration
Swift
func skipForwardBatchable(deltaPositionMilliseconds: UInt64) throws -> BatchableCommand<Matter.MediaPlaybackTrait.SkipForwardCommandResponse> -
Whether the device supports the
skipBackwardcommand 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.SkipBackwardCommandResponseParameters
deltaPositionMillisecondsThe duration of the time span to skip backward in the media, in milliseconds.
Return Value
The outcome of the
SkipBackwardcommand. -
The batchable version of skipBackward command above.
See also
skipBackwardDeclaration
Swift
func skipBackwardBatchable(deltaPositionMilliseconds: UInt64) throws -> BatchableCommand<Matter.MediaPlaybackTrait.SkipBackwardCommandResponse> -
Whether the device supports the
seekcommand 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.SeekCommandResponseParameters
positionThe position to seek to, relative to the start of the media, in milliseconds.
Return Value
The outcome of the
Seekcommand. -
The batchable version of seek command above.
See also
seekDeclaration
Swift
func seekBatchable(position: UInt64) throws -> BatchableCommand<Matter.MediaPlaybackTrait.SeekCommandResponse> -
Whether the device supports the
activateAudioTrackcommand for this trait.Declaration
Swift
var supportsActivateAudioTrackCommand: Bool { get } -
The batchable version of activateAudioTrack command above.
See also
activateAudioTrackDeclaration
Swift
func activateAudioTrackBatchable(trackID: String, audioOutputIndex: UInt8) throws -> BatchableCommand<Void> -
Whether the device supports the
activateTextTrackcommand for this trait.Declaration
Swift
var supportsActivateTextTrackCommand: Bool { get } -
The batchable version of activateTextTrack command above.
See also
activateTextTrackDeclaration
Swift
func activateTextTrackBatchable(trackID: String) throws -> BatchableCommand<Void> -
Whether the device supports the
deactivateTextTrackcommand for this trait.Declaration
Swift
var supportsDeactivateTextTrackCommand: Bool { get } -
The batchable version of deactivateTextTrack command above.
See also
deactivateTextTrackDeclaration
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