npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-multi-player

v2.1.4

Published

Streaming Plugin

Downloads

69

Readme

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

  • Android
  • Browser (new)
  • iOS (not tested, use at your own risk)

Requirements

Starting to version 2.1.0, requires cordova@8, cordova-android@8 and the use of androidx (required for the latest ExoPlayer version, that is not yet available on cordova). To complain with androidx requirements (if not available yet), you can install the plugins cordova-plugin-androidx and cordova-plugin-androidx-adapter with:

cordova plugin add cordova-plugin-androidx
cordova plugin add cordova-plugin-androidx-adapter

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') {
                // the service responsible for playing was connected
            } else if (s == 'DISCONNECTED') {
                // the service responsible for playing was disconnected
            } else if (s == 'LOADING') {
                // the media is loading (called once every play call, not called on buffering content)
            } else if (s == 'STARTED') {
                // the media was successfully started playing
            } else if (s == 'STOPPED') {
                // the media was stopped
            } else if (s == 'STOPPED_FOCUS_LOSS') {
                // the media was stopped after other app requested focus (Android only)
            } else if (s == 'ERROR') {
                // the media raised an error
            }
        },
        function (e) {
            console.log('ERROR navigator.multiPlayer.initialize');
        },
        // streaming url
        url,
        // Android Only (optional):
        //   on android 11+ usign MusicControls plugin, disconnect may not end the service and/or notification,
        //   this flag force cancel the MusicControls notification when the service is destroyed, enabling to terminate the process properlly
        true
    );
}
...

// valid constants are 'STREAM_MUSIC' and 'STREAM_ALARM' (default: STREAM_MUSIC)
var streamType = navigator.multiPlayer.STREAM_ALARM;

// streamType parameter is not required
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');
});

// initialize the service responsible for playing the stream
// this is not required, since its automatically connected when is called the play action
navigator.multiPlayer.connect(function (s) {
    console.log('SUCCESS navigator.multiPlayer.connect');
}, function (e) {
    console.log('ERROR navigator.multiPlayer.connect');
});

// close the service responsible for playing the stream
// this is not required, since its automatically disconnected when the app is closed
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