use of com.connectsdk.service.capability.MediaControl in project butter-android by butterproject.
the class BeamPlayerNotificationService method handleIntent.
private void handleIntent(Intent intent) {
if (intent == null || intent.getAction() == null) {
return;
}
String action = intent.getAction();
if (mediaControl == null) {
Intent stopIntent = new Intent(getApplicationContext(), BeamPlayerNotificationService.class);
stopService(stopIntent);
return;
}
if (action.equalsIgnoreCase(ACTION_PLAY) || action.equalsIgnoreCase(ACTION_PAUSE)) {
ResponseListener<Object> responseListener = new ResponseListener<Object>() {
@Override
public void onSuccess(Object object) {
mediaControl.getPlayState(playStateListener);
}
@Override
public void onError(ServiceCommandError error) {
mediaControl.getPlayState(playStateListener);
}
};
if (isPlaying) {
isPlaying = false;
mediaControl.pause(responseListener);
buildNotification(generateAction(R.drawable.ic_av_play, "Play", ACTION_PLAY));
} else {
isPlaying = true;
mediaControl.play(responseListener);
buildNotification(generateAction(R.drawable.ic_av_pause, "Pause", ACTION_PAUSE));
}
mediaControl.getPlayState(playStateListener);
} else if (action.equalsIgnoreCase(ACTION_FAST_FORWARD)) {
mediaControl.getPosition(new MediaControl.PositionListener() {
@Override
public void onSuccess(Long object) {
long seek = object + 10000;
mediaControl.seek(seek, null);
}
@Override
public void onError(ServiceCommandError error) {
}
});
} else if (action.equalsIgnoreCase(ACTION_REWIND)) {
mediaControl.getPosition(new MediaControl.PositionListener() {
@Override
public void onSuccess(Long object) {
long seek = object - 10000;
mediaControl.seek(seek, null);
}
@Override
public void onError(ServiceCommandError error) {
}
});
} else if (action.equalsIgnoreCase(ACTION_STOP)) {
manager.stopVideo();
}
}
Aggregations