cordova-plugin-music-controls
Advanced tools
Comparing version 1.4.1 to 2.0.0
{ | ||
"name": "cordova-plugin-music-controls", | ||
"version": "1.4.1", | ||
"version": "2.0.0", | ||
"description": "Music controls for Cordova apps", | ||
@@ -5,0 +5,0 @@ "cordova": { |
@@ -20,7 +20,7 @@ # Cordova Music Controls Plugin | ||
track : 'Time is Running Out', // optional, default : '' | ||
artist : 'Muse', // optional, default : '' | ||
artist : 'Muse', // optional, default : '' | ||
cover : 'albums/absolution.jpg', // optional, default : nothing | ||
// cover can be a local path (use fullpath 'file:///storage/emulated/...', or only 'my_image.jpg' if my_image.jpg is in the www folder of your app) | ||
// or a remote url ('http://...', 'https://...', 'ftp://...') | ||
isPlaying : true, // optional, default : true | ||
isPlaying : true, // optional, default : true | ||
dismissable : true, // optional, default : false | ||
@@ -33,6 +33,6 @@ | ||
// iOS only, optional | ||
album : 'Absolution' // optional, default: '' | ||
duration : 60, // optional, default: 0 | ||
elapsed : 10, // optional, default: 0 | ||
// iOS only, optional | ||
album : 'Absolution', // optional, default: '' | ||
duration : 60, // optional, default: 0 | ||
elapsed : 10, // optional, default: 0 | ||
@@ -53,3 +53,5 @@ // Android only, optional | ||
function events(action) { | ||
switch(action) { | ||
const message = JSON.parse(action).message; | ||
switch(message) { | ||
case 'music-controls-next': | ||
@@ -71,6 +73,14 @@ // Do something | ||
// External controls (iOS only) | ||
case 'music-controls-toggle-play-pause' : | ||
// External controls (iOS only) | ||
case 'music-controls-toggle-play-pause' : | ||
// Do something | ||
break; | ||
case 'music-controls-seek-to': | ||
const seekToInSeconds = JSON.parse(action).position; | ||
MusicControls.updateElapsed({ | ||
elapsed: seekToInSeconds, | ||
isPlaying: true | ||
}); | ||
// Do something | ||
break; | ||
@@ -106,2 +116,12 @@ // Headset events (Android only) | ||
``` | ||
- iOS Specific Events: | ||
Allows you to listen for iOS events fired from the scrubber in control center. | ||
```javascript | ||
MusicControls.updateElapsed({ | ||
elapsed: 208, // seconds | ||
isPlaying: true | ||
}); | ||
``` | ||
- List of media button events (Android only): | ||
@@ -108,0 +128,0 @@ ```javascript |
@@ -11,15 +11,15 @@ // Copyright © 2015 filfat Studios AB | ||
case Button.play: | ||
onUpdate('music-controls-play'); | ||
onUpdate("{\"message\": \"music-controls-play\"}"); | ||
break; | ||
case Button.pause: | ||
onUpdate('music-controls-pause'); | ||
onUpdate("{\"message\": \"music-controls-pause\"}"); | ||
break; | ||
case Button.stop: | ||
onUpdate('music-controls-stop'); | ||
onUpdate("{\"message\": \"music-controls-stop\"}"); | ||
break; | ||
case Button.next: | ||
onUpdate('music-controls-next'); | ||
onUpdate("{\"message\": \"music-controls-next\"}"); | ||
break; | ||
case Button.previous: | ||
onUpdate('music-controls-previous'); | ||
onUpdate("{\"message\": \"music-controls-previous\"}"); | ||
break; | ||
@@ -51,4 +51,4 @@ } | ||
mc.playbackStatus = Windows.Media.MediaPlaybackStatus.stopped; | ||
if (!/^(f|ht)tps?:\/\//i.test(data.cover)) { | ||
@@ -55,0 +55,0 @@ var cover = new Windows.Foundation.Uri("ms-appdata://" + data.cover); |
@@ -24,2 +24,8 @@ module.exports = { | ||
}, | ||
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) { | ||
@@ -26,0 +32,0 @@ cordova.exec(successCallback, errorCallback, 'MusicControls', 'updateDismissable', [{dismissable: dismissable}]); |
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
47119
654
143