Sound
Access
{{reader}}
Favourite Pages
{{pageEntry.pageName}}
Signed in as {{currentUser}} {{avatar}}
Sign Out
Sign In as Different User
{{currentUserExtraOptions}}
OpenForum
Javascript
Sound
//OpenForum/Javascript/Sound/page.js
OpenForum.loadScript("/OpenForum/Javascript/Sound/SoundPlayer.js"); OpenForum.init = function() { OpenForum.SoundPlayer.addSound("/OpenForum/Javascript/Sound/torpedo-1.mp3","sound1"); OpenForum.SoundPlayer.addSound("/OpenForum/Javascript/Sound/torpedo-2.mp3","sound2"); };
//OpenForum/Javascript/Sound/page.content
[{InsertSourceFile fileName="page.js"}] [{InsertSourceFile fileName="page.content"}]
Play Sound 1
Play Sound 2
[{InsertSourceFile fileName="SoundPlayer.js"}]
Play Sound 1
Play Sound 2
//OpenForum/Javascript/Sound/SoundPlayer.js
if(!OpenForum) { OpenForum = {}; } if(!OpenForum.SoundPlayer) { OpenForum.SoundPlayer = new function() { var sounds = []; this.addSound = function(source,id) { var sound = document.createElement('audio'); sound.src = source; sounds[id] = {source: source,sound: sound}; }; this.playSound = function(id,onEndCallBack) { if(onEndCallBack) sounds[id].sound.onended = onEndCallBack; sounds[id].sound.loop=false; sounds[id].sound.play(); }; this.loopSound = function(id) { sounds[id].sound.loop=true; sounds[id].sound.play(); }; this.stopSound = function(id) { sounds[id].sound.loop=false; sounds[id].sound.pause(); }; }; }
An error has occurred.
{{OpenForum.errorMessage}}
See technical details
×
Error details.
{{OpenForum.error}}
×
{{OpenForum.alert.title}}
{{OpenForum.alert.message}}
×