Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is mediaelement.js compatible with Phonegap?

I am building a phonegap application where i need to use video and audio streaming feature, i found that mediaelementjs seems more suitable for cross platform video and audio feature.

I created one demo and its working fine on iOS & Android browsers, but when i prepared phonegap build its not playing video or audio on android device.

Is mediaelement.js compatible with phonegap?if no then is there any other video\audio player plugin available which can use with phonegap, instead of using phonegap Media API.

Thanks Suresh

like image 447
Suresh Avatar asked May 27 '15 12:05

Suresh


1 Answers

Is mediaelement.js compatible with phonegap?

Yes, they are compatible.

I have seen them used together on projects. PhoneGap can be difficult to configure properly to work with other JS libraries b/c of the extent to which PhoneGap binds its own events to manage the environment.

Without knowing more about your specific problem, I can't help you further than to assure you that they can work together and that there are pains with configuration and managing dependencies. I recommend using a mangement library like Require.JS to help manage the dependencies.

is there any other video\audio player plugin available which can use with phonegap, instead of using phonegap Media API?

Yes, infact PhoneGap has a Media API for playing and recording audio files

The advantage of PG is how much effort the contributors invested into making apps work with native drivers and tools. You will have an easier time (in general) relying on PG API's when possible.

documentation for PhoneGap media

Example playing an audio file from an URL:

Markup:

    <a href="#" class="btn large" onclick="playAudio('http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3');">Play Audio</a>
    <a href="#" class="btn large" onclick="pauseAudio();">Pause Playing Audio</a>
    <a href="#" class="btn large" onclick="stopAudio();">Stop Playing Audio</a>
    <p id="audio_position"></p>

JavaScript:

// Play audio
//
function playAudio(url) {
    // Play the audio file at url
    var my_media = new Media(url,
        // success callback
        function () {
            console.log("playAudio():Audio Success");
        },
        // error callback
        function (err) {
            console.log("playAudio():Audio Error: " + err);
        }
    );
    // Play audio
    my_media.play();
}

The functionality included is extensive and robust, including tools for setting Volume, Play Position, Releasing media resources when finished.

There are many Android Video-Player plug-ins for PhoneGap:

VideoPlayer plugin for Phonegap

Adobe's Video Player for PhoneGap Android

This HTML 5 video-player seems to support all platforms:

HTML 5 Video player for Phone Gap

like image 92
Dave Alperovich Avatar answered Oct 16 '22 07:10

Dave Alperovich