SinricPro Library
MediaController< T >

MediaController. More...

Inheritance diagram for MediaController< T >:

Public Types

using MediaControlCallback = std::function< bool(const String &, String &)>
 Callback definition for onMediaControl function. More...
 

Public Member Functions

void onMediaControl (MediaControlCallback cb)
 Set callback function for mediaControl request. More...
 
bool sendMediaControlEvent (String mediaControl, String cause="PHYSICAL_INTERACTION")
 Send mediaControl event to SinricPro Server indicating devices media control state. More...
 

Detailed Description

template<typename T>
class MediaController< T >

MediaController.

Member Typedef Documentation

◆ MediaControlCallback

using MediaControlCallback = std::function<bool(const String &, String &)>

Callback definition for onMediaControl function.

Gets called when device receive a mediaControl request

Parameters
[in]deviceIdString which contains the ID of device
[in]controlString with requested control
FastForward, Next, Pause, Play, Previous, Rewind, StartOver, Stop
[out]controlString with control
FastForward, Next, Pause, Play, Previous, Rewind, StartOver, Stop
Returns
the success of the request
Return values
truerequest handled properly
falserequest was not handled properly because of some error

Example-Code

bool onMediaControl(const String &deviceId, String &control) {
Serial.printf("Device %s: %s\r\n", deviceId.c_str(), control.c_str());
return true; // request handled properly
}
void onMediaControl(MediaControlCallback cb)
Set callback function for mediaControl request.
Definition: MediaController.h:48

Member Function Documentation

◆ onMediaControl()

void onMediaControl ( MediaControlCallback  cb)

Set callback function for mediaControl request.

Parameters
cbFunction pointer to a MediaControlCallback function
Returns
void
See also
MediaControlCallback

◆ sendMediaControlEvent()

bool sendMediaControlEvent ( String  mediaControl,
String  cause = "PHYSICAL_INTERACTION" 
)

Send mediaControl event to SinricPro Server indicating devices media control state.

Parameters
mediaControlString with actual media control
FastForward, Next, Pause, Play, Previous, Rewind, StartOver, Stop
cause(optional) String reason why event is sent (default = "PHYSICAL_INTERACTION")
Returns
the success of sending the even
Return values
trueevent has been sent successfully
falseevent has not been sent, maybe you sent to much events in a short distance of time