需求:
背景音乐需要一直播放,无论切换场景与否,同时循环播放。另外每个场景都有自己的声音(解说词)。
解决方案:
<pre name="code" class="html"><krpano onstart="playsound(bg, backgroundmusic.mp3,0); loadscene(scene1,null,MERGE);">
<plugin name="soundinterface" url="soundinterface.swf" alturl="soundinterface.js" preload="true" />
<scene name="scene1">
<events name="scene1events" onxmlcomplete="tween(sound[bg].volume, 0.5);playsound(scene1sound, scene1music.mp3,1,tween(sound[bg].volume, 1));" onremovepano="stopsound(scene1sound);" />
...
</scene>
<scene name="scene2">
<events name="scene2events" onxmlcomplete="tween(sound[bg].volume, 0.5);playsound(scene2sound, scene2music.mp3,1,tween(sound[bg].volume, 1));" o