Is mediaelement.js compatible with Phonegap?

六眼飞鱼酱① 提交于 2019-12-23 07:13:33

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/30483187/is-mediaelement-js-compatible-with-phonegap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!