21

我正在学习如何使用 jPlayer。我想使用 jPlayer流式传输http://u10.sky.fm:80/sky_the80s音频。

http://www.jplayer.org/1.2.0/demo-08-oggSupportFalse/演示适用于 Chrome 9。我尝试使用以下代码片段对其进行简化:

$(document).ready(function() {
  $("#jpId").jPlayer( {
    ready: function () {
      $(this).jPlayer("setFile", "http://mp3-vr-128.as34763.net:80/;stream/1", "http://ogg2.as34763.net/vr160.ogg")
      .jPlayer("play");
    },
    swfPath: "client/js",   
    volume: 60,
    oggSupport: true
  });
});

不幸的是,上述方法不起作用。我确信我错过了一些东西,因为我是 jPlayer 的新手。

任何帮助表示赞赏。在此先感谢您的帮助。

同样,理想情况下,我想流式传输http://u10.sky.fm:80/sky_the80s

昨晚在https://groups.google.com/forum/?fromgroups#!topic/jplayer/yW7WoYtrxI8上交叉发布。

更新:以下代码片段有效

$(document).ready(function() {
  $("#jpId").jPlayer( {
    ready: function () {
      $(this).jPlayer("setMedia", {
            m4a: "http://mp3-vr-128.as34763.net:80/;stream/1",
            oga: "http://ogg2.as34763.net/vr160.ogg"
      }).jPlayer("play");
      debug($(this));
    },
    supplied: "m4a, oga",
    swfPath: "client/js"    
  });
});

但我仍然无法使http://u10.sky.fm:80/sky_the80s工作。

更新 2:以下代码片段适用于 Firefox Minefield,但不适用于Chrome 9:

$(document).ready(function() {
  $("#jpId").jPlayer( {
    ready: function () {
      $(this).jPlayer("setMedia", {
              mp3: "http://u10.sky.fm:80/sky_the80s"
//            m4a: "http://mp3-a8-128.as34763.net:80/;stream/1"
//            m4a: "http://mp3-vr-128.as34763.net:80/;stream/1"
      }).jPlayer("play");
      debug($(this));
    },
    supplied: "mp3",
    swfPath: "client/js"    
  });
});
4

1 回答 1

3

Two things you could check:

Is the path to the swf correct?

Depending on the browser-capabilities jplayer chooses the playback mode (html5/flash). Try using an absolute path for the swf, includeing the file-part - eg:

swfPath:"/static/swf/jplayer.swf"

and make sure that you can access it, in your case maybe something like: http://www.sky.fm/static/swf/jplayer.swf

Do you serve the correct MIME Types?

As written in the Developer Guide you should make sure to propperly set the mimetypes. Not sure if you have an issue there. When checking the mentioned stream with:

curl http://mp3-a8-128.as34763.net:80/;stream/1 

you get:

ICY 200 OK
...
content-type:audio/mpeg
...

The manual tells that you should set audio/mp4 for m4a. (and audio/mpeg is used for mp3)

Maybe you could provide your current code with urls to running streams? This would make it easier to figure out what's going on. (The http://u10.sky.fm:80/sky_the80s does not work - at least for me...)

于 2012-04-13T13:40:22.773 回答