改变对jPlayer歌曲通过单击链接,托管在亚马逊S3 [英] Changing songs on jPlayer by clicking a link, hosted on Amazon S3
问题描述
您好所有和感谢提前任何帮助。
Hello all and thanks for any help in advance.
我在Rails应用程序中,我试图通过jPlayer,这是托管在S3传输音频红宝石。到目前为止,我没有问题,上传文件,或使用内置的播放器在浏览器中播放的音频文件,甚至让jPlayer初始化一首歌是在S3上。当我进入改变歌曲的问题来了。
I have a ruby on rails application in which I am attempting to stream audio through jPlayer, which is hosted on S3. So far I have no problem uploading files or using the browsers built in player to play audio files, or even getting jPlayer to initialize with a song that is on S3. The issue comes when I get into changing songs.
我初始化jPlayer是这样的:
I initialize jPlayer like this:
$('a.html5').click(function() {
var url = $(this).attr('href');
$("#jquery_jplayer_1").jPlayer({
ready: function (event) {
$(this).jPlayer("setMedia", {
mp3: url
});
},
swfPath: "javascripts",
supplied: "mp3",
wmode: "window"
});
return false;
});
,其中MP3:URL指向S3 URL(这一切工作就好了)
where the mp3: url points to the S3 URL (this all works just fine).
这使我从一个链接列表中选择一首歌曲,它加载并开始播放没有问题。
This allows me to select a song from a list of links, and it loads up and starts playing no problem.
问题是,当我尝试改变的歌曲,我得到一个访问控制 - 允许原产地的错误。因此,我试过如下:
The issue is that when I try to change songs, I get an access-control-allow-origin error. So I tried the following:
$('a.html5').click(function() {
var url = $(this).attr('href');
$("#jquery_jplayer_1").jPlayer("setMedia", mp3: url).jPlayer("play");
return false;
});
这仍然给我一个访问控制使原产地的错误。我一直在敲打我的头靠在墙上几个小时试图弄清楚这一点并没有什么。
This still gives me an access-control-allow-origin error. I have been pounding my head against the wall for hours trying to figure this out and nothing.
因此,基本上一个总结,我可以初始化jPlayer和播放一首歌曲就好了,但是当我想去换一首歌,访问控制,使原产地的错误毁了我的一天。
So basically a summary is that I can initialize jPlayer and play a song just fine, but when I want to go change a song, access-control-allow-origin errors ruin my day.
任何想法?
推荐答案
那么它看来,唯一的问题是缺乏括号的MP3:jPlayer的URL部分(setMedia......
Well it appears that the only issue was a lack of brackets around the mp3: url part of jPlayer("setMedia"....
所以它应该是(...)jPlayer(setMedia,{MP3:URL})。(...)
这篇关于改变对jPlayer歌曲通过单击链接,托管在亚马逊S3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!