我正在尝试使用以下代码在JPlayer中设置mp3声音:
$("#jquery_jplayer_2").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
title: "welcome",
mp3: "C:\Users\test\Desktop\test.mp3"
});
},
cssSelectorAncestor: "#jp_container_2",
swfPath: "/js",
supplied: "mp3",
useStateClassSkin: true,
autoBlur: false,
smoothPlayBar: true,
keyEnabled: true,
remainingDuration: true,
toggleDuration: true,
error: function (event) {
if (event.jPlayer.error.type === $.jPlayer.error.URL) {
alert("Not found");
}
}
});
当我知道mp3位置正确时,它会在窗口中显示“Not found”。
答案 0 :(得分:0)
最近面临这个问题。您的代码不起作用,因为jplayer无法从文件系统访问文件。
您需要使用某种类型的网络服务器(如nginx)来提供媒体文件,或者使用控制器中的方法来读取文件和返回流。