cordova-music-remote-controls
Supported platforms
Methods
- Create the media controls:
function remoteCommandCallback(event,value){
switch(event){
case MusicControls.EVENT_PLAY:
console.log("######### remoteCommandCallback, event: PLAY");
break;
case MusicControls.EVENT_PAUSE:
console.log("######### remoteCommandCallback, event: PAUSE");
break;
case MusicControls.EVENT_TOGGLE_PLAY_PAUSE:
console.log("######### remoteCommandCallback, event: TOGGLE PLAY PAUSE");
break;
case MusicControls.EVENT_SKIP_FORWARD:
console.log("######### remoteCommandCallback, event: SKIP FW");
break;
case MusicControls.EVENT_SKIP_BACKWARD:
console.log("######### remoteCommandCallback, event: SKIP BW");
break;
}
}
var info = {
title : 'Title',
artist : 'Artist',
artwork : 'albums/cover.jpg',
isPlaying : true,
dismissable : true,
hasPrev : false,
hasNext : false,
hasClose : true,
ticker : 'Now playing "Time is Running Out"' [Android]
albumTrackCount :10,
albumTrackNumber :1,
playbackDuration :234.76,
playbackPosition :12.5,
playbackRate :1.0,
skipForwardValue :30,
skipBackwardValue :30
};
var mControl = new MusicControls(info,remoteCommandCallback);
mControl.subscribe(remoteCommandCallback);
mControl.listen();
- Destroy the media controller:
mControl.destroy(clearInfo);
updateIsPlaying(true): Toggle the play/pause notification button [Android]
updateInfo(info): Updates the information shown in the lock screen.
updatePlaybackRate(newPlaybackRate): Updates (only) the playback rate. Uses updateInfo internally [iOS].
updatePlaybackPosition(newPlaybackPosition): Updates (only) the playback position. Uses updateInfo internally [iOS].