cordova-plugin-multi-player
This plugin provides an implementation of an Android service library which uses Google's ExoPlayer. Ready to use Streaming Player Service. (Background Player Service).
This plugin has part of its code base on cordova-plugin-exoplayer, with a focus on audio streaming and keeping the audio active on background.
Supported Platforms
Installation
cordova plugin add cordova-plugin-multi-player
Optional dependency
It's recommended to use the plugin cordova-plugin-music-controls2, since instead of creating a generic notification, to inform the user that there is a service in background, it uses the music controls plugin notification to do so.
cordova plugin add cordova-plugin-music-controls2
Quick Example
...
onDeviceReady: function() {
var url = 'http://hayatmix.net/;yayin.mp3.m3u';
navigator.multiPlayer.initialize(
function (s) {
console.log('SUCCESS navigator.multiPlayer.initialize');
if (s == 'CONNECTED') {
} else if (s == 'DISCONNECTED') {
} else if (s == 'LOADING') {
} else if (s == 'STARTED') {
} else if (s == 'STOPPED') {
} else if (s == 'STOPPED_FOCUS_TRANSIENT') {
} else if (s == 'STARTED_FOCUS_TRANSIENT') {
} else if (s == 'STOPPED_FOCUS_LOSS') {
} else if (s == 'ERROR') {
}
},
function (e) {
console.log('ERROR navigator.multiPlayer.initialize');
},
url,
true,
5000
);
}
...
var streamType = navigator.multiPlayer.STREAM_ALARM;
navigator.multiPlayer.play(function (s) {
console.log('SUCCESS navigator.multiPlayer.play');
}, function (e) {
console.log('ERROR navigator.multiPlayer.play');
}, streamType);
navigator.multiPlayer.stop(function (s) {
console.log('SUCCESS navigator.multiPlayer.stop');
}, function (e) {
console.log('ERROR navigator.multiPlayer.stop');
});
navigator.multiPlayer.connect(function (s) {
console.log('SUCCESS navigator.multiPlayer.connect');
}, function (e) {
console.log('ERROR navigator.multiPlayer.connect');
});
navigator.multiPlayer.disconnect(function (s) {
console.log('SUCCESS navigator.multiPlayer.disconnect');
}, function (e) {
console.log('ERROR navigator.multiPlayer.disconnect');
});
Log Debug
adb logcat -s "LOG" -s "MultiPlayer"
Libraries Used
ExoPlayer Library