Fixed playback to gmediarenderer.
Calling stop before play fixes the otherwise buggy playback.
This commit is contained in:
parent
635bdb04d3
commit
2997938e18
1 changed files with 55 additions and 31 deletions
|
@ -77,6 +77,7 @@ public class RemotePlayServiceBinder extends IRemotePlayService.Stub {
|
||||||
|
|
||||||
private RemotePlayService mRps;
|
private RemotePlayService mRps;
|
||||||
|
|
||||||
|
private boolean mStartingPlayback = false;
|
||||||
public RemotePlayServiceBinder(RemotePlayService rps) {
|
public RemotePlayServiceBinder(RemotePlayService rps) {
|
||||||
mRps = rps;
|
mRps = rps;
|
||||||
}
|
}
|
||||||
|
@ -118,7 +119,7 @@ public class RemotePlayServiceBinder extends IRemotePlayService.Stub {
|
||||||
LastChange lastChange = new LastChange(
|
LastChange lastChange = new LastChange(
|
||||||
new AVTransportLastChangeParser(),
|
new AVTransportLastChangeParser(),
|
||||||
m.get("LastChange").toString());
|
m.get("LastChange").toString());
|
||||||
if (lastChange.getEventedValue(0,
|
if (mStartingPlayback || lastChange.getEventedValue(0,
|
||||||
AVTransportVariable.TransportState.class) == null)
|
AVTransportVariable.TransportState.class) == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -203,29 +204,48 @@ public class RemotePlayServiceBinder extends IRemotePlayService.Stub {
|
||||||
* current renderer.
|
* current renderer.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void play(String uri, String metadata) throws RemoteException {
|
public void play(final String uri, final String metadata) throws RemoteException {
|
||||||
|
mStartingPlayback = true;
|
||||||
mPlaybackState = MediaItemStatus.PLAYBACK_STATE_BUFFERING;
|
mPlaybackState = MediaItemStatus.PLAYBACK_STATE_BUFFERING;
|
||||||
mRps.mUpnpService.getControlPoint().execute(new SetAVTransportURI(
|
mRps.mUpnpService.getControlPoint().execute(
|
||||||
mRps.getService(mCurrentRenderer, "AVTransport"),
|
new Stop(mRps.getService(mCurrentRenderer, "AVTransport")) {
|
||||||
uri, metadata) {
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
public void failure(ActionInvocation invocation,
|
public void failure(ActionInvocation invocation,
|
||||||
UpnpResponse operation, String defaultMsg) {
|
org.teleal.cling.model.message.UpnpResponse operation,
|
||||||
Log.w(TAG, "Set URI failed: " + defaultMsg);
|
String defaultMessage) {
|
||||||
mRps.sendError("Set URI failed: " + defaultMsg);
|
Log.w(TAG, "Stop failed: " + defaultMessage);
|
||||||
|
mRps.sendError("Stop failed: " + defaultMessage);
|
||||||
|
mStartingPlayback = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
public void success(ActionInvocation invocation) {
|
public void success(ActionInvocation invocation) {
|
||||||
|
mRps.mUpnpService.getControlPoint().execute(new SetAVTransportURI(
|
||||||
|
mRps.getService(mCurrentRenderer, "AVTransport"),
|
||||||
|
uri, metadata) {
|
||||||
|
@Override
|
||||||
|
public void failure(ActionInvocation invocation,
|
||||||
|
UpnpResponse operation, String defaultMsg) {
|
||||||
|
Log.w(TAG, "Set URI failed: " + defaultMsg);
|
||||||
|
mRps.sendError("Set URI failed: " + defaultMsg);
|
||||||
|
mStartingPlayback = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void success(ActionInvocation invocation) {
|
||||||
|
// Can't use resume here as we don't have the session id to call.
|
||||||
mRps.mUpnpService.getControlPoint().execute(
|
mRps.mUpnpService.getControlPoint().execute(
|
||||||
new Play(mRps.getService(mCurrentRenderer,
|
new Play(mRps.getService(mCurrentRenderer,
|
||||||
"AVTransport")) {
|
"AVTransport")) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void success(ActionInvocation invocation) {
|
public void success(ActionInvocation invocation) {
|
||||||
|
Log.d(TAG, "play success");
|
||||||
mPlaybackState = MediaItemStatus.PLAYBACK_STATE_PLAYING;
|
mPlaybackState = MediaItemStatus.PLAYBACK_STATE_PLAYING;
|
||||||
|
mStartingPlayback = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -233,11 +253,15 @@ public class RemotePlayServiceBinder extends IRemotePlayService.Stub {
|
||||||
UpnpResponse operation, String defaultMessage) {
|
UpnpResponse operation, String defaultMessage) {
|
||||||
Log.w(TAG, "Play failed: " + defaultMessage);
|
Log.w(TAG, "Play failed: " + defaultMessage);
|
||||||
mRps.sendError("Play failed: " + defaultMessage);
|
mRps.sendError("Play failed: " + defaultMessage);
|
||||||
|
mStartingPlayback = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pauses playback on current renderer.
|
* Pauses playback on current renderer.
|
||||||
|
|
Reference in a new issue