NUGU SDK Linux  1.7.6
audio_player_interface.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 SK Telecom Co., Ltd. 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  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __NUGU_AUDIO_PLAYER_INTERFACE_H__
18 #define __NUGU_AUDIO_PLAYER_INTERFACE_H__
19 
22 #include <nugu.h>
23 
24 namespace NuguCapability {
25 
26 using namespace NuguClientKit;
27 
43 enum class AudioPlayerState {
44  IDLE,
45  PLAYING,
46  STOPPED,
47  PAUSED,
48  FINISHED
49 };
50 
54 enum class AudioPlayerEvent {
55  UNDERRUN,
56  LOAD_FAILED,
57  LOAD_DONE,
58  INVALID_URL,
62 };
63 
67 enum class RepeatType {
68  NONE,
69  ONE,
70  ALL
71 };
72 
77 class NUGU_API IAudioPlayerListener : virtual public ICapabilityListener {
78 public:
79  virtual ~IAudioPlayerListener() = default;
80 
86  virtual void mediaStateChanged(AudioPlayerState state, const std::string& dialog_id) = 0;
87 
91  virtual void mediaEventReport(AudioPlayerEvent event, const std::string& dialog_id) = 0;
92 
97  virtual void durationChanged(int duration) = 0;
98 
103  virtual void positionChanged(int position) = 0;
104 
110  virtual void favoriteChanged(bool favorite, const std::string& dialog_id) = 0;
111 
117  virtual void shuffleChanged(bool shuffle, const std::string& dialog_id) = 0;
118 
124  virtual void repeatChanged(RepeatType repeat, const std::string& dialog_id) = 0;
125 
131  virtual void requestContentCache(const std::string& key, const std::string& playurl) = 0;
132 
139  virtual bool requestToGetCachedContent(const std::string& key, std::string& filepath) = 0;
140 };
141 
146 class NUGU_API IAudioPlayerDisplayListener : virtual public IDisplayListener {
147 public:
148  virtual ~IAudioPlayerDisplayListener() = default;
149 
156  virtual bool requestLyricsPageAvailable(const std::string& id, bool& visible) = 0;
157 
163  virtual bool showLyrics(const std::string& id) = 0;
164 
170  virtual bool hideLyrics(const std::string& id) = 0;
171 
177  virtual void updateMetaData(const std::string& id, const std::string& json_payload) = 0;
178 };
179 
184 class NUGU_API IAudioPlayerHandler : virtual public ICapabilityInterface,
185  virtual public IDisplayHandler {
186 public:
187  virtual ~IAudioPlayerHandler() = default;
188 
193  virtual std::string play() = 0;
194 
200  virtual std::string stop(bool direct_access = false) = 0;
201 
206  virtual std::string next() = 0;
207 
212  virtual std::string prev() = 0;
213 
219  virtual std::string pause(bool direct_access = false) = 0;
220 
226  virtual std::string resume(bool direct_access = false) = 0;
227 
232  virtual void seek(int msec) = 0;
233 
239  virtual std::string requestFavoriteCommand(bool current_favorite) = 0;
240 
246  virtual std::string requestRepeatCommand(RepeatType current_repeat) = 0;
247 
253  virtual std::string requestShuffleCommand(bool current_shuffle) = 0;
254 
260  virtual bool setVolume(int volume) = 0;
261 
267  virtual bool setMute(bool mute) = 0;
268 
273  virtual void addListener(IAudioPlayerListener* listener) = 0;
274 
279  virtual void removeListener(IAudioPlayerListener* listener) = 0;
280 };
281 
286 } // NuguCapability
287 
288 #endif /* __NUGU_AUDIO_PLAYER_INTERFACE_H__ */
audioplayer's display listener interface
Definition: audio_player_interface.hh:146
virtual bool showLyrics(const std::string &id)=0
Request to the user to show the lyrics page.
virtual void updateMetaData(const std::string &id, const std::string &json_payload)=0
Request to update metadata the current display.
virtual bool requestLyricsPageAvailable(const std::string &id, bool &visible)=0
SDK request information about device's lyrics page available.
virtual bool hideLyrics(const std::string &id)=0
Request to the user to hide the lyrics page.
audioplayer handler interface
Definition: audio_player_interface.hh:185
virtual bool setMute(bool mute)=0
set media player's mute
virtual void removeListener(IAudioPlayerListener *listener)=0
Remove the Listener object.
virtual void addListener(IAudioPlayerListener *listener)=0
Add the Listener object.
virtual bool setVolume(int volume)=0
set media player's volume
virtual std::string requestShuffleCommand(bool current_shuffle)=0
Send to request shuffle command event with current shuffle value.
virtual std::string play()=0
Request the audio player to play the current content.
virtual std::string stop(bool direct_access=false)=0
Request the audio player to stop the current content.
virtual std::string pause(bool direct_access=false)=0
Request the audio player to pause the current content.
virtual void seek(int msec)=0
Request the audio player to move the current content section.
virtual std::string prev()=0
Request the audio player to play the previous content.
virtual std::string resume(bool direct_access=false)=0
Request the audio player to resume the current content.
virtual std::string requestRepeatCommand(RepeatType current_repeat)=0
Send to request repeat command event with current repeat value.
virtual std::string requestFavoriteCommand(bool current_favorite)=0
Send to request favorite command event with current favorite value.
virtual std::string next()=0
Request the audio player to play the next content.
audioplayer listener interface
Definition: audio_player_interface.hh:77
virtual void repeatChanged(RepeatType repeat, const std::string &dialog_id)=0
The audio player reports to the user the current content's repeat setting changed.
virtual void durationChanged(int duration)=0
The audio player reports the total duration of the content being played to the user.
virtual void favoriteChanged(bool favorite, const std::string &dialog_id)=0
The audio player reports to the user the current content's favorite setting changed.
virtual void mediaStateChanged(AudioPlayerState state, const std::string &dialog_id)=0
Report this to the user when the state of the audio player changes.
virtual void shuffleChanged(bool shuffle, const std::string &dialog_id)=0
The audio player reports to the user the current content's shuffle setting changed.
virtual void mediaEventReport(AudioPlayerEvent event, const std::string &dialog_id)=0
The audio player reports player's event being played to the user.
virtual void requestContentCache(const std::string &key, const std::string &playurl)=0
The audio player request to the user to cache the content if possible.
virtual void positionChanged(int position)=0
The audio player reports to the user the current playing time of the content being played.
virtual bool requestToGetCachedContent(const std::string &key, std::string &filepath)=0
The audio player request to the user to get the cached content.
display handler interface
Definition: display_interface.hh:107
display listener interface
Definition: display_interface.hh:66
capability interface
Definition: capability_interface.hh:82
capability listener interface
Definition: capability_interface.hh:60
RepeatType
RepeatType.
Definition: audio_player_interface.hh:67
AudioPlayerEvent
AudioPlayerEvent.
Definition: audio_player_interface.hh:54
AudioPlayerState
AudioPlayerState.
Definition: audio_player_interface.hh:43