vlc | branch: master | Steve Lhomme <[email protected]> | Mon Mar 21 15:01:23 2016 +0100| [1a74d595400d8b9730a609def488977e66626ba5] | committer: Jean-Baptiste Kempf
chromecast: add the known player commands to send to the player based on https://developers.google.com/cast/docs/reference/messages > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1a74d595400d8b9730a609def488977e66626ba5 --- modules/stream_out/chromecast/chromecast.h | 7 ++ modules/stream_out/chromecast/chromecast_ctrl.cpp | 93 +++++++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h index 6864434..de7c466 100644 --- a/modules/stream_out/chromecast/chromecast.h +++ b/modules/stream_out/chromecast/chromecast.h @@ -110,6 +110,13 @@ struct intf_sys_t void msgReceiverGetStatus(); void msgPlayerLoad(); + void msgPlayerPlay(); + void msgPlayerStop(); + void msgPlayerPause(); + void msgPlayerGetStatus(); + void msgPlayerSeek(const std::string & currentTime); + void msgPlayerSetVolume(float volume); + void msgPlayerSetMute(bool mute); void processMessage(const castchannel::CastMessage &msg); diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp index f39acc3..8318edc 100644 --- a/modules/stream_out/chromecast/chromecast_ctrl.cpp +++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp @@ -685,6 +685,15 @@ void intf_sys_t::msgReceiverLaunchApp() buildMessage( NAMESPACE_RECEIVER, ss.str() ); } +void intf_sys_t::msgPlayerGetStatus() +{ + std::stringstream ss; + ss << "{\"type\":\"GET_STATUS\"," + << "\"requestId\":" << i_requestId++ + << "}"; + + pushMediaPlayerMessage( ss ); +} void intf_sys_t::msgPlayerLoad() { @@ -706,6 +715,90 @@ void intf_sys_t::msgPlayerLoad() pushMediaPlayerMessage( ss ); } +void intf_sys_t::msgPlayerPlay() +{ + assert(!mediaSessionId.empty()); + + std::stringstream ss; + ss << "{\"type\":\"PLAY\"," + << "\"mediaSessionId\":" << mediaSessionId << "," + << "\"requestId\":" << i_requestId++ + << "}"; + + pushMediaPlayerMessage( ss ); +} + +void intf_sys_t::msgPlayerStop() +{ + assert(!mediaSessionId.empty()); + + std::stringstream ss; + ss << "{\"type\":\"STOP\"," + << "\"mediaSessionId\":" << mediaSessionId << "," + << "\"requestId\":" << i_requestId++ + << "}"; + + pushMediaPlayerMessage( ss ); +} + +void intf_sys_t::msgPlayerPause() +{ + assert(!mediaSessionId.empty()); + + std::stringstream ss; + ss << "{\"type\":\"PAUSE\"," + << "\"mediaSessionId\":" << mediaSessionId << "," + << "\"requestId\":" << i_requestId++ + << "}"; + + pushMediaPlayerMessage( ss ); +} + +void intf_sys_t::msgPlayerSetVolume(float f_volume) +{ + assert(!mediaSessionId.empty()); + + if ( f_volume < 0.0 || f_volume > 1.0) + return; + + std::stringstream ss; + ss << "{\"type\":\"SET_VOLUME\"," + << "\"volume\":{\"level\":" << f_volume << "}," + << "\"mediaSessionId\":" << mediaSessionId << "," + << "\"requestId\":" << i_requestId++ + << "}"; + + pushMediaPlayerMessage( ss ); +} + +void intf_sys_t::msgPlayerSetMute(bool b_mute) +{ + assert(!mediaSessionId.empty()); + + std::stringstream ss; + ss << "{\"type\":\"SET_VOLUME\"," + << "\"volume\":{\"muted\":" << ( b_mute ? "true" : "false" ) << "}," + << "\"mediaSessionId\":" << mediaSessionId << "," + << "\"requestId\":" << i_requestId++ + << "}"; + + pushMediaPlayerMessage( ss ); +} + +void intf_sys_t::msgPlayerSeek(const std::string & currentTime) +{ + assert(!mediaSessionId.empty()); + + std::stringstream ss; + ss << "{\"type\":\"SEEK\"," + << "\"currentTime\":" << currentTime << "," + << "\"mediaSessionId\":" << mediaSessionId << "," + << "\"requestId\":" << i_requestId++ + << "}"; + + pushMediaPlayerMessage( ss ); +} + /** * @brief Send a message to the Chromecast * @param msg the CastMessage to send _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
