AlexaClientSDK  3.0.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, const MediaPlayerState &)
 
virtual void onPlaybackResumed (SourceId, const MediaPlayerState &)
 
virtual void onPlaybackStopped (SourceId, const MediaPlayerState &)
 
virtual void onBufferUnderrun (SourceId, const MediaPlayerState &)
 
virtual void onBufferRefilled (SourceId, const MediaPlayerState &)
 
virtual void onBufferingComplete (SourceId, const MediaPlayerState &)
 
virtual void onSeeked (SourceId, const MediaPlayerState &, const MediaPlayerState &)
 
virtual void onTags (SourceId, std::unique_ptr< const VectorOfTags >, const MediaPlayerState &)
 

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  ,
const MediaPlayerState  
)
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
SourceIdThe id of the source to which this callback corresponds to.
MediaPlayerStateMetadata about the media player state

◆ onBufferRefilled()

virtual void alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::onBufferRefilled ( SourceId  ,
const MediaPlayerState  
)
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
SourceIdThe id of the source to which this callback corresponds to.
MediaPlayerStateMetadata about the media player state

◆ onBufferUnderrun()

virtual void alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::onBufferUnderrun ( SourceId  ,
const MediaPlayerState  
)
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
SourceIdThe id of the source to which this callback corresponds to.
MediaPlayerStateMetadata about the media player state

◆ onFirstByteRead()

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

This is an indication to the observer that the MediaPlayer has read its first byte of data.

Parameters
idThe id of the source to which this callback corresponds to.
stateMetadata about the media player state

Implemented in alexaClientSDK::captions::CaptionManager.

◆ 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::captions::CaptionManager.

◆ 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::captions::CaptionManager.

◆ onPlaybackPaused()

virtual void alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::onPlaybackPaused ( SourceId  ,
const MediaPlayerState  
)
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
SourceIdThe id of the source to which this callback corresponds to.
MediaPlayerStateMetadata about the media player state

Reimplemented in alexaClientSDK::captions::CaptionManager.

◆ onPlaybackResumed()

virtual void alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::onPlaybackResumed ( SourceId  ,
const MediaPlayerState  
)
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
SourceIdThe id of the source to which this callback corresponds to.
MediaPlayerStateMetadata about the media player state

Reimplemented in 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::captions::CaptionManager.

◆ onPlaybackStopped()

virtual void alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::onPlaybackStopped ( SourceId  ,
const MediaPlayerState  
)
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
SourceIdThe id of the source to which this callback corresponds to.
MediaPlayerStateMetadata about the media player state

Reimplemented in alexaClientSDK::captions::CaptionManager.

◆ onSeeked()

virtual void alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::onSeeked ( SourceId  ,
const MediaPlayerState ,
const MediaPlayerState  
)
inlinevirtual

This is an indication to the observer that the MediaPlayer has seeked in the source specified by the id. This can be sent anytime after onPlaybackStarted has been called

Note
The observer must quickly return from this callback. Failure to do so could block the MediaPlayer from further processing.
Parameters
SourceIdThe id of the source to which this callback corresponds to.
MediaPlayerStateMetadata about the media player state at the point seek started
MediaPlayerStateMetadata about the media player state at the point the seek completed, or, if stopped / paused, the point playback will be resumed.

◆ onTags()

virtual void alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface::onTags ( SourceId  ,
std::unique_ptr< const VectorOfTags ,
const MediaPlayerState  
)
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
SourceIdThe id of the source to which this callback corresponds to.
VectorOfTagsThe vector containing stream tags.
MediaPlayerStateMetadata about the media player state

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

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