我想创建一个简单的插件,将发挥不同的MP3录音,每次用户双击一个网页,他正在访问一个字,并选择从上下文菜单中一个特殊的选项。
I would like to create a simple add-on that would play a different MP3 recording every time the user double clicks a word in a webpage he is visiting and selects a special option from the context menu.
的MP3文件位于远程服务器上。通常我会用JavaScript + Flash来播放MP3文件。在Firefox插件,但是,我无法加载外部脚本由于某种原因(播放声音工作正常,如果它是加载脚本的网页本身,但当然我需要它与每一个网站,而不仅仅是工作包括该脚本的那些)。
The MP3 files are located on a remote server. Normally I would use JavaScript+Flash to play the MP3 file. In a Firefox add-on, however, I'm unable to load external scripts for some reason (playing the sound works fine if it's the webpage itself that loads the scripts, but of course I need it to work with every website and not just the ones that include the script).
那么,在Firefox中发挥远程MP3文件,最简单的方法附加使用JavaScript?
So what's the easiest way to play a remote MP3 file in a Firefox add-on using JavaScript?
推荐答案这可能不能完全解决你的问题,因为我不相信它播放MP3,但我不能肯定。
This may not entirely solve your question, as I don't BELIEVE it plays MP3s, but I'm not certain.
Firefox拥有nsISound,我知道可以播放远程WAV文件,因为我已经测试并证明了这一点。
Firefox has nsISound, which I KNOW can play remote WAV files, as I've tested and proved it.
您可能想测试自己,看看它是否会导致你靠近一点!
You may want to test it for yourself and see if it leads you a little closer!
var ios = Components.classes['@mozilla/network/io-service;1'].getService(Components.interfaces.nsIIOService); var sound = ios.newURI("www.yoursite/snds/haha.wav", null, null); var player = Components.classes["@mozilla/sound;1"].createInstance(Components.interfaces.nsISound); player.play(sound);祝你好运,我希望这至少可以让你靠近!
Good luck, I hope this at least gets you close!
更多推荐
在Firefox中播放声音附加
发布评论