Search code examples
videocordovaflvmp4

Is it possible to play flv/mp4 in phonegap?


Is it possible to have a builtin player that plays flv/mp4 in phonegap? I don't want to use third party apps, just builtin player that opens links.


Solution

  • for playing flv you need third party library because non of the ios or android support it naively but for mp4 you can use phonegap media api :

     // Audio player
        //
        var my_media = new Media(src, onSuccess, onError);
    
        // Update media position every second
        var mediaTimer = setInterval(function() {
            // get media position
            my_media.getCurrentPosition(
                // success callback
                function(position) {
                    if (position > -1) {
                        console.log((position) + " sec");
                    }
                },
                // error callback
                function(e) {
                    console.log("Error getting pos=" + e);
                }
            );
        }, 1000);
    

    for more information see : http://docs.phonegap.com/en/1.0.0/phonegap_media_media.md.html