从ajax加载的soundManager播放先前选择的歌曲

发布于 2024-12-25 16:52:02 字数 536 浏览 0 评论 0原文

我有一个显示不同音乐专辑的页面,我正在其中初始化一个声音管理器。 单击专辑时,会在 ajax 中加载一个视图,其中包含一些 mp3 链接。 这工作正常并且音乐播放。 (我的脚本基于: http:// www.schillmania.com/projects/soundmanager2/demo/mp3-player-button/basic.html

当单击另一个专辑时,我会调用

soundManager.stopAll();

以停止任何当前正在播放的曲目。这会停止当前播放的曲目,但是当我单击新打开的“专辑视图”中的曲目时,先前选择的曲目将在新单击的曲目之上播放。

我尝试过使用 soundManager.unload();和 soundManager.destruct();没有成功...

有什么想法吗?

I have a page where different music albums are showed, and I'm initalizing a soundManager in it.
When an album is clicked, a view is loaded in ajax with some mp3 links in it.
This works fine and the music plays. (I've based my script on: http://www.schillmania.com/projects/soundmanager2/demo/mp3-player-button/basic.html )

When another album is clicked, I'm calling

soundManager.stopAll();

to stop any currently playing track. This stops the track currently playing, but when I click on a track in a newly opened "album view", the previously selected track, plays on top of the newly clicked one.

I've tried using soundManager.unload(); and soundManager.destruct(); without success...

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

影子的影子 2025-01-01 16:52:02

而不是:

var basicMP3Player = null;

soundManager.onready(function() {
  // soundManager.createSound() etc. may now be called
  basicMP3Player = new BasicMP3Player();
});

我使用:

if ( typeof basicMP3Player !== "undefined" && basicMP3Player) {
    basicMP3Player.destruct();
} 
else {
    var basicMP3Player = null;
}

soundManager.onready(function() {
  // soundManager.createSound() etc. may now be called
  basicMP3Player = new BasicMP3Player();
});

问题是,现在当我加载另一个“相册视图”时,配置未正确加载,并且“playNext”或“autoPlay”属性不起作用......

Instead of:

var basicMP3Player = null;

soundManager.onready(function() {
  // soundManager.createSound() etc. may now be called
  basicMP3Player = new BasicMP3Player();
});

I used:

if ( typeof basicMP3Player !== "undefined" && basicMP3Player) {
    basicMP3Player.destruct();
} 
else {
    var basicMP3Player = null;
}

soundManager.onready(function() {
  // soundManager.createSound() etc. may now be called
  basicMP3Player = new BasicMP3Player();
});

The problem is that now when I load another "album view", the config isn't loaded properly and the "playNext" or "autoPlay" attributes aren't working...

无所的.畏惧 2025-01-01 16:52:02

嗯......这是旧的,但我遇到了这个问题并找到了答案
这里

似乎你只需要调用:

soundManager.reboot();

在你的ajax调用成功之后。

Well... this is old, but I had this issue and found the answer
here

Seems you just need to call:

soundManager.reboot();

After your ajax call success.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文