From 3e3111fb1c1207b734b317d941c167a7748c2fef Mon Sep 17 00:00:00 2001 From: Vaporexpress Date: Sun, 30 Jul 2017 11:55:50 +0200 Subject: [PATCH 1/4] Fix mistakes on js plugin Fixes missing calls to getPlayState function and subscribePlayState on Mediacontrol. --- www/ConnectSDK.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) 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 */ From 9108ee752c023c8dadf60d534a8fa7f976d3ad4d Mon Sep 17 00:00:00 2001 From: Vaporexpress Date: Sun, 30 Jul 2017 12:18:36 +0200 Subject: [PATCH 2/4] Added missing getPlayState Added missing getPlayState on Android and iOS. --- src/android/JSCommandDispatcher.java | 8 ++++++++ src/ios/ConnectSDKCordovaDispatcher.m | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/android/JSCommandDispatcher.java b/src/android/JSCommandDispatcher.java index 76a7e42a..328efab7 100644 --- a/src/android/JSCommandDispatcher.java +++ b/src/android/JSCommandDispatcher.java @@ -395,6 +395,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]; From d797c534de06d388650524bb6374cbc8a0d7580a Mon Sep 17 00:00:00 2001 From: Vaporexpress Date: Sun, 30 Jul 2017 12:24:32 +0200 Subject: [PATCH 3/4] Revert "Added missing getPlayState" This reverts commit 9108ee752c023c8dadf60d534a8fa7f976d3ad4d. --- src/android/JSCommandDispatcher.java | 8 -------- src/ios/ConnectSDKCordovaDispatcher.m | 8 -------- 2 files changed, 16 deletions(-) diff --git a/src/android/JSCommandDispatcher.java b/src/android/JSCommandDispatcher.java index 328efab7..76a7e42a 100644 --- a/src/android/JSCommandDispatcher.java +++ b/src/android/JSCommandDispatcher.java @@ -395,14 +395,6 @@ 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 779e9b63..67950664 100644 --- a/src/ios/ConnectSDKCordovaDispatcher.m +++ b/src/ios/ConnectSDKCordovaDispatcher.m @@ -535,14 +535,6 @@ - (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]; From b3abb13dc7839b38d12d3acfed78a5d0e79d70e2 Mon Sep 17 00:00:00 2001 From: Vaporexpress Date: Sun, 30 Jul 2017 12:34:38 +0200 Subject: [PATCH 4/4] Added missing getPlayState Added missing getPlayState on Android and iOS. --- src/android/JSCommandDispatcher.java | 8 ++++++++ src/ios/ConnectSDKCordovaDispatcher.m | 8 ++++++++ 2 files changed, 16 insertions(+) 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];