Cordova Audio Controller Plugin
Thanks
This plugin is partly inspired by https://github.com/homerours/cordova-music-controls-plugin repository. It is not updated on NPM anymore so I took the liberty to rewrite objective C code and push it with a different name.
Major diffferences
- Removed the listen() method (it is now automatic)
- Fixed a lot of bugs on IOS
- Added a Audio interruption event on IOS
- Removed the updateIsPlaying method and destroy on IOS (for now)
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
Installation
cordova plugin add https://github.com/bhvr-business-solutions/cordova-plugin-audiocontroller
Methods
- Replace the media controls:
AudioController.setControls({
track : 'Time is Running Out',
artist : 'Muse',
cover : 'albums/absolution.jpg',
isPlaying : true,
hasPrev : true,
hasNext : true,
album : 'Absolution',
album : 'Absolution',
duration : 60,
elapsed : 10,
hasSkipForward : true,
hasSkipBackward : true,
skipForwardInterval : 15,
skipBackwardInterval : 15,
hasScrubbing : false,
ticker : 'Now playing "Time is Running Out"',
playIcon: 'media_play',
pauseIcon: 'media_pause',
prevIcon: 'media_prev',
nextIcon: 'media_next',
closeIcon: 'media_close',
notificationIcon: 'notification'
});
- Subscribe events to the media controller:
AudioController.subscribe(function(eventName) {
});
List of media button events
'play', 'pause',
'previous', 'next', 'pause', 'play',
'skip-backward', 'skip-forward'
'interruption-started', 'interruption-ended', 'seek' (2nd argument available)
'fast-forward', 'rewind',
'play-pause', 'stop',
'step-backward', 'step-forward',
'meta-left', 'meta-right', 'music',
'volume-up', 'volume-down', 'volume-mute',
'headset-hook'
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
Thanks !