Native Player  1.0
player_listeners.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 //
3 // Copyright (c) 2016, Samsung Electronics Co., Ltd
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to
7 // deal in the Software without restriction, including without limitation the
8 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 // sell copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
20 // , OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22 //
23 // @author Tomasz Borkowski
24 // Michal Murgrabia
25 //
26 // ----------------------------------------------------------------------------
27 
28 #ifndef NATIVE_PLAYER_INC_PLAYER_PLAYER_LISTENERS_H_
29 #define NATIVE_PLAYER_INC_PLAYER_PLAYER_LISTENERS_H_
30 
31 #include <memory>
32 
33 #include "nacl_player/buffering_listener.h"
34 #include "nacl_player/media_events_listener.h"
35 #include "nacl_player/subtitle_listener.h"
36 #include "ppapi/cpp/var.h"
37 
40 #include "common.h"
41 
46 
51 class SubtitleListener : public Samsung::NaClPlayer::SubtitleListener {
52  public:
57  explicit SubtitleListener(
58  std::weak_ptr<Communication::MessageSender> message_sender)
59  : message_sender_(std::move(message_sender)) {}
60 
70  void OnShowSubtitle(Samsung::NaClPlayer::TimeTicks time, const char* text)
71  override;
72 
73  private:
74  std::weak_ptr<Communication::MessageSender> message_sender_;
75 };
76 
82 class MediaPlayerListener : public Samsung::NaClPlayer::MediaEventsListener {
83  public:
89  std::weak_ptr<Communication::MessageSender> message_sender)
90  : message_sender_(std::move(message_sender)) {}
91 
98  void OnTimeUpdate(Samsung::NaClPlayer::TimeTicks time) override;
99 
103  void OnEnded() override;
104 
110  void OnError(Samsung::NaClPlayer::MediaPlayerError error) override;
111 
112  private:
113  std::weak_ptr<Communication::MessageSender> message_sender_;
114 };
115 
121 class MediaBufferingListener : public Samsung::NaClPlayer::BufferingListener {
122  public:
131  std::weak_ptr<Communication::MessageSender> message_sender,
132  std::weak_ptr<PlayerController> player_controller = {})
133  : message_sender_(std::move(message_sender)),
134  player_controller_(std::move(player_controller)) {}
135 
139  void OnBufferingStart() override;
140 
148  void OnBufferingProgress(uint32_t percent) override;
149 
159  void OnBufferingComplete() override;
160 
161  private:
162  std::weak_ptr<Communication::MessageSender> message_sender_;
163  std::weak_ptr<PlayerController> player_controller_;
164 };
165 
170  std::shared_ptr<MediaBufferingListener> buffering_listener;
171  std::shared_ptr<MediaPlayerListener> player_listener;
172  std::shared_ptr<SubtitleListener> subtitle_listener;
173 };
174 
175 #endif // NATIVE_PLAYER_INC_PLAYER_PLAYER_LISTENERS_H_
This file defines SubtitleListener, MediaPlayerListener, MediaBufferingListener classes and PlayerLis...
This file defines the PlayerController class.
SubtitleListener(std::weak_ptr< Communication::MessageSender > message_sender)
It aggregates implementation of all basic listeners required by NaClPlayer.
Listener class designed to handle player and playback related events from the platform. MediaPlayerListener receives event&#39;s information and passes it through the communication channel using MessageSender.
MediaBufferingListener(std::weak_ptr< Communication::MessageSender > message_sender, std::weak_ptr< PlayerController > player_controller={})
std::shared_ptr< MediaBufferingListener > buffering_listener
std::shared_ptr< SubtitleListener > subtitle_listener
MediaPlayerListener(std::weak_ptr< Communication::MessageSender > message_sender)
This file defines a MessageSender class.
std::shared_ptr< MediaPlayerListener > player_listener
void OnShowSubtitle(Samsung::NaClPlayer::TimeTicks time, const char *text) override
Listener class designed to handle buffering related events. MediaBufferingListener receives event&#39;s i...