AlexaClientSDK  1.25.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
PlayerActivity.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_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_PLAYERACTIVITY_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_PLAYERACTIVITY_H_
18 
19 #include <istream>
20 #include <ostream>
21 
22 namespace alexaClientSDK {
23 namespace avsCommon {
24 namespace avs {
25 
27 enum class PlayerActivity {
29  IDLE,
30 
32  PLAYING,
33 
38  STOPPED,
39 
41  PAUSED,
42 
45 
47  FINISHED
48 };
49 
50 /*
51  * Convert a @c PlayerActivity to an AVS-compliant @c std::string.
52  *
53  * @param playerActivity The @c PlayerActivity to convert.
54  * @return The AVS-compliant string representation of @c playerActivity.
55  */
56 inline std::string playerActivityToString(PlayerActivity playerActivity) {
57  switch (playerActivity) {
59  return "IDLE";
61  return "PLAYING";
63  return "STOPPED";
65  return "PAUSED";
67  return "BUFFER_UNDERRUN";
69  return "FINISHED";
70  }
71  return "unknown PlayerActivity";
72 }
73 
81 inline std::ostream& operator<<(std::ostream& stream, const PlayerActivity& playerActivity) {
82  return stream << playerActivityToString(playerActivity);
83 }
84 
92 inline std::istream& operator>>(std::istream& is, PlayerActivity& value) {
93  std::string str;
94  is >> str;
95  if ("IDLE" == str) {
96  value = PlayerActivity::IDLE;
97  } else if ("PLAYING" == str) {
99  } else if ("STOPPED" == str) {
100  value = PlayerActivity::STOPPED;
101  } else if ("PAUSED" == str) {
102  value = PlayerActivity::PAUSED;
103  } else if ("BUFFER_UNDERRUN" == str) {
105  } else if ("FINISHED" == str) {
106  value = PlayerActivity::FINISHED;
107  } else {
108  is.setstate(std::ios_base::failbit);
109  }
110  return is;
111 }
112 
113 } // namespace avs
114 } // namespace avsCommon
115 } // namespace alexaClientSDK
116 
117 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_PLAYERACTIVITY_H_
Indicates that playback has finished.
std::istream & operator>>(std::istream &is, PlayerActivity &value)
Definition: PlayerActivity.h:92
Indicates that a buffer underrun has occurred and the stream is buffering.
Initial state, prior to acting on the first Play directive.
Indicates that audio is currently playing.
Indicates that the audio stream has been paused.
std::string playerActivityToString(PlayerActivity playerActivity)
Definition: PlayerActivity.h:56
std::ostream & operator<<(std::ostream &stream, AlexaResponseType responseType)
Definition: AlexaResponseType.h:93
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
PlayerActivity
Identifies the player state.
Definition: PlayerActivity.h:27

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