cordova-plugin-music-controls
Advanced tools
Comparing version 1.3.0 to 1.4.0
{ | ||
"name": "cordova-plugin-music-controls", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Music controls for Cordova apps", | ||
@@ -5,0 +5,0 @@ "cordova": { |
@@ -9,6 +9,5 @@ # Cordova Music Controls Plugin | ||
- Android (4.1+) | ||
- Windows (10+, by [fitfat](https://github.com/filfat)) | ||
- Windows (10+, by [filfat](https://github.com/filfat)) | ||
- iOS (by [0505gonzalez](https://github.com/0505gonzalez)) | ||
For iOS, see [shi11/RemoteControls](https://github.com/shi11/RemoteControls). | ||
## Installation | ||
@@ -22,5 +21,7 @@ `cordova plugin add https://github.com/homerours/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 | ||
isPlaying : true, // optional, default : true | ||
// 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 | ||
dismissable : true, // optional, default : false | ||
@@ -33,2 +34,7 @@ | ||
// iOS only, optional | ||
album : 'Absolution' // optional, default: '' | ||
duration : 60, // optional, default: 0 | ||
elapsed : 10, // optional, default: 0 | ||
// Android only, optional | ||
@@ -65,2 +71,7 @@ // text displayed in the status bar when the notification (and the ticker) are updated | ||
// External controls (iOS only) | ||
case 'music-controls-toggle-play-pause' : | ||
// Do something | ||
break; | ||
// Headset events (Android only) | ||
@@ -101,2 +112,1 @@ case 'music-controls-media-button' : | ||
5. Create new Pull Request | ||
@@ -71,3 +71,10 @@ // Copyright © 2015 filfat Studios AB | ||
onUpdate = _onUpdate; | ||
}, | ||
updateIsPlaying: function (successCallback, errorCallback, par) { | ||
if (par[0].isPlaying) | ||
mc.playbackStatus = Windows.Media.MediaPlaybackStatus.playing; | ||
else | ||
mc.playbackStatus = Windows.Media.MediaPlaybackStatus.stopped; | ||
mc.displayUpdater.update(); | ||
} | ||
}); |
module.exports = { | ||
updateCallback: function () {}, | ||
create: function (data, successCallback, errorCallback) { | ||
if (data.artist === undefined) { | ||
data.artist = ''; | ||
} | ||
if (data.track === undefined) { | ||
data.track = ''; | ||
} | ||
if (data.cover === undefined) { | ||
data.cover = ''; | ||
} | ||
if (data.ticker === undefined) { | ||
data.ticker = ''; | ||
} | ||
if (data.isPlaying === undefined) { | ||
data.isPlaying = true; | ||
} | ||
if (data.hasPrev === undefined) { | ||
data.hasPrev = true; | ||
} | ||
if (data.hasNext === undefined) { | ||
data.hasNext = true; | ||
} | ||
if (data.hasClose === undefined) { | ||
data.hasClose = false; | ||
} | ||
if (data.dismissable === undefined) { | ||
data.dismissable = false; | ||
} | ||
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; | ||
data.elapsed = !isUndefined(data.elapsed) ? data.elapsed : 0; | ||
data.isPlaying = !isUndefined(data.isPlaying) ? data.isPlaying : true; | ||
data.hasPrev = !isUndefined(data.hasPrev) ? data.hasPrev : true; | ||
data.hasNext = !isUndefined(data.hasNext) ? data.hasNext : true; | ||
data.hasClose = !isUndefined(data.hasClose) ? data.hasClose : false; | ||
data.dismissable = !isUndefined(data.dismissable) ? data.dismissable : false; | ||
cordova.exec(successCallback, errorCallback, 'MusicControls', 'create', [data]); | ||
}, | ||
updateIsPlaying: function (isPlaying, successCallback, errorCallback) { | ||
cordova.exec(successCallback, errorCallback, 'MusicControls', 'updateIsPlaying', [{isPlaying: isPlaying}]); | ||
}, | ||
destroy: function (successCallback, errorCallback) { | ||
cordova.exec(successCallback, errorCallback, 'MusicControls', 'destroy', []); | ||
}, | ||
// Register callback | ||
@@ -58,3 +43,7 @@ subscribe: function (onUpdate) { | ||
} | ||
}; | ||
function isUndefined(val) { | ||
return val === undefined; | ||
} |
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
39658
19
570
108