自动播放音频播放列表 SoundManager2 bar-ui
Autoplay audio playlist SoundManager2 bar-ui
** 已编辑 **
请参阅下面 Jon Black 的回答作为正确的解决方案...
我正在尝试在网站上为客户使用 SoundManager2 HTML5 音频播放器,但是客户坚持认为 .mp3 播放列表 自动播放 以轨道 1 并循环通过其余轨道。
原始脚本(站点上的 soundmanager2.js)有一个 autoPlay: false 选项,但将其更改为 true 没有任何作用。
这是我使用 SoundManager2 的 bar-ui(这是客户想要使用的样式)创建的演示网站的 link 和自动播放 .背景中的 mp3 曲目:website with working demo
正如您所看到(和听到)的那样,背景音频自动播放得很好,但不是通过条形音箱,正如预期的那样。如果您单击“播放”或单击曲目菜单中的播放列表项,则新单击的音频只会在背景音频上播放,这是不需要的。我需要播放列表 audi 自动播放,能够通过条形音箱本身播放、暂停和 select 不同的曲目。
Here is the link to original SoundManager2 project website for further info。
我希望有人能告诉我如何创建一个函数或提供一个脚本,让播放列表在页面加载时自动通过音频播放器 UI 播放。
我进行了大量搜索,并尝试编写和拼凑脚本,但似乎无法正常工作!所以,我求助于 SO 上的天才。
提前感谢您的帮助!
我想出了一个快速简便的方法来解决您的困境。您只需在 bar-ui.js
的 line 1378
或附近的 init()
调用之后添加此简单代码。
soundObject = makeSound(playlistController.getURL());
soundObject.togglePause();
在init()
设置好播放器后,你只需要排队播放列表中的第一个声音(with makeSound(playlistController.getURL()
)然后播放(with togglePause()
)。
要清楚 Jon 的解决方案:
将他提到的两行添加到 bar-ui.js 并插入您的 soundManager.setup
onready: function() {
makeSound(playlistController.getURL());
togglePause();
}
希望对您有所帮助。
上面的解决方案对我不起作用。
它改变了按钮状态,但文件不播放。我在 chrome console
中收到这个带下划线的错误
sound0: play(): Loading - attempting to play...
bar-ui.js:125 Uncaught TypeError: Cannot read property 'on' of undefined
这里显示自动播放是正确的。
Object {url: "http://freshly-ground.com/data/audio/sm2/SonReal%20-%20LA%20%28Prod%20Chin%20Injetti%29.mp3", volume: 100, autoLoad: false, autoPlay: true, from: null…}
当我尝试 Jon Black 的解决方案时,我遇到了与 Oj Obasi 相同的错误,所以我没有在 init() 调用之后立即添加这两行,而是在声明导出之后添加它们并且效果很好。
这是我所做的编辑:
init(); // the init call
exports = {
// Per-instance events: window.sm2BarPlayers[0].on = { ... } etc. See global players.on example above for reference.
on: null,
actions: actions,
dom: dom,
playlistController: playlistController
};
soundObject = makeSound(playlistController.getURL()); // these two lines make it autoplays the playlist from beginning
soundObject.togglePause(); // these two lines make it autoplays the playlist from beginning
return exports;
要使用 SM2 播放器自动播放单个文件(不是播放列表),请在页面加载时包含以下内容:
sm2BarPlayers[0].actions.play();
** 已编辑 **
请参阅下面 Jon Black 的回答作为正确的解决方案...
我正在尝试在网站上为客户使用 SoundManager2 HTML5 音频播放器,但是客户坚持认为 .mp3 播放列表 自动播放 以轨道 1 并循环通过其余轨道。
原始脚本(站点上的 soundmanager2.js)有一个 autoPlay: false 选项,但将其更改为 true 没有任何作用。
这是我使用 SoundManager2 的 bar-ui(这是客户想要使用的样式)创建的演示网站的 link 和自动播放 .背景中的 mp3 曲目:website with working demo
正如您所看到(和听到)的那样,背景音频自动播放得很好,但不是通过条形音箱,正如预期的那样。如果您单击“播放”或单击曲目菜单中的播放列表项,则新单击的音频只会在背景音频上播放,这是不需要的。我需要播放列表 audi 自动播放,能够通过条形音箱本身播放、暂停和 select 不同的曲目。
Here is the link to original SoundManager2 project website for further info。
我希望有人能告诉我如何创建一个函数或提供一个脚本,让播放列表在页面加载时自动通过音频播放器 UI 播放。
我进行了大量搜索,并尝试编写和拼凑脚本,但似乎无法正常工作!所以,我求助于 SO 上的天才。
提前感谢您的帮助!
我想出了一个快速简便的方法来解决您的困境。您只需在 bar-ui.js
的 line 1378
或附近的 init()
调用之后添加此简单代码。
soundObject = makeSound(playlistController.getURL());
soundObject.togglePause();
在init()
设置好播放器后,你只需要排队播放列表中的第一个声音(with makeSound(playlistController.getURL()
)然后播放(with togglePause()
)。
要清楚 Jon 的解决方案: 将他提到的两行添加到 bar-ui.js 并插入您的 soundManager.setup
onready: function() {
makeSound(playlistController.getURL());
togglePause();
}
希望对您有所帮助。
上面的解决方案对我不起作用。 它改变了按钮状态,但文件不播放。我在 chrome console
中收到这个带下划线的错误sound0: play(): Loading - attempting to play...
bar-ui.js:125 Uncaught TypeError: Cannot read property 'on' of undefined
这里显示自动播放是正确的。
Object {url: "http://freshly-ground.com/data/audio/sm2/SonReal%20-%20LA%20%28Prod%20Chin%20Injetti%29.mp3", volume: 100, autoLoad: false, autoPlay: true, from: null…}
当我尝试 Jon Black 的解决方案时,我遇到了与 Oj Obasi 相同的错误,所以我没有在 init() 调用之后立即添加这两行,而是在声明导出之后添加它们并且效果很好。 这是我所做的编辑:
init(); // the init call
exports = {
// Per-instance events: window.sm2BarPlayers[0].on = { ... } etc. See global players.on example above for reference.
on: null,
actions: actions,
dom: dom,
playlistController: playlistController
};
soundObject = makeSound(playlistController.getURL()); // these two lines make it autoplays the playlist from beginning
soundObject.togglePause(); // these two lines make it autoplays the playlist from beginning
return exports;
要使用 SM2 播放器自动播放单个文件(不是播放列表),请在页面加载时包含以下内容:
sm2BarPlayers[0].actions.play();