AlexaClientSDK  1.18.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Classes | Public Types | Public Member Functions | List of all members
alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface Class Referenceabstract

#include <MediaPlayerObserverInterface.h>

Inheritance diagram for alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface:
Inheritance graph
[legend]

Classes

struct  TagKeyValueType
 

Public Types

enum  TagType {
  TagType::STRING, TagType::UINT, TagType::INT, TagType::DOUBLE,
  TagType::BOOLEAN
}
 The different types of metadata "stream tags". More...
 
using SourceId = MediaPlayerInterface::SourceId
 A type that identifies which source is currently being operated on. More...
 
typedef std::vector< TagKeyValueTypeVectorOfTags
 

Public Member Functions

virtual ~MediaPlayerObserverInterface ()=default
 
virtual void onFirstByteRead (SourceId id, const MediaPlayerState &state)=0
 
virtual void onPlaybackStarted (SourceId id, const MediaPlayerState &state)=0
 
virtual void onPlaybackFinished (SourceId id, const MediaPlayerState &state)=0
 
virtual void onPlaybackError (SourceId id, const ErrorType &type, std::string error, const MediaPlayerState &state)=0
 
virtual void onPlaybackPaused (SourceId id, const MediaPlayerState &state)
 
virtual void onPlaybackResumed (SourceId id, const MediaPlayerState &state)
 
virtual void onPlaybackStopped (SourceId id, const MediaPlayerState &state)
 
virtual void onBufferUnderrun (SourceId id, const MediaPlayerState &state)
 
virtual void onBufferRefilled (SourceId id, const MediaPlayerState &state)
 
virtual void onBufferingComplete (SourceId id, const MediaPlayerState &state)
 
virtual void onTags (SourceId id, std::unique_ptr< const VectorOfTags > vectorOfTags, const MediaPlayerState &state)
 

Detailed Description

A player observer will receive notifications when the player starts playing or when it stops playing a stream. A pointer to the MediaPlayerObserverInterface needs to be provided to a MediaPlayer for it to notify the observer.

Warning
An observer should never call a method from the observed media player while handling a callback. This may cause a deadlock while trying to re-acquire a mutex.
Be aware that there is a high risk of deadlock if the observer calls media player functions while holding an exclusive lock. The deadlock may happen because the call to media player functions may end up calling the same observer which will try to acquire the same lock that it already has. One way to avoid this issue is by using a recursive lock.

Member Typedef Documentation

◆ SourceId

A type that identifies which source is currently being operated on.

◆ VectorOfTags

Member Enumeration Documentation

◆ TagType

The different types of metadata "stream tags".

Enumerator
STRING 
UINT 
INT 
DOUBLE 
BOOLEAN 

Constructor & Destructor Documentation

◆ ~MediaPlayerObserverInterface()

virtual alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::~MediaPlayerObserverInterface ( )
virtualdefault

Destructor.

Member Function Documentation

◆ onBufferingComplete()

virtual void alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::onBufferingComplete ( SourceId  id,
const MediaPlayerState state 
)
inlinevirtual

This is an indication to the observer that the MediaPlayer has completed buffering of the source specified by the id. This can be sent anytime after a source is set. This notification is part of AudioPlayer's implementation for pre-buffering, and must be called by MediaPlayer implementations for this feature to work properly.

Note
The observer must quickly return from this callback. Failure to do so could block the MediaPlayer from further processing.
Parameters
idThe id of the source to which this callback corresponds to.
stateMetadata about the media player state

Reimplemented in alexaClientSDK::mediaPlayer::test::MockPlayerObserver, and alexaClientSDK::capabilityAgents::audioPlayer::AudioPlayer.

◆ onBufferRefilled()

virtual void alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::onBufferRefilled ( SourceId  id,
const MediaPlayerState state 
)
inlinevirtual

This is an indication to the observer that the MediaPlayer's buffer has refilled. This will only be sent after playback has started. Playback will resume.

Note
The observer must quickly return from this callback. Failure to do so could block the MediaPlayer from further processing.
Parameters
idThe id of the source to which this callback corresponds to.
stateMetadata about the media player state

Reimplemented in alexaClientSDK::capabilityAgents::audioPlayer::AudioPlayer.

◆ onBufferUnderrun()

virtual void alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::onBufferUnderrun ( SourceId  id,
const MediaPlayerState state 
)
inlinevirtual

This is an indication to the observer that the MediaPlayer is experiencing a buffer underrun. This will only be sent after playback has started. Playback will be paused until the buffer is filled.

Note
The observer must quickly return from this callback. Failure to do so could block the MediaPlayer from further processing.
Parameters
idThe id of the source to which this callback corresponds to.
stateMetadata about the media player state

Reimplemented in alexaClientSDK::capabilityAgents::speechSynthesizer::SpeechSynthesizer, and alexaClientSDK::capabilityAgents::audioPlayer::AudioPlayer.

◆ onFirstByteRead()

virtual void alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::onFirstByteRead ( SourceId  id,
const MediaPlayerState state 
)
pure virtual

◆ onPlaybackError()

virtual void alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::onPlaybackError ( SourceId  id,
const ErrorType type,
std::string  error,
const MediaPlayerState state 
)
pure virtual

This is an indication to the observer that the MediaPlayer encountered an error. Errors can occur during playback.

Note
The observer must quickly return from this callback. Failure to do so could block the MediaPlayer from further processing.
Parameters
idThe id of the source to which this callback corresponds to.
typeThe type of error encountered by the MediaPlayerInterface.
errorThe error encountered by the MediaPlayerInterface.
stateMetadata about the media player state

