Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mistakes on iOS and Android #63

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/android/JSCommandDispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions src/ios/ConnectSDKCordovaDispatcher.m
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,14 @@ - (void) mediaControl_getPosition:(JSCommand*)command
[mediaControl getPositionWithSuccess:command.successWithDouble failure:command.failure];
}

- (void) mediaControl_getPlayState:(JSCommand*)command
{
id<MediaControl> mediaControl = [self getMediaControl:command];
if (!mediaControl) return;

[mediaControl getPlayStateWithSuccess:command.playStateSuccess failure:command.failure];
}

- (ServiceSubscription*) mediaControl_subscribePlayState:(JSCommand*)command
{
id<MediaControl> mediaControl = [self getMediaControl:command];
Expand Down
23 changes: 18 additions & 5 deletions www/ConnectSDK.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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);
}
});

Expand Down Expand Up @@ -1771,9 +1776,17 @@ registerDeviceInterface("mediaControl",

/**
* @method
* @success {playStateCallback}
* @success {getPlayStateCallback}
*/
subscribePlayState: {}
getPlayState: {},

/**
* @method
* @success {subscribePlayState}
*/
subscribePlayState: {
subscribe: true
}
});

/** @class PlaylistControl */
Expand Down