SoundManager2 onid3() 未触发

发布于 2024-10-12 13:45:55 字数 1423 浏览 4 评论 0原文

我正在构建一个简单的 Javascript 自动点唱机,使用最新的 SoundManager2 进行音频播放,以本地 MP3 文件为源。我已经对文件加载和播放进行了排序,目前我正在尝试访问这些 MP3 文件的 ID3 信息,但 onid3() 回调没有触发。我正在使用 Flash 并已验证文件中是否存在 ID3 信息。以下是我对 onid3() 的实现:

function playNextSongInQueue()
{
    // Get the first element of the songQueue array
    var nextSongInQueue = songQueue.shift();

    // Start playback from the queue
    var jukeboxTune = soundManager.createSound({
        id: 'currentTune',
        url: 'audio/' + nextSongInQueue.name,
        onload: function() {
            this.play();
        },
        onid3: function() {
            alert('ID3 present!');
        },
        onfinish: function() {
            this.destruct();    // Destroy this sound on finish
            songFinish();       // Run the songFinish() function, so decide what to do next
        }
    });

    jukeboxTune.load();
    //jukeboxTune.play();           // The jukebox running!

    songPlaying = true;             // Set songPlaying flag
    updateSongQueueDisplay();       // Refresh the song queue display (for debug)

    return nextSongInQueue.name;
}

其他回调工作正常,但 onid3() 警报永远不会出现。我什至将音频播放的加载和播放部分分开,看看是否有帮助。 SoundManager 发现 onid3() 在那里,因为它将 usePolicyFile 切换为 true - 由于 MP3 是本地的,我假设我不需要担心跨域 XML 文件。

有人能解释一下为什么这不起作用吗?我在谷歌上搜索了一些可行的实现,但没有找到任何有用的东西。我见过 Jacob Seidelin 的纯 Javascript 解决方法,但如果可能的话,我宁愿坚持使用 SoundManager,也不愿使用 PHP 解决方案。

谢谢,

亚当

I'm building a simple Javascript jukebox using the latest SoundManager2 for audio playback, with local MP3 files being the source. I've got file loading and playing sorted, and at the moment I'm trying to get access to the ID3 info of these MP3 files, but the onid3() callback is not firing. I'm using Flash and have verified that ID3 info is present in the files. Below is my implementation of onid3():

function playNextSongInQueue()
{
    // Get the first element of the songQueue array
    var nextSongInQueue = songQueue.shift();

    // Start playback from the queue
    var jukeboxTune = soundManager.createSound({
        id: 'currentTune',
        url: 'audio/' + nextSongInQueue.name,
        onload: function() {
            this.play();
        },
        onid3: function() {
            alert('ID3 present!');
        },
        onfinish: function() {
            this.destruct();    // Destroy this sound on finish
            songFinish();       // Run the songFinish() function, so decide what to do next
        }
    });

    jukeboxTune.load();
    //jukeboxTune.play();           // The jukebox running!

    songPlaying = true;             // Set songPlaying flag
    updateSongQueueDisplay();       // Refresh the song queue display (for debug)

    return nextSongInQueue.name;
}

The other callbacks work fine, but the onid3() alert never comes up. I even separated the load and play portions of audio playback to see if that helped. SoundManager spots that onid3() is there because it switches usePolicyFile to true - seeing as the MP3s are local I am assuming I don't need to worry about the cross-domain XML file.

Can anybody shed light on why this isn't working? I've scoured Google looking for implementations that work but have come up with nothing helpful. I've seen Jacob Seidelin's pure Javascript workaround but would rather stick with SoundManager if possible, and would rather not use a PHP solution.

Thanks,

Adam

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

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

发布评论

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

评论(2

疏忽 2024-10-19 13:45:55

这个问题对于任何可靠的答案来说可能都太深奥了,所以我决定研究 SM2 库之外可能的 Javascript 解决方案。

我开始使用 Nihilogic 的库来读取 ID3v1 标签(位于 http: //blog.nihilogic.dk/2008/08/reading-id3-tags-with-javascript.html),但移至 antimatter15 的 js-id3v2 库(https://github.com/antimatter15/js-id3v2),因为它可以读取 ID3v2 标签。根据提供的示例改编代码,我成功地解析了通过 控件加载 MP3 时所需的主要标签。

This problem is probably too esoteric for any solid answers, so I decided to investigate possible Javascript solutions outside the SM2 library.

I started with Nihilogic's library for reading ID3v1 tags (at http://blog.nihilogic.dk/2008/08/reading-id3-tags-with-javascript.html), but moved to antimatter15's js-id3v2 library (https://github.com/antimatter15/js-id3v2) as it can read ID3v2 tags. Adapting code from the provided example I have managed to successfully parse the main tags required when the MP3s are loaded via the <input> control.

一念一轮回 2024-10-19 13:45:55

对于本地文件,我说的是“用户本地文件”(不是“服务器”本地文件),我使用 id3v2.js 取得了一些成功。

要获取 ID3,SM2 需要 mp3 主机上的跨域(如果它是另一个域)。
另外,我在使用 Soundcloud 时遇到了困难,因为它们将 MP3 重定向到动态 Amazon S3 存储...所以我必须对来宾最终 URL 执行 PHP 脚本,然后 SM2 可以获得正确的 crossdomain.xml (检查 https://getsatisfaction.com/schillmania/topics/displaying_waveformdata_of_soundcloud_hosted_track_prompts_securityerror_error_2122

问题在于 S3 链接和本地用户文件(blob)确实有短暂的过期延迟。

祝你好运 !

For local files, i speak of "user local files" (not "server" local files) i get some success with id3v2.js

To get ID3, SM2 need a cross domain on the mp3 host, if it's another domain.
Plus i have encountered difficulties with Soundcloud as they redirect MP3 to dynamic Amazon S3 storage... so i have to do a PHP script to guest final URL and then SM2 can get proper crossdomain.xml (Check https://getsatisfaction.com/schillmania/topics/displaying_waveformdata_of_soundcloud_hosted_track_prompts_securityerror_error_2122 )

The problem is both S3 links and local user files (blob) do have a short expiration delay.

Good luck !

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