开发者

Safari and Chrome crash when running this jquery script

I am not sure why my site crashes, but for some reason I am able to get to crash every time when preforming a search and returning html5 audio results.

The user searches our database and music is delivered. I am not able to get it to crash in FF, but in Chrome and Safari.

$('.audioplayerHTML5').live('click', function(event) {

        var audio = '';
        var playbutton = '';
        var video = $('.videoplayer').get(0);
        var $syncMusic = $('#syncMusic');
        var $last_played = $('#last_played');
        var $playAudioBeginning = $('#playAudioBeginning');
        var $playFromBeginning = $('#playFromBeginning');
        var $sliderVideo = $('#sliderVideo');


        if ($.browser.mozilla) {
            playbutton = event.layerX < 31;
        } else if ($.browser.safari) {
            playbutton = event.offsetX < 61;
        } else if ($.browser.webkit) {
            playbutton = event.offsetX < 31;
        }

        if (!playbutton) return;
        if (!this.paused) {
            pause(this, $syncMusic.is(':checked') ? video : null);
        } else if (this.paused) {
            //this.play();
            if (!$last_played.val()) {
                $last_played.val(this.id);
                if ($syncMusic.is(':checked') && video) {
                    if ($playFromBeginning.is(':checked') && !video.paused) {
                        video.currentTime =  document.getElementById("offsetVideo").value;
                    } else {
                        video.play();
                    }
                }
                if ($playAudioBeginning.is(':checked')) {
                    this.currentTime = 0;
                }
                this.play();
            } else if ($last_played.val() !== this.id) {
                audio = $('#' + $last_played.val()).get(0);

                if (!audio) {
                    $last_played.val(this.id);
                    if ($syncMusic.is(':checked') && video) {
                        if ($playFromBeginning.is(':checked') && !video.paused) {
                            video.currentTime =  document.getElementById("offsetVideo").value;
                        } else {
                            video.play();
                        }
                    }
                    if ($playAudioBeginning.is(':checked')) {
                        this.currentTime = 0;
                    }
                    this.play();
                } else {
                    audio.pause();
                    $last_played.val(this.id);
                    if ($syncMusic.is(':checked') && video) {
                        if ($playFromBeginning.is(':checked') && !video.paused) {
                            video.currentTime =  document.getElementById("offsetVideo").value;
                        } else {
                            video.play();
                        }
                    }
                    if ($playAudioBeginning.is(':checked')) {
                        this.currentTime = 0;
                    }

                    this.play();
                }
            } else if ($last_played.val() == this.id) {
                if ($syncMusic.is(':checked') && video) {
                    if ($playFromBeginning.is(':checked') && !video.paused) {
                        video.currentTime =  document.getElementById("offsetVideo").value;
                    } else {
                        video.play();
                    }
                }
                if ($playAudioBeginning.is(':checked')) {
                    this.currentTime = 0;
                }
                this.play();
            }
        }
    });开发者_C百科

REFERENCE: jQuery .live and WebKit are crashing http://code.google.com/p/chromium/issues/detail?id=79685


well do you check the browser and output ogg or mp3 if the browser supports it? think a plugin crashes the browser?


Check out this The problem with Html5 audio

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