use of com.lzx.musiclibrary.MusicService in project MusicLibrary by lizixian18.
the class PlayerReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (TextUtils.isEmpty(action)) {
return;
}
MusicService musicService = MusicService.getService();
if (musicService == null) {
return;
}
PlayControl binder = musicService.getBinder();
if (binder == null) {
return;
}
PlayController controller = binder.getController();
if (controller == null) {
return;
}
switch(action) {
case IMediaNotification.ACTION_CLOSE:
controller.stopMusic();
controller.stopNotification();
break;
case IMediaNotification.ACTION_PLAY_PAUSE:
if (controller.getState() == State.STATE_PLAYING) {
controller.pauseMusic();
} else if (controller.getState() == State.STATE_PAUSED) {
controller.resumeMusic();
}
break;
case IMediaNotification.ACTION_PREV:
controller.playPre();
break;
case IMediaNotification.ACTION_NEXT:
controller.playNext();
break;
default:
break;
}
}
use of com.lzx.musiclibrary.MusicService in project NiceMusic by lizixian18.
the class PlayerReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (TextUtils.isEmpty(action)) {
return;
}
MusicService musicService = MusicService.getService();
if (musicService == null) {
return;
}
PlayControl binder = musicService.getBinder();
if (binder == null) {
return;
}
PlayController controller = binder.getController();
if (controller == null) {
return;
}
switch(action) {
case IMediaNotification.ACTION_CLOSE:
controller.stopMusic();
controller.stopNotification();
break;
case IMediaNotification.ACTION_PLAY_PAUSE:
if (controller.getState() == State.STATE_PLAYING) {
controller.pauseMusic();
} else if (controller.getState() == State.STATE_PAUSED) {
controller.resumeMusic();
}
break;
case IMediaNotification.ACTION_PREV:
controller.playPre();
break;
case IMediaNotification.ACTION_NEXT:
controller.playNext();
break;
default:
break;
}
}
Aggregations