AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
SystemSoundPlayer.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ALEXA_CLIENT_SDK_APPLICATIONUTILITIES_SYSTEMSOUNDPLAYER_INCLUDE_SYSTEMSOUNDPLAYER_SYSTEMSOUNDPLAYER_H_
17 #define ALEXA_CLIENT_SDK_APPLICATIONUTILITIES_SYSTEMSOUNDPLAYER_INCLUDE_SYSTEMSOUNDPLAYER_SYSTEMSOUNDPLAYER_H_
18 
19 #include <future>
20 #include <memory>
21 
29 
30 namespace alexaClientSDK {
31 namespace applicationUtilities {
32 namespace systemSoundPlayer {
33 
35 static const constexpr char* SYSTEM_SOUND_MEDIA_PLAYER_NAME = "SystemSoundMediaPlayer";
36 
44 public:
53  static std::shared_ptr<SystemSoundPlayerInterface> createSystemSoundPlayerInterface(
54  std::shared_ptr<acsdkApplicationAudioPipelineFactoryInterfaces::ApplicationAudioPipelineFactoryInterface>
55  audioPipelineFactory,
56  std::shared_ptr<avsCommon::sdkInterfaces::audio::AudioFactoryInterface> audioFactory);
57 
67  static std::shared_ptr<SystemSoundPlayer> create(
68  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> mediaPlayer,
69  std::shared_ptr<avsCommon::sdkInterfaces::audio::SystemSoundAudioFactoryInterface> soundPlayerAudioFactory);
70 
73  std::shared_future<bool> playTone(Tone tone) override;
75 
79  void onPlaybackError(
80  SourceId id,
82  std::string error,
87 
88 private:
96  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> mediaPlayer,
97  std::shared_ptr<avsCommon::sdkInterfaces::audio::SystemSoundAudioFactoryInterface> soundPlayerAudioFactory);
98 
102  void finishPlayTone(bool result);
103 
106  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> m_mediaPlayer;
108  std::shared_ptr<avsCommon::sdkInterfaces::audio::SystemSoundAudioFactoryInterface> m_soundPlayerAudioFactory;
110  std::shared_future<bool> m_sharedFuture;
112  std::promise<bool> m_playTonePromise;
114  std::mutex m_mutex;
116  SourceId m_sourceId;
117 };
118 
119 } // namespace systemSoundPlayer
120 } // namespace applicationUtilities
121 } // namespace alexaClientSDK
122 
123 #endif // ALEXA_CLIENT_SDK_APPLICATIONUTILITIES_SYSTEMSOUNDPLAYER_INCLUDE_SYSTEMSOUNDPLAYER_SYSTEMSOUNDPLAYER_H_
void onPlaybackError(SourceId id, const avsCommon::utils::mediaPlayer::ErrorType &type, std::string error, const avsCommon::utils::mediaPlayer::MediaPlayerState &state) override
::std::string string
Definition: gtest-port.h:1097
void onPlaybackStarted(SourceId id, const avsCommon::utils::mediaPlayer::MediaPlayerState &state) override
static const constexpr char * SYSTEM_SOUND_MEDIA_PLAYER_NAME
String to identify the system sound media player to render system sounds.
Definition: SystemSoundPlayer.h:35
static std::shared_ptr< SystemSoundPlayer > create(std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerInterface > mediaPlayer, std::shared_ptr< avsCommon::sdkInterfaces::audio::SystemSoundAudioFactoryInterface > soundPlayerAudioFactory)
static std::shared_ptr< SystemSoundPlayerInterface > createSystemSoundPlayerInterface(std::shared_ptr< acsdkApplicationAudioPipelineFactoryInterfaces::ApplicationAudioPipelineFactoryInterface > audioPipelineFactory, std::shared_ptr< avsCommon::sdkInterfaces::audio::AudioFactoryInterface > audioFactory)
MediaPlayerInterface::SourceId SourceId
A type that identifies which source is currently being operated on.
Definition: MediaPlayerObserverInterface.h:49
void onPlaybackFinished(SourceId id, const avsCommon::utils::mediaPlayer::MediaPlayerState &state) override
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
type
Definition: upload.py:443
void onFirstByteRead(SourceId id, const avsCommon::utils::mediaPlayer::MediaPlayerState &state) override
ErrorType
Identifies the specific type of error in a PlaybackFailed event.
Definition: ErrorTypes.h:28
Tone
The different system sounds supported.
Definition: SystemSoundPlayerInterface.h:36

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