diff --git a/src/android/JSCommandDispatcher.java b/src/android/JSCommandDispatcher.java index 76a7e42a..a055301a 100644 --- a/src/android/JSCommandDispatcher.java +++ b/src/android/JSCommandDispatcher.java @@ -394,6 +394,14 @@ public void onError(ServiceCommandError error) { }); } + @CommandMethod + public void mediaControl_getPlayState(JSCommand command, JSONObject args) throws JSONException { + MediaControl mediaControl = getMediaControl(command, args); + + mediaControl.getPlayState(command.getPlayStateListener()); + + } + @CommandMethod public void mediaControl_subscribePlayState(final JSCommand command, JSONObject args) throws JSONException { MediaControl mediaControl = getMediaControl(command, args); diff --git a/src/ios/ConnectSDKCordovaDispatcher.m b/src/ios/ConnectSDKCordovaDispatcher.m index 67950664..779e9b63 100644 --- a/src/ios/ConnectSDKCordovaDispatcher.m +++ b/src/ios/ConnectSDKCordovaDispatcher.m @@ -535,6 +535,14 @@ - (void) mediaControl_getPosition:(JSCommand*)command [mediaControl getPositionWithSuccess:command.successWithDouble failure:command.failure]; } +- (void) mediaControl_getPlayState:(JSCommand*)command +{ + id mediaControl = [self getMediaControl:command]; + if (!mediaControl) return; + + [mediaControl getPlayStateWithSuccess:command.playStateSuccess failure:command.failure]; +} + - (ServiceSubscription*) mediaControl_subscribePlayState:(JSCommand*)command { id mediaControl = [self getMediaControl:command]; diff --git a/www/ConnectSDK.js b/www/ConnectSDK.js index 4f9a79ca..7a68faa1 100644 --- a/www/ConnectSDK.js +++ b/www/ConnectSDK.js @@ -1239,10 +1239,11 @@ var MediaControlWrapper = createClass( this._objectId = data.objectId; }, - _sendCommand: function (command, params) { + _sendCommand: function (command, params, subscribe) { params = params || {}; params.objectId = this._objectId; - return this._device._sendCommand("mediaControl", command, params); + subscribe = subscribe || false; + return this._device._sendCommand("mediaControl", command, params, subscribe); }, play: function () { @@ -1277,8 +1278,12 @@ var MediaControlWrapper = createClass( return this._sendCommand("getPosition"); }, + getPlayState: function () { + return this._sendCommand("getPlayState"); + }, + subscribePlayState: function () { - return this._sendCommand("subscribePlayState"); + return this._sendCommand("subscribePlayState", {}, true); } }); @@ -1771,9 +1776,17 @@ registerDeviceInterface("mediaControl", /** * @method - * @success {playStateCallback} + * @success {getPlayStateCallback} */ - subscribePlayState: {} + getPlayState: {}, + + /** + * @method + * @success {subscribePlayState} + */ + subscribePlayState: { + subscribe: true + } }); /** @class PlaylistControl */