NUGU SDK Linux  1.7.6
media_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_MEDIA_PLAYER_INTERFACE_H__
18 #define __NUGU_MEDIA_PLAYER_INTERFACE_H__
19 
20 #include <string>
21 
22 #include <base/nugu_audio.h>
23 #include <nugu.h>
24 
25 namespace NuguClientKit {
26 
41 enum class MediaPlayerState {
42  IDLE,
43  PREPARE,
44  READY,
45  PLAYING,
46  PAUSED,
47  STOPPED
48 };
49 
53 enum class MediaPlayerEvent {
59 };
60 
65 class NUGU_API IMediaPlayerListener {
66 public:
67  virtual ~IMediaPlayerListener() = default;
68 
73  virtual void mediaStateChanged(MediaPlayerState state) = 0;
74 
79  virtual void mediaEventReport(MediaPlayerEvent event) = 0;
80 
85  virtual void mediaChanged(const std::string& url) = 0;
86 
91  virtual void durationChanged(int duration) = 0;
92 
97  virtual void positionChanged(int position) = 0;
98 
103  virtual void volumeChanged(int volume) = 0;
104 
109  virtual void muteChanged(int mute) = 0;
110 };
111 
116 class NUGU_API IMediaPlayer {
117 public:
118  virtual ~IMediaPlayer() = default;
119 
124  virtual void addListener(IMediaPlayerListener* listener) = 0;
125 
130  virtual void removeListener(IMediaPlayerListener* listener) = 0;
131 
136  virtual void setAudioAttribute(NuguAudioAttribute attr) = 0;
137 
142  virtual bool setSource(const std::string& url) = 0;
143 
147  virtual bool play() = 0;
148 
152  virtual bool stop() = 0;
153 
157  virtual bool pause() = 0;
158 
162  virtual bool resume() = 0;
163 
168  virtual bool seek(int sec) = 0;
169 
174  virtual int position() = 0;
175 
180  virtual bool setPosition(int position) = 0;
181 
186  virtual bool loop() = 0;
187 
192  virtual void setLoop(bool loop) = 0;
193 
198  virtual int duration() = 0;
199 
204  virtual bool setDuration(int duration) = 0;
205 
210  virtual int volume() = 0;
211 
216  virtual bool setVolume(int volume) = 0;
217 
222  virtual bool mute() = 0;
223 
228  virtual bool setMute(bool mute) = 0;
229 
234  virtual bool isPlaying() = 0;
235 
240  virtual MediaPlayerState state() = 0;
241 
246  virtual bool setState(MediaPlayerState state) = 0;
247 
253  virtual std::string stateString(MediaPlayerState state) = 0;
254 
259  virtual std::string url() = 0;
260 };
261 
266 class NUGU_API ITTSPlayer : public IMediaPlayer {
267 public:
268  virtual ~ITTSPlayer() = default;
269 
276  virtual bool writeAudio(const char* data, int size) = 0;
277 
281  virtual void writeDone() = 0;
282 };
283 
288 } // NuguClientKit
289 
290 #endif
mediaplayer listener interface
Definition: media_player_interface.hh:65
virtual void volumeChanged(int volume)=0
The media player reports the changed volume of the media content.
virtual void mediaChanged(const std::string &url)=0
The media player reports that the media content has changed.
virtual void durationChanged(int duration)=0
The media player reports the changed duration of the media content.
virtual void mediaEventReport(MediaPlayerEvent event)=0
Report an event occurred during mediaplayer playback to the user.
virtual void muteChanged(int mute)=0
The media player reports the changed mute of the media content.
virtual void mediaStateChanged(MediaPlayerState state)=0
Report changes in the mediaplayer state to the user.
virtual void positionChanged(int position)=0
The media player reports the changed position of the media content.
mediaplayer interface
Definition: media_player_interface.hh:116
virtual bool setDuration(int duration)=0
Set duration of the media content to the media player.
virtual void removeListener(IMediaPlayerListener *listener)=0
Remove the Listener object.
virtual bool stop()=0
Request media player to stop the media content.
virtual bool play()=0
Request media player to play the media content.
virtual bool mute()=0
Get mute information of the media content from the media player.
virtual bool loop()=0
Get loop information of the media content from the media player.
virtual bool pause()=0
Request media player to pause the media content.
virtual int volume()=0
Get volume information of the media content from the media player.
virtual std::string url()=0
Get url of media content from the media player.
virtual bool setState(MediaPlayerState state)=0
Set state of the media player.
virtual bool setMute(bool mute)=0
Set mute of the media content to the media player.
virtual int duration()=0
Get duration information of the media content from the media player.
virtual bool resume()=0
Request media player to resume the media content.
virtual int position()=0
Get current position information of the media content from the media player.
virtual bool setVolume(int volume)=0
Set volume of the media content to the media player.
virtual void setAudioAttribute(NuguAudioAttribute attr)=0
Sets the audio attribute in the media player.
virtual MediaPlayerState state()=0
Get state of the media player.
virtual bool setSource(const std::string &url)=0
Sets the playurl of the media content to play in the media player.
virtual bool setPosition(int position)=0
Set current position of the media content to the media player.
virtual std::string stateString(MediaPlayerState state)=0
Get state name of the media player.
virtual bool seek(int sec)=0
Request the media player to move the current content section.
virtual void setLoop(bool loop)=0
Set loop of the media content to the media player.
virtual bool isPlaying()=0
Check whether the media player is playing media content.
virtual void addListener(IMediaPlayerListener *listener)=0
Add the Listener object.
ttsplayer interface
Definition: media_player_interface.hh:266
virtual bool writeAudio(const char *data, int size)=0
Write audio samples to the tts player. The player decodes it using opus.
virtual void writeDone()=0
Notify to write done to the tts player.
MediaPlayerState
MediaPlayerState.
Definition: media_player_interface.hh:41
MediaPlayerEvent
MediaPlayerEvent.
Definition: media_player_interface.hh:53
enum nugu_audio_attribute NuguAudioAttribute
NuguAudioAttribute.
Definition: nugu_audio.h:101