感谢您提前提供的任何帮助。
所以,我使用 Paperclip 将歌曲存储在文件系统中。然后我尝试用 jPlayer 播放这些歌曲。
我已遵循所有指示,但似乎无法通过单击应该将音频解析为 jPlayer 的 link_to 方法来播放音频。
基本上,当单击“播放歌曲”按钮时应该播放歌曲。
我的 jPlayer 函数如下所示:
$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
mp3: '<source>'
});
},
swfPath: "jplayerflash",
supplied: "mp3",
});
});
我的观点如下:
<td><%= link_to 'Play Song', song_upload.song.url, :class => "html5" %></td>
音频文件通过回形针存储在 asset/user_song_uploads... 这些歌曲都是 MP3 格式,我使用的是 Chrome,所以一切都应该正常。
尝试在 jPlayer 中设置媒体时出现问题。
Link to how jPlayer should be implemented This where I initially learned how to implement a music listening application. Half way through in the section 'Streaming with HTML5 Audio' is why i used '' - but clearly not working with this implementation.
最佳答案
抱歉回复晚了,但我已经找到答案了。
$(document).ready(function(){
$("#jquery_jplayer_1").jPlayer({
swfPath: "/app/assets/jplayerflash",
supplied: "mp3",
wmode: "window"
});
$('a.play').click(function(e) {
e.preventDefault();
$("#jquery_jplayer_1")
.jPlayer("setMedia", {mp3: this.href })
.jPlayer("play");
以及我的观点:
<td><%= link_to 'Play Song', song_upload.song.url, :class => "play" %></td>
关于jquery - 在 jPlayer 中播放通过 Paperclip 上传的歌曲 - Ruby on Rails - jQuery - jPlayer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10134927/