AlexaClientSDK
1.20.1
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
#include <ExternalMediaPlayer.h>
Public Member Functions | |
void | addObserver (const std::shared_ptr< avsCommon::sdkInterfaces::externalMediaPlayer::ExternalMediaPlayerObserverInterface > observer) |
void | removeObserver (const std::shared_ptr< avsCommon::sdkInterfaces::externalMediaPlayer::ExternalMediaPlayerObserverInterface > observer) |
bool | init (const AdapterMediaPlayerMap &mediaPlayers, const AdapterSpeakerMap &speakers, const AdapterCreationMap &adapterCreationMap, std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerInterface > focusManager) |
std::map< std::string, std::shared_ptr< avsCommon::sdkInterfaces::externalMediaPlayer::ExternalMediaAdapterInterface > > | getAdaptersMap () |
ContextRequesterInterface Functions | |
void | onContextAvailable (const std::string &jsonContext) override |
void | onContextFailure (const avsCommon::sdkInterfaces::ContextRequestError error) override |
StateProviderInterface Functions | |
void | provideState (const avsCommon::avs::NamespaceAndName &stateProviderName, unsigned int stateRequestToken) override |
CapabilityAgent/DirectiveHandlerInterface Functions | |
void | handleDirectiveImmediately (std::shared_ptr< avsCommon::avs::AVSDirective > directive) override |
void | preHandleDirective (std::shared_ptr< DirectiveInfo > info) override |
void | handleDirective (std::shared_ptr< DirectiveInfo > info) override |
void | cancelDirective (std::shared_ptr< DirectiveInfo > info) override |
void | onDeregistered () override |
avsCommon::avs::DirectiveHandlerConfiguration | getConfiguration () const override |
Overridden PlaybackHandlerInterface methods. | |
virtual void | onButtonPressed (avsCommon::avs::PlaybackButton button) override |
virtual void | onTogglePressed (avsCommon::avs::PlaybackToggle toggle, bool action) override |
Overridden ExternalMediaPlayerInterface methods. | |
virtual void | setPlayerInFocus (const std::string &playerInFocus) override |
CapabilityConfigurationInterface Functions | |
std::unordered_set< std::shared_ptr< avsCommon::avs::CapabilityConfiguration > > | getCapabilityConfigurations () override |
RenderPlayerInfoCardsProviderInterface Functions | |
void | setObserver (std::shared_ptr< avsCommon::sdkInterfaces::RenderPlayerInfoCardsObserverInterface > observer) override |
LocalPlaybackHandlerInterface Functions | |
bool | localOperation (PlaybackOperation op) override |
bool | localSeekTo (std::chrono::milliseconds location, bool fromStart) override |
MediaPropertiesInterface Functions | |
std::chrono::milliseconds | getAudioItemOffset () override |
std::chrono::milliseconds | getAudioItemDuration () override |
Public Member Functions inherited from alexaClientSDK::avsCommon::avs::CapabilityAgent | |
virtual | ~CapabilityAgent ()=default |
void | preHandleDirective (std::shared_ptr< AVSDirective > directive, std::unique_ptr< sdkInterfaces::DirectiveHandlerResultInterface > result) override final |
bool | handleDirective (const std::string &messageId) override final |
void | cancelDirective (const std::string &messageId) override final |
void | onFocusChanged (FocusState newFocus, MixingBehavior behavior) override |
Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::DirectiveHandlerInterface | |
virtual | ~DirectiveHandlerInterface ()=default |
virtual void | handleDirectiveImmediately (std::shared_ptr< avsCommon::avs::AVSDirective > directive)=0 |
virtual void | preHandleDirective (std::shared_ptr< avsCommon::avs::AVSDirective > directive, std::unique_ptr< DirectiveHandlerResultInterface > result)=0 |
Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::ChannelObserverInterface | |
virtual | ~ChannelObserverInterface ()=default |
Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::StateProviderInterface | |
virtual | ~StateProviderInterface ()=default |
virtual void | provideState (const avs::CapabilityTag &stateProviderName, const ContextRequestToken stateRequestToken) |
virtual bool | canStateBeRetrieved () |
virtual bool | hasReportableStateProperties () |
Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::ContextRequesterInterface | |
virtual | ~ContextRequesterInterface ()=default |
virtual void | onContextAvailable (const endpoints::EndpointIdentifier &endpointId, const avs::AVSContext &endpointContext, ContextRequestToken requestToken) |
virtual void | onContextFailure (const ContextRequestError error, ContextRequestToken token) |
Public Member Functions inherited from alexaClientSDK::avsCommon::utils::RequiresShutdown | |
RequiresShutdown (const std::string &name) | |
virtual | ~RequiresShutdown () |
Destructor. More... | |
const std::string & | name () const |
void | shutdown () |
bool | isShutdown () const |
Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::CapabilityConfigurationInterface | |
virtual | ~CapabilityConfigurationInterface ()=default |
Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::ExternalMediaPlayerInterface | |
virtual | ~ExternalMediaPlayerInterface ()=default |
Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::MediaPropertiesInterface | |
virtual | ~MediaPropertiesInterface ()=default |
Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::RenderPlayerInfoCardsProviderInterface | |
virtual | ~RenderPlayerInfoCardsProviderInterface ()=default |
Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::PlaybackHandlerInterface | |
virtual | ~PlaybackHandlerInterface ()=default |
Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::LocalPlaybackHandlerInterface | |
virtual | ~LocalPlaybackHandlerInterface ()=default |
Static Public Member Functions | |
static std::shared_ptr< ExternalMediaPlayer > | create (const AdapterMediaPlayerMap &mediaPlayers, const AdapterSpeakerMap &speakers, const AdapterCreationMap &adapterCreationMap, std::shared_ptr< avsCommon::sdkInterfaces::SpeakerManagerInterface > speakerManager, std::shared_ptr< avsCommon::sdkInterfaces::MessageSenderInterface > messageSender, std::shared_ptr< certifiedSender::CertifiedSender > certifiedMessageSender, std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerInterface > focusManager, std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerInterface > contextManager, std::shared_ptr< avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface > exceptionSender, std::shared_ptr< avsCommon::sdkInterfaces::PlaybackRouterInterface > playbackRouter, std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder=nullptr) |
Static Public Attributes | |
static constexpr const char * | SPI_VERSION = "1.0" |
The spiVersion of this implementation of ExternalMediaPlayer. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from alexaClientSDK::avsCommon::avs::CapabilityAgent | |
CapabilityAgent (const std::string &nameSpace, std::shared_ptr< sdkInterfaces::ExceptionEncounteredSenderInterface > exceptionEncounteredSender) | |
virtual std::shared_ptr< DirectiveInfo > | createDirectiveInfo (std::shared_ptr< AVSDirective > directive, std::unique_ptr< sdkInterfaces::DirectiveHandlerResultInterface > result) |
void | removeDirective (const std::string &messageId) |
void | sendExceptionEncounteredAndReportFailed (std::shared_ptr< DirectiveInfo > info, const std::string &message, avsCommon::avs::ExceptionErrorType type=avsCommon::avs::ExceptionErrorType::INTERNAL_ERROR) |
const std::pair< std::string, std::string > | buildJsonEventString (const std::string &eventName, const std::string &dialogRequestIdString="", const std::string &payload="{}", const std::string &context="") const |
Protected Attributes inherited from alexaClientSDK::avsCommon::avs::CapabilityAgent | |
const std::string | m_namespace |
The namespace of the capability agent. More... | |
std::shared_ptr< sdkInterfaces::ExceptionEncounteredSenderInterface > | m_exceptionEncounteredSender |
Object to use to send exceptionEncountered messages. More... | |
This class implements the ExternalMediaPlayer
capability agent. This agent is responsible for handling music service providers which manage their PLAY queue.
shutdown()
must be called. using alexaClientSDK::capabilityAgents::externalMediaPlayer::ExternalMediaPlayer::AdapterCreateFunction = std::shared_ptr<avsCommon::sdkInterfaces::externalMediaPlayer::ExternalMediaAdapterInterface> (*)( std::shared_ptr<alexaClientSDK::avsCommon::utils::metrics::MetricRecorderInterface>, std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> mediaPlayer, std::shared_ptr<avsCommon::sdkInterfaces::ChannelVolumeInterface> speaker, std::shared_ptr<avsCommon::sdkInterfaces::SpeakerManagerInterface> speakerManager, std::shared_ptr<avsCommon::sdkInterfaces::MessageSenderInterface> messageSender, std::shared_ptr<avsCommon::sdkInterfaces::FocusManagerInterface> focusManager, std::shared_ptr<avsCommon::sdkInterfaces::ContextManagerInterface> contextManager, std::shared_ptr<avsCommon::sdkInterfaces::ExternalMediaPlayerInterface> externalMediaPlayer) |
using alexaClientSDK::capabilityAgents::externalMediaPlayer::ExternalMediaPlayer::AdapterCreationMap = std::unordered_map<std::string, AdapterCreateFunction> |
using alexaClientSDK::capabilityAgents::externalMediaPlayer::ExternalMediaPlayer::AdapterMediaPlayerMap = std::unordered_map<std::string, std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> > |
using alexaClientSDK::capabilityAgents::externalMediaPlayer::ExternalMediaPlayer::AdapterSpeakerMap = std::unordered_map<std::string, std::shared_ptr<avsCommon::sdkInterfaces::ChannelVolumeInterface> > |
void alexaClientSDK::capabilityAgents::externalMediaPlayer::ExternalMediaPlayer::addObserver | ( | const std::shared_ptr< avsCommon::sdkInterfaces::externalMediaPlayer::ExternalMediaPlayerObserverInterface > | observer | ) |
Adds an observer which will be notified on any observable state changes
observer | The observer to add |
|
overridevirtual |
Cancel an ongoing preHandleDirective()
or handleDirective()
operation for the AVSDirective
in . Once this has been called the CapabilityAgent
should not expect to receive further calls regarding this directive.
AVSDirectives
.info | The DirectiveInfo instance for the AVSDirective to process. |
Implements alexaClientSDK::avsCommon::avs::CapabilityAgent.
|
static |
Creates a new ExternalMediaPlayer
instance.
mediaPlayers | The map of <PlayerId, MediaPlayer> to be used to find the mediaPlayer to use for this adapter. |
speakers | The map of <PlayerId, ChannelVolumeInterface> to be used to find the speaker to use for this adapter. |
adapterCreationMap | The map of <PlayerId, AdapterCreateFunction> to be used to create the adapters. |
speakerManager | A SpeakerManagerInterface to perform volume changes requested by adapters. |
messageSender | The object to use for sending events. |
certifiedMessageSender | Used to send messages that must be guaranteed. |
focusManager | The object used to manage focus for the adapter managed by the EMP. |
contextManager | The AVS Context manager used to generate system context for events. |
exceptionSender | The object to use for sending AVS Exception messages. |
playbackRouter | The PlaybackRouterInterface instance to use when ExternalMediaPlayer becomes active. |
metricRecorder | The metric recorder. |
std::shared_ptr
to the new ExternalMediaPlayer
instance. std::map< std::string, std::shared_ptr< avsCommon::sdkInterfaces::externalMediaPlayer::ExternalMediaAdapterInterface > > alexaClientSDK::capabilityAgents::externalMediaPlayer::ExternalMediaPlayer::getAdaptersMap | ( | ) |
Getter for m_adapters
localPlayerId
(business names) to adapters.
|
overridevirtual |
Returns the duration of the current AudioItem the player is handling.
Reimplemented from alexaClientSDK::avsCommon::sdkInterfaces::MediaPropertiesInterface.
|
overridevirtual |
This function retrieves the offset of the current AudioItem the player is handling.
Implements alexaClientSDK::avsCommon::sdkInterfaces::MediaPropertiesInterface.
|
overridevirtual |
Returns the configurations of the capability interfaces being implemented.
Implements alexaClientSDK::avsCommon::sdkInterfaces::CapabilityConfigurationInterface.
|
overridevirtual |
Returns the configuration of the directive handler.
The configuration consists of multiple directive routing rules and their respective blocking policy. The directives will be matched from the most specific rule (with all fields defined) to the least specific rule (which only matches the directive endpointId).
avs::DirectiveHandlerConfiguration
of the handler. Implements alexaClientSDK::avsCommon::sdkInterfaces::DirectiveHandlerInterface.
|
overridevirtual |
Handle the action specified by the AVSDirective
in info
. The handling of subsequent directives with the same DialogRequestId
may be blocked until the DirectiveHandler
calls the setSucceeded()
method of the DirectiveHandlingResult
present in info
. If handling of this directive fails setFailed()
should be called to indicate a failure.
AVSDirectives
.info | The DirectiveInfo instance for the AVSDirective to process. |
Implements alexaClientSDK::avsCommon::avs::CapabilityAgent.
|
override |
bool alexaClientSDK::capabilityAgents::externalMediaPlayer::ExternalMediaPlayer::init | ( | const AdapterMediaPlayerMap & | mediaPlayers, |
const AdapterSpeakerMap & | speakers, | ||
const AdapterCreationMap & | adapterCreationMap, | ||
std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerInterface > | focusManager | ||
) |
Iniitalize the ExternalMediaAdapter.
mediaPlayers | The map of <PlayerId, MediaPlayer> to be used to find the mediaPlayer to use for this adapter. |
speakers | The map of <PlayerId, SpeakerInterface> to be used to find the speaker to use for this adapter. |
adapterCreationMap | The map of <PlayerId, AdapterCreateFunction> to be used to create the adapters. |
focusManager | Used to control channel focus. |
|
overridevirtual |
Request the handler to perform a local playback operation.
op | Operation to request |
Implements alexaClientSDK::avsCommon::sdkInterfaces::LocalPlaybackHandlerInterface.
|
overridevirtual |
Request the handler to perform a local seek operation.
location | Position to seek to |
fromStart | true to seek to absolute location, false to seek reletive to current location. |
Implements alexaClientSDK::avsCommon::sdkInterfaces::LocalPlaybackHandlerInterface.
|
overridevirtual |
Used to notify the handler when a playback button is pressed.
button | The button that has been pressed. |
Implements alexaClientSDK::avsCommon::sdkInterfaces::PlaybackHandlerInterface.
|
overridevirtual |
This is called by the ContextManager once the context is ready and available.
ContextRequester
should perform minimum processing and return quickly. Otherwise it will block the processing of updating the of other ContextProviders
.jsonContext | Context information.Context provided is of the format {"context"[{...}, {...}]} |
Reimplemented from alexaClientSDK::avsCommon::sdkInterfaces::ContextRequesterInterface.
|
overridevirtual |
The contextManager calls this if it is unable to process a getContext
request successfully.
ContextRequester
should perform minimum processing and return quickly. Otherwise it will block the processing of updating the of other ContextProviders
.error | The reason why the getContext request failed. |
Reimplemented from alexaClientSDK::avsCommon::sdkInterfaces::ContextRequesterInterface.
|
overridevirtual |
Notification that this handler has been de-registered and will not receive any more calls.
Reimplemented from alexaClientSDK::avsCommon::avs::CapabilityAgent.
|
overridevirtual |
Used to notify the handler when a playback toggle is pressed.
toggle | The toggle that has been pressed. |
action | The boolean action for the toggle state |
Implements alexaClientSDK::avsCommon::sdkInterfaces::PlaybackHandlerInterface.
|
overridevirtual |
Notification that a directive has arrived. This notification gives the DirectiveHandler a chance to prepare for handling of an AVSDirective
. If an error occurs during the pre-Handling phase and that error should cancel the handling of subsequent AVSDirectives
with the same DialogRequestId
, the DirectiveHandler
should call the setFailed
method on the result
instance passed in to this call.
AVSDirectives
.info | The DirectiveInfo instance for the AVSDirective to process. |
Implements alexaClientSDK::avsCommon::avs::CapabilityAgent.
|
overridevirtual |
A request to a StateProvider
to provide the state. The StateProvider
should perform minimum processing and return quickly, otherwise it will block the processing of updating the states of other StateProviders
. The ContextManager
specifies a token which it uses to track the getContext
request associated with this provideState
request. The stateProviderInterface
must use the same token when it updates its state via the setState
call.
: The setState method MUST be called from a different thread from where the provideState method is being called from.
stateProviderName | The name of the state provider. |
stateRequestToken | The token to use in the setState call. |
NamespaceAndName
is being deprecated. Use the CapabilityMessageIdentifier version instead. Reimplemented from alexaClientSDK::avsCommon::sdkInterfaces::StateProviderInterface.
void alexaClientSDK::capabilityAgents::externalMediaPlayer::ExternalMediaPlayer::removeObserver | ( | const std::shared_ptr< avsCommon::sdkInterfaces::externalMediaPlayer::ExternalMediaPlayerObserverInterface > | observer | ) |
Removes an observer from the list of active watchers
observer | The observer to remove |
|
overridevirtual |
This function sets an RenderPlayerInfoCardsObserverInterface
so that it will get notified for RenderPlayerInfoCards state changes. This implies that there can be one or no observer at a given time.
observer | The RenderPlayerInfoCardsObserverInterface |
Implements alexaClientSDK::avsCommon::sdkInterfaces::RenderPlayerInfoCardsProviderInterface.
|
overridevirtual |
Method to set the player in focus after an adapter has acquired the channel.
playerInFocus | The business name of the adapter that has currently acquired focus. |
ExternalMediaAdapterInterface
. Implements alexaClientSDK::avsCommon::sdkInterfaces::ExternalMediaPlayerInterface.
|
static |
The spiVersion of this implementation of ExternalMediaPlayer.
AlexaClientSDK 1.20.1 - Copyright 2016-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0