cordova-plugin-music-controls
Advanced tools
Comparing version 2.0.0 to 2.1.4
{ | ||
"name": "cordova-plugin-music-controls", | ||
"version": "2.0.0", | ||
"version": "2.1.4", | ||
"description": "Music controls for Cordova apps", | ||
"cordova": { | ||
"id": "cordova-plugin-music-controls", | ||
"platforms": [ | ||
"android", | ||
"windows" | ||
] | ||
"platforms": ["android", "windows", "ios"] | ||
}, | ||
@@ -39,3 +36,4 @@ "repository": { | ||
}, | ||
"homepage": "https://github.com/homerours/cordova-music-controls-plugin#readme" | ||
"homepage": | ||
"https://github.com/homerours/cordova-music-controls-plugin#readme" | ||
} |
# Cordova Music Controls Plugin | ||
<img src='https://github.com/homerours/cosmic/blob/master/screenshots/notification.png' width='564' height='342'> | ||
<img src='https://imgur.com/fh3ACOq.png' width='564' height='342'> | ||
@@ -10,3 +10,3 @@ 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). | ||
- Windows (10+, by [filfat](https://github.com/filfat)) | ||
- iOS (by [0505gonzalez](https://github.com/0505gonzalez)) | ||
- iOS 8+ (by [0505gonzalez](https://github.com/0505gonzalez)) | ||
@@ -35,8 +35,21 @@ ## Installation | ||
album : 'Absolution', // optional, default: '' | ||
duration : 60, // optional, default: 0 | ||
elapsed : 10, // optional, default: 0 | ||
duration : 60, // optional, default: 0 | ||
elapsed : 10, // optional, default: 0 | ||
hasSkipForward : true, //optional, default: false. true value overrides hasNext. | ||
hasSkipBackward : true, //optional, default: false. true value overrides hasPrev. | ||
skipForwardInterval : 15, //optional. default: 0. | ||
skipBackwardInterval : 15, //optional. default: 0. | ||
hasScrubbing : false, //optional. default to false. Enable scrubbing from control center progress bar | ||
// Android only, optional | ||
// text displayed in the status bar when the notification (and the ticker) are updated | ||
ticker : 'Now playing "Time is Running Out"' | ||
ticker : 'Now playing "Time is Running Out"', | ||
//All icons default to their built-in android equivalents | ||
//The supplied drawable name, e.g. 'media_play', is the name of a drawable found under android/res/drawable* folders | ||
playIcon: 'media_play', | ||
pauseIcon: 'media_pause', | ||
prevIcon: 'media_prev', | ||
nextIcon: 'media_next', | ||
closeIcon: 'media_close', | ||
notificationIcon: 'notification' | ||
}, onSuccess, onError); | ||
@@ -80,3 +93,3 @@ ``` | ||
elapsed: seekToInSeconds, | ||
isPlaying: true | ||
isPlaying: true | ||
}); | ||
@@ -125,4 +138,10 @@ // Do something | ||
- List of media button events (Android only): | ||
## List of media button events | ||
- Default: | ||
```javascript | ||
'music-controls-media-button' | ||
``` | ||
- Android only: | ||
```javascript | ||
'music-controls-media-button-next', 'music-controls-media-button-pause', 'music-controls-media-button-play', | ||
@@ -135,5 +154,7 @@ 'music-controls-media-button-play-pause', 'music-controls-media-button-previous', 'music-controls-media-button-stop', | ||
'music-controls-media-button-headset-hook' | ||
``` | ||
// Default: | ||
'music-controls-media-button' | ||
- iOS Only: | ||
```javascript | ||
'music-controls-skip-forward', 'music-controls-skip-backward' | ||
``` | ||
@@ -140,0 +161,0 @@ |
@@ -1,10 +0,10 @@ | ||
module.exports = { | ||
updateCallback: function () {}, | ||
var musicControls = { | ||
updateCallback: function() {}, | ||
create: function (data, successCallback, errorCallback) { | ||
data.artist = !isUndefined(data.artist) ? data.artist : ''; | ||
data.track = !isUndefined(data.track) ? data.track : ''; | ||
data.album = !isUndefined(data.album) ? data.album : ''; | ||
data.cover = !isUndefined(data.cover) ? data.cover : ''; | ||
data.ticker = !isUndefined(data.ticker) ? data.ticker : ''; | ||
create: function(data, successCallback, errorCallback) { | ||
data.artist = !isUndefined(data.artist) ? data.artist : ""; | ||
data.track = !isUndefined(data.track) ? data.track : ""; | ||
data.album = !isUndefined(data.album) ? data.album : ""; | ||
data.cover = !isUndefined(data.cover) ? data.cover : ""; | ||
data.ticker = !isUndefined(data.ticker) ? data.ticker : ""; | ||
data.duration = !isUndefined(data.duration) ? data.duration : 0; | ||
@@ -15,40 +15,88 @@ data.elapsed = !isUndefined(data.elapsed) ? data.elapsed : 0; | ||
data.hasNext = !isUndefined(data.hasNext) ? data.hasNext : true; | ||
data.hasSkipForward = !isUndefined(data.hasSkipForward) ? data.hasSkipForward : false; | ||
data.hasSkipBackward = !isUndefined(data.hasSkipBackward) ? data.hasSkipBackward : false; | ||
data.hasScrubbing = !isUndefined(data.hasScrubbing) ? data.hasScrubbing : false; | ||
data.skipForwardInterval = !isUndefined(data.skipForwardInterval) ? data.skipForwardInterval : 0; | ||
data.skipBackwardInterval = !isUndefined(data.skipBackwardInterval) ? data.skipBackwardInterval : 0; | ||
data.hasClose = !isUndefined(data.hasClose) ? data.hasClose : false; | ||
data.dismissable = !isUndefined(data.dismissable) ? data.dismissable : false; | ||
data.playIcon = !isUndefined(data.playIcon) ? data.playIcon : ""; | ||
data.pauseIcon = !isUndefined(data.pauseIcon) ? data.pauseIcon : ""; | ||
data.prevIcon = !isUndefined(data.prevIcon) ? data.prevIcon : ""; | ||
data.nextIcon = !isUndefined(data.nextIcon) ? data.nextIcon : ""; | ||
data.closeIcon = !isUndefined(data.closeIcon) ? data.closeIcon : ""; | ||
data.notificationIcon = !isUndefined(data.notificationIcon) ? data.notificationIcon : ""; | ||
cordova.exec(successCallback, errorCallback, 'MusicControls', 'create', [data]); | ||
cordova.exec(successCallback, errorCallback, "MusicControls", "create", [ | ||
data | ||
]); | ||
}, | ||
updateIsPlaying: function (isPlaying, successCallback, errorCallback) { | ||
cordova.exec(successCallback, errorCallback, 'MusicControls', 'updateIsPlaying', [{isPlaying: isPlaying}]); | ||
updateIsPlaying: function(isPlaying, successCallback, errorCallback) { | ||
cordova.exec( | ||
successCallback, | ||
errorCallback, | ||
"MusicControls", | ||
"updateIsPlaying", | ||
[{ isPlaying: isPlaying }] | ||
); | ||
}, | ||
updateElapsed: function (args, successCallback, errorCallback) { | ||
cordova.exec(successCallback, errorCallback, 'MusicControls', 'updateElapsed', [{ | ||
elapsed: args.elapsed, | ||
isPlaying: (args.isPlaying === undefined) ? '' : !!args.isPlaying | ||
}]); | ||
updateElapsed: function(args, successCallback, errorCallback) { | ||
cordova.exec( | ||
successCallback, | ||
errorCallback, | ||
"MusicControls", | ||
"updateElapsed", | ||
[ | ||
{ | ||
elapsed: args.elapsed, | ||
isPlaying: args.isPlaying === undefined ? "" : !!args.isPlaying | ||
} | ||
] | ||
); | ||
}, | ||
updateDismissable: function (dismissable, successCallback, errorCallback) { | ||
cordova.exec(successCallback, errorCallback, 'MusicControls', 'updateDismissable', [{dismissable: dismissable}]); | ||
updateDismissable: function(dismissable, successCallback, errorCallback) { | ||
cordova.exec( | ||
successCallback, | ||
errorCallback, | ||
"MusicControls", | ||
"updateDismissable", | ||
[{ dismissable: dismissable }] | ||
); | ||
}, | ||
destroy: function (successCallback, errorCallback) { | ||
cordova.exec(successCallback, errorCallback, 'MusicControls', 'destroy', []); | ||
destroy: function(successCallback, errorCallback) { | ||
cordova.exec( | ||
successCallback, | ||
errorCallback, | ||
"MusicControls", | ||
"destroy", | ||
[] | ||
); | ||
}, | ||
// Register callback | ||
subscribe: function (onUpdate) { | ||
module.exports.updateCallback = onUpdate; | ||
subscribe: function(onUpdate) { | ||
musicControls.updateCallback = onUpdate; | ||
}, | ||
// Start listening for events | ||
listen: function () { | ||
cordova.exec(module.exports.receiveCallbackFromNative, function (res) { | ||
}, 'MusicControls', 'watch', []); | ||
listen: function() { | ||
cordova.exec( | ||
musicControls.receiveCallbackFromNative, | ||
function(res) {}, | ||
"MusicControls", | ||
"watch", | ||
[] | ||
); | ||
}, | ||
receiveCallbackFromNative: function (messageFromNative) { | ||
module.exports.updateCallback(messageFromNative); | ||
cordova.exec(module.exports.receiveCallbackFromNative, function (res) { | ||
}, 'MusicControls', 'watch', []); | ||
receiveCallbackFromNative: function(messageFromNative) { | ||
musicControls.updateCallback(messageFromNative); | ||
cordova.exec( | ||
musicControls.receiveCallbackFromNative, | ||
function(res) {}, | ||
"MusicControls", | ||
"watch", | ||
[] | ||
); | ||
} | ||
}; | ||
@@ -59,1 +107,3 @@ | ||
} | ||
module.exports = musicControls; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
54782
738
164
18