Fixing jPlayer android 2.3 not playing bug

Posted by | May 24, 2012 | JavaScript | No Comments

jPlayer is really grate because it is easy to integrate, well good documented, it has support for almost all browsers even for iOS and Android. Still it has some issues on Android; in my case I have experienced them on Android 2.3. It happens that on using the play function the player crash and stop working until you refresh the page, this is happening because it tries to read the media duration before the media header is fully loaded. I have solved this problem by directly hacking the code and added a delay on play function. The fix may look like:

play: function(time) {
 
        time = (typeof time === "number") ? time : NaN; // Remove jQuery event from click handler
        if(this.status.srcSet) {
            if(this.html.active) {
 
                var __player=this;
                var interval=setTimeout(function(){
                // Ugly fix for Android, but hell yeah... it works  
                __player._html_play(time);
                clearTimeout(interval);
                },4000);
 
 
            } else if(this.flash.active) {
                this._flash_play(time);
            }
        } else {
            this._urlNotSetError("play");
        }
    },

About Andrei Tara

Andrei is a developer/geek who loves creating high quality and efficient applications, always following the best practices in software engineering. He loves the challenge of learning new, exciting things and playing with new languages, frameworks, and tools.

Leave a Reply