jQuery jPlayer can't be replayed after first run in Safari

人走茶凉 提交于 2019-12-24 02:52:32

问题


After configuring and running jPlayer 2.0.0 in Firefox 3.6.13, where everthing runs smooth, the same code doesn't run in Safari 5.0.3. What i am doing is creating the jPlayer, listen for the "ended"-event to restart it. Here's the code:

$(document).ready(function(){
    $("#loopplayer").jPlayer({
        ready: function () {$(this).jPlayer("setMedia", {mp3: "/static/audio/brokentech.mp3"});
        },
        swfPath: "/static/swf",
        supplied: "mp3",
        preload: true,
        });
    $("#loopplayer").bind($.jPlayer.event.ended, function(){
      $(this).jPlayer("play" );
     });
    });

Whats happening in Safari is: the progress bar shows NaN as length of the track, and it stops after running once. When i remove the event listener and reload the page, i can run the jPlayer once (again with NaN as tracklength), after it has run once i am not able to restart it. Anything wrong with my code or a bug in jP2?


回答1:


Look here:

http://groups.google.com/group/jplayer/tree/browse_frm/month/2010-05/bb4306c1850108b1?rnum=71&_done=/group/jplayer/browse_frm/month/2010-05%3F

There are some mp3s that have problems with jPlayer due to the way files are served. The browser doesn't retrieve metadata correctly on gzipped response.




回答2:


Try to re-set the media in the ended event.

This works in Safari 7.0, which only plays the sound once and mutes for subsequent replay attempts without the hack.

$(function() {
    $('#jp').jPlayer({
        ready: function() {
            // Set the media when jPlayer is ready.
            $(this).jPlayer("setMedia", {mp3: "/audio/demo.mp3"});
        },
        ended: function() {
            // Do it again after it finishes playing.
            $(this).jPlayer("setMedia", {mp3: "/audio/demo.mp3"});
        },
    });
});



回答3:


you give the swfpath as follow or use full domain path { swfPath: "[http://localhost/jplayer/js/]", supplied: "webmv, ogv, m4v, oga, mp3" }



来源:https://stackoverflow.com/questions/4866471/jquery-jplayer-cant-be-replayed-after-first-run-in-safari

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