Main class responsible for handling messages from the communication channel and controlling player life cycle.
More...
#include <message_receiver.h>
Main class responsible for handling messages from the communication channel and controlling player life cycle.
MessageReceiver
is designed to receive messages from the communication channel and perform proper actions. It accepts only VarDictionary
messages, which must contain a key named kKeyMessageToPlayer
and have a value defined by the enum MessageToPlayer
. Basing on this value MessageReceiver
performs a proper action on the player.
- See also
- Communication Description of the
Communication
namespace provides a brief of the communication mechanism.
-
kKeyMessageToPlayer
-
MessageToPlayer
Definition at line 59 of file message_receiver.h.
Communication::MessageReceiver::MessageReceiver |
( |
std::shared_ptr< PlayerProvider > |
player_provider | ) |
|
|
inlineexplicit |
Communication::MessageReceiver::~MessageReceiver |
( |
| ) |
|
|
inline |
void Communication::MessageReceiver::ChangeRepresentation |
( |
const pp::Var & |
type, |
|
|
const pp::Var & |
id |
|
) |
| |
Validates a kChangeRepresentation
message, decodes provided parameters and requests the player to change the defined representation from the current one to the specified one. The request will be ignored if the content is not loaded.
- Parameters
-
[in] | type | A type of the stream which is requested to be changed, Video = 0 or Audio = 1 . This Var is cast to a StreamType and it has to be an integer value. |
[in] | id | An id of a representation which should be used. This Var has to be an integer value. |
- See also
- kChangeRepresentation.
-
StreamType
void Communication::MessageReceiver::ChangeSubtitlesRepresentation |
( |
const pp::Var & |
id | ) |
|
Handles a kChangeSubtitlesRepresentation
message, validates a provided parameter and requests the player to change subtitle strack to a defined one. The request will be ignored if the content is not loaded.
- Parameters
-
[in] | id | An ID of subtitles which need to be used. This Var has to be an int type. |
- See also
- kChangeSubtitlesRepresentation
void Communication::MessageReceiver::ChangeSubtitlesVisibility |
( |
| ) |
|
Method which handles a kChangeSubtitlesVisibility
message and disables or enables generating subtitle events, depending on previous state. The request will be ignored if the content is not loaded.
- See also
- kChangeSubtitlesVisibility
void Communication::MessageReceiver::ChangeViewRect |
( |
const pp::Var & |
x_position, |
|
|
const pp::Var & |
y_position, |
|
|
const pp::Var & |
width, |
|
|
const pp::Var & |
height |
|
) |
| |
Handles a kChangeViewRect
message, validates provided parameters and informs the player about new position and resolution of plugin window. If the player is not initialized then parameters will be provided during initialization.
- Parameters
-
[in] | x_position | An x position of the plugin left upper corner; should be expressed by an integer value. |
[in] | y_position | A y position of the plugin left upper corner; should be expressed by an integer value. |
[in] | width | A width of the plugin window; should be expressed by an integer value. |
[in] | height | A height of the plugin window; should be expressed by an integer value. |
- See also
- kChangeViewRect
void Communication::MessageReceiver::ClosePlayer |
( |
| ) |
|
Handles a kClosePlayer
message, closes the player and frees resources.
- See also
- kClosePlayer
pp::Var Communication::MessageReceiver::HandleBlockingMessage |
( |
pp::InstanceHandle |
instance, |
|
|
const pp::Var & |
message_data |
|
) |
| |
|
override |
Handles synchronous messages. Such way of communication is not used in this application. Method sends a received message as a replay message.
- Parameters
-
[in] | instance | A handle to a plugin instance to which the message was addressed. The Value is provided automatically by NaCl engine. |
[in] | message_data | A container with message. |
- Returns
- Var object which is send back as a replay message.
void Communication::MessageReceiver::HandleMessage |
( |
pp::InstanceHandle |
instance, |
|
|
const pp::Var & |
message_data |
|
) |
| |
|
override |
Handles asynchronous messages from the communication channel. This method performs an action selected basing on a value mapped by the kKeyMessageToPlayer
key contained within message_data dictionary.
- Parameters
-
[in] | instance | A handle to a plugin instance to which a message was addressed. This value is provided automatically by the NaCl engine and is not used in this application. |
[in] | message_data | A container with a message, it is expected that the message is VarDictionary . |
- See also
- kKeyMessageToPlayer
-
MessageToPlayer
void Communication::MessageReceiver::LoadMedia |
( |
const pp::Var & |
type, |
|
|
const pp::Var & |
url, |
|
|
const pp::Var & |
subtitle, |
|
|
const pp::Var & |
encoding |
|
) |
| |
Validates a kLoadMedia
message, decodes provided parameters and creates a player that can handle a given type of the multimedia content.
- Parameters
-
[in] | type | A type of a content which needs to be loaded. This Var is casted to ClipTypeEnum and it has to be an integer value. |
[in] | url | An URL to a content container, it could point to different types of files depending on the player type. This Var has to be a string type value. |
[in] | subtitle | An URL to the file with external subtitles. It is an optional parameter, but if provided it has to be a string type value. |
[in] | encoding | A subtitle encoding code. It is an optional parameter, which has to be a string type value. |
- See also
- kLoadMedia
-
ClipTypeEnum
void Communication::MessageReceiver::Pause |
( |
| ) |
|
Handles a kPause
message, and requests the player to pause. The request will be ignored if the content is not loaded.
- See also
- kPause
void Communication::MessageReceiver::Play |
( |
| ) |
|
Handles a kPlay
message, and requests the player to start play. The request will be ignored if the content is not loaded.
- See also
- kPlay
void Communication::MessageReceiver::Seek |
( |
const pp::Var & |
time | ) |
|
Handles a kSeek
message, validates a provided parameter and requests the player to change current playback time to the defined one. The request will be ignored if the content is not loaded.
- Parameters
-
[in] | time | Time from which playback should continue when seek operation completes. This value is cast to TimeTick and it has to be a floating point value. |
- See also
- kSeek
-
TimeTick
void Communication::MessageReceiver::WasUnregistered |
( |
pp::InstanceHandle |
instance | ) |
|
|
inlineoverride |
Informs MessageReceiver
object that it was unregistered from receiving messages. After this, no more calls will be made to this object.
- Parameters
-
[in] | instance | A handle to a plugin instance from which receiving list object has been removed. |
Definition at line 104 of file message_receiver.h.
The documentation for this class was generated from the following file: