Cordova Music Controls Plugin
Music controls for Cordova applications. Display a 'media' notification with play/pause, previous, next buttons, allowing the user to control the play. Handle also headset event (plug, unplug, headset button).
Supported platforms
- Android (4.1+)
- Windows (10+, by fitfat)
For iOS, see shi11/RemoteControls.
Installation
cordova plugin add https://github.com/homerours/cordova-music-controls-plugin
Methods
- Create the media controls:
MusicControls.create({
track : 'Time is Running Out',
artist : 'Muse',
cover : 'albums/absolution.jpg',
isPlaying : true,
ticker : 'Now playing "Time is Running Out"'
}, onSuccess, onError);
- Destroy the media controller:
MusicControls.destroy(onSuccess, onError);
- Subscribe events to the media controller:
function events(action) {
switch(action) {
case 'music-controls-next':
break;
case 'music-controls-previous':
break;
case 'music-controls-pause':
break;
case 'music-controls-play':
break;
case 'music-controls-media-button' :
break;
case 'music-controls-headset-unplugged':
break;
case 'music-controls-headset-plugged':
break;
default:
break;
}
}
MusicControls.subscribe(events);
MusicControls.listen();
MusicControls.updateIsPlaying(true);
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request