Implemented in alexaClientSDK::capabilityAgents::alerts::renderer::Renderer, alexaClientSDK::capabilityAgents::notifications::NotificationRenderer, alexaClientSDK::mediaPlayer::test::MockPlayerObserver, alexaClientSDK::capabilityAgents::speechSynthesizer::SpeechSynthesizer, alexaClientSDK::capabilityAgents::audioPlayer::AudioPlayer, alexaClientSDK::captions::CaptionManager, and alexaClientSDK::capabilityAgents::bluetooth::Bluetooth.

◆ onPlaybackFinished()

virtual void alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::onPlaybackFinished ( SourceId  id,
const MediaPlayerState state 
)
pure virtual

This is an indication to the observer that the MediaPlayer finished the source.

Note
The observer must quickly return to quickly from this callback. Failure to do so could block the MediaPlayer from further processing.
Parameters
idThe id of the source to which this callback corresponds to.
stateMetadata about the media player state

Implemented in alexaClientSDK::capabilityAgents::alerts::renderer::Renderer, alexaClientSDK::capabilityAgents::notifications::NotificationRenderer, alexaClientSDK::mediaPlayer::test::MockPlayerObserver, alexaClientSDK::capabilityAgents::speechSynthesizer::SpeechSynthesizer, alexaClientSDK::capabilityAgents::audioPlayer::AudioPlayer, alexaClientSDK::captions::CaptionManager, and alexaClientSDK::capabilityAgents::bluetooth::Bluetooth.

◆ onPlaybackPaused()

virtual void alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::onPlaybackPaused ( SourceId  id,
const MediaPlayerState state 
)
inlinevirtual

This is an indication to the observer that the MediaPlayer has paused playing the source.

Note
The observer must quickly return from this callback. Failure to do so could block the MediaPlayer from further processing.
Parameters
idThe id of the source to which this callback corresponds to.
stateMetadata about the media player state

Reimplemented in alexaClientSDK::mediaPlayer::test::MockPlayerObserver, alexaClientSDK::capabilityAgents::audioPlayer::AudioPlayer, and alexaClientSDK::captions::CaptionManager.

◆ onPlaybackResumed()

virtual void alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::onPlaybackResumed ( SourceId  id,
const MediaPlayerState state 
)
inlinevirtual

This is an indication to the observer that the MediaPlayer has resumed playing the source.

Note
The observer must quickly return from this callback. Failure to do so could block the MediaPlayer from further processing.
Parameters
idThe id of the source to which this callback corresponds to.
stateMetadata about the media player state

Reimplemented in alexaClientSDK::mediaPlayer::test::MockPlayerObserver, alexaClientSDK::capabilityAgents::audioPlayer::AudioPlayer, and alexaClientSDK::captions::CaptionManager.

◆ onPlaybackStarted()

virtual void alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::onPlaybackStarted ( SourceId  id,
const MediaPlayerState state 
)
pure virtual

This is an indication to the observer that the MediaPlayer has started playing the source specified by the id.

Note
The observer must quickly return to quickly from this callback. Failure to do so could block the MediaPlayer from further processing.
Parameters
idThe id of the source to which this callback corresponds to.
stateMetadata about the media player state

Implemented in alexaClientSDK::capabilityAgents::alerts::renderer::Renderer, alexaClientSDK::capabilityAgents::notifications::NotificationRenderer, alexaClientSDK::mediaPlayer::test::MockPlayerObserver, alexaClientSDK::capabilityAgents::speechSynthesizer::SpeechSynthesizer, alexaClientSDK::capabilityAgents::audioPlayer::AudioPlayer, alexaClientSDK::captions::CaptionManager, and alexaClientSDK::capabilityAgents::bluetooth::Bluetooth.

◆ onPlaybackStopped()

virtual void alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::onPlaybackStopped ( SourceId  id,
const MediaPlayerState state 
)
inlinevirtual

This is an indication to the observer that the MediaPlayer has stopped the source.

Note
The observer must quickly return from this callback. Failure to do so could block the MediaPlayer from further processing.
Parameters
idThe id of the source to which this callback corresponds to.
stateMetadata about the media player state

Reimplemented in alexaClientSDK::capabilityAgents::alerts::renderer::Renderer, alexaClientSDK::capabilityAgents::notifications::NotificationRenderer, alexaClientSDK::mediaPlayer::test::MockPlayerObserver, alexaClientSDK::capabilityAgents::speechSynthesizer::SpeechSynthesizer, alexaClientSDK::capabilityAgents::audioPlayer::AudioPlayer, alexaClientSDK::captions::CaptionManager, and alexaClientSDK::capabilityAgents::bluetooth::Bluetooth.

◆ onTags()

virtual void alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::onTags ( SourceId  id,
std::unique_ptr< const VectorOfTags vectorOfTags,
const MediaPlayerState state 
)
inlinevirtual

This is an indication to the observer that the MediaPlayer has found tags in the stream. Tags are key value pairs extracted from the metadata of the stream. There can be multiple tags that have the same key. Vector preserves the order of insertion (push_back) which may come in handy.

Note
The observer must quickly returnfrom this callback. Failure to do so could block the MediaPlayer from further processing.
Parameters
idThe id of the source to which this callback corresponds to.
vectorOfTagsThe vector containing stream tags.
stateMetadata about the media player state

Reimplemented in alexaClientSDK::mediaPlayer::test::MockPlayerObserver, and alexaClientSDK::capabilityAgents::audioPlayer::AudioPlayer.


The documentation for this class was generated from the following file:

AlexaClientSDK 1.18.0 - Copyright 2016-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0