JPlayer - 使用Flash后备功能支持MP3播放列表

时间:2012-12-10 17:41:16

标签: html5 flash firefox mp3 jplayer

我是JPlayer的新手,并不知道如何使用它。我正在尝试创建一个只使用MP3文件的播放器,我知道不是每个浏览器本身都支持MP3播放,所以要播放器工作,它需要在某些情况下使用Flash后备。

目前我可以让播放器使用单个MP3,但是当添加多个MP3时,只播放第一首曲目。

这是我当前的脚本

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Player</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.6.4.js'></script>
<script type='text/javascript' src="http://www.jplayer.org/latest/js/jquery.jplayer.min.js"></script>
<script type="text/javascript" src="js/jplayer.playlist.min.js"></script>
<script type='text/javascript'>//<![CDATA[ 
$(function(){
$("#jquery_jplayer").jPlayer({
    ready: function () {
      $(this).jPlayer("setMedia", { mp3: "http://www.jplayer.org/audio/mp3/TSP-01-Cro_magnon_man.mp3" }, 
      { mp3: "http://www.jplayer.org/audio/mp3/TSP-05-Your_face.mp3" });
    },
    swfPath: "http://www.jplayer.org/latest/js/Jplayer.swf",
    supplied: "mp3",
    volume: 1,
    wmode:"window",
    solution: "html,flash",
    errorAlerts: true,
    warningAlerts: false

});
});//]]>  
</script>
</head>
<body>
<div id="jquery_jplayer"></div>
<div id="jp_container_1" class="jp-audio">
    <div class="jp-type-single">
      <div id="jp_interface_1" class="jp-interface all_rounded_corners">
        <ul class="jp-controls">
          <li><a href="#" class="jp-play pp" tabindex="1">play</a></li>
          <li><a href="#" class="jp-pause pp" tabindex="1">pause</a></li>
          <li><a href="#" class="jp-previous" tabindex="1">Previous</a></li>
          <li><a href="#" class="jp-next" tabindex="1">Next</a></li>
        </ul>
        <div class="jp-progress">
          <div class="jp-seek-bar">
            <div class="jp-play-bar"></div>
          </div>
        </div>
      </div>
    </div>
</div>
</body>
</html>

我可以说我在某个地方出了问题,但我不知道在哪里,我希望得到你的帮助。随意修改脚本以使其工作,并可能指导我一个工作的例子。

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

而不是jPlyer你需要使用jPlayerPlaylist,需要做类似下面的事情

 <!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Player</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.6.4.js'></script>
<script type='text/javascript' src="http://www.jplayer.org/latest/js/jquery.jplayer.min.js"></script>
<script type="text/javascript" src="js/jplayer.playlist.min.js"></script>

</head>
<body>
<div id="jquery_jplayer"></div>
<div id="jp_container_1" class="jp-audio">
    <div class="jp-type-single">
      <div id="jp_interface_1" class="jp-interface all_rounded_corners">
        <ul class="jp-controls">
          <li><a href="#" class="jp-play pp" tabindex="1">play</a></li>
          <li><a href="#" class="jp-pause pp" tabindex="1">pause</a></li>
          <li><a href="#" class="jp-previous" tabindex="1">Previous</a></li>
          <li><a href="#" class="jp-next" tabindex="1">Next</a></li>
        </ul>
        <div class="jp-progress">
          <div class="jp-seek-bar">
            <div class="jp-play-bar"></div>
          </div>
        </div>
      </div>
    </div>
</div>
</body>
</html>

<script type='text/javascript'>//<![CDATA[ 

var myPlaylist = null;
 $(document).ready(function () {
 myPlaylist = new jPlayerPlaylist(
                        {
                            jPlayer: "#jquery_jplayer_N",
                            cssSelectorAncestor: "#jp_container_N"
                        },
                        [
                            {
                                mp3: "http://www.jplayer.org/audio/mp3/TSP-01-Cro_magnon_man.mp3",
                            }
                        ],
                        {
                            playlistOptions: {
                                enableRemoveControls: true
                            },

                            swfPath: "http://www.jplayer.org/latest/js/Jplayer.swf",
                            supplied: "mp3",
                            solution: "html,flash"

                        });


 myPlaylist.option("autoPlay", true);

myPlaylist.add({ title: "", artist: "", mp3: "http://www.jplayer.org/audio/mp3/TSP-05-Your_face.mp3", poster: "", });
});
</script>