Why does Soundmanager 2 not fire onload event in firefox (23)?

筅森魡賤 提交于 2020-01-13 18:06:02

问题


I am using Soundmanager 2 to play an mp3 audio stream. Somehow the onload event will not be fired in Firefox. In Safari and Chrom it worked well. When i set autoplay to true the stream will be played even in firefox, its just the onload events witch is not working.

soundManager.setup({
    url: '/static/soundmanager2/swf',
    flashVersion: 9,
    preferFlash: false,
    useHTML5Audio: true,
    onready: function() {
        var options = {
        id: 'channel-'+num,
        url: chan.url,
        stream: true,
        onload: function() { alert("loaded"); },
        volume: 50,
        autoPlay:true
        };
        this.SM = soundManager.createSound(options)
    }
});

回答1:


It's a problem with the documentation as it turns out. Remove the onload from the options and use the sound.load method.

Change your code to this:

var sound = soundManager.createSound(options);
sound.load( { 
  onload: function() { 
    alert('works'); 
  } 
});
this.SM = sound;


来源:https://stackoverflow.com/questions/18250573/why-does-soundmanager-2-not-fire-onload-event-in-firefox-23

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!