【问题标题】:How to play multiple mp3 files with Jplayer?如何用 Jplayer 播放多个 mp3 文件?
【发布时间】:2014-11-18 16:59:03
【问题描述】:

这里我使用 Jplayer 一个开源的 mp3 播放器插件。

myPlaylist.add({
  title:"Tempered Song",
  artist:"Miaow",
  mp3:"http://www.jplayer.org/audio/mp3/Miaow-01-Tempered-song.mp3",
});

但是假设如果我有 three 锚标签,其中包含三种不同的音乐。

<a href="#">This is song 1</a>
<a href="#">This is song 2</a>
<a href="#">This is song 3</a>

显然,我无法将音乐 URL 放入 href。点击后会自动开始下载或打开window媒体播放器。

那么,如何将三个不同的音乐源文件放入这个 jquery 脚本中呢?或者你用什么来播放mp3文件而不是使用锚标签?

myPlaylist.add({
      title:"<Song name>",
      artist:"<singer name>",
      mp3:"<MP3 URL of three different song>",
    });

我想将这三个不同的 mp3 文件播放到一个播放器中,但很困惑。我无法在 google 中找到 jplayer 倾向于将不同的多个 mp3 文件与 jplayer 一起使用。请帮助如何做到这一点?

帮助,不胜感激!!

【问题讨论】:

标签: javascript php jquery html jplayer


【解决方案1】:

这很容易,无需使用 jquery attr 进行锚定。

<a href="#" music-url="songs_music_url">This is song 1</a>

在 jquery 中:

myPlaylist.add({
  title:"<Song name>",
  artist:"<singer name>",
  mp3:$('a').attr('music-url'),
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多