一、添加背景音乐
#添加全局播放插件(注意文件如果不存在从krpano程序目录中复制)
<plugin name="soundinterface" url="%SWFPATH%/plugins/soundinterface.swf" alturl="%SWFPATH%/plugins/soundinterface.js" rootpath="" preload="true" keep="true" volume="0.6"/>
#添加音乐
<action name="startup" autorun="onstart">
....
playsound(bgsnd, 'audio/bg.mp3', 0);
</action>
#bgsnd代表声音id,名字不要和其它id冲突, 0代表循环,1代表播放一次
二、添加每个场景解说
#添加一的全局插件
#添加action
<events name="audioscene" keep="true" onnewscene="ChangeScene();"/>
<action name="ChangeScene">
set(_audiourl, calc:'audio/' + scene[get(xml.scene)].sound + '.mp3');
playsound(curaudio, get(_audiourl));
</action>
在每个scene添加音乐名称(不带.mp3后缀)
<scene name="scene_1" .... sound="mp3name">
多个场景同一个解说(多个场景切换时不中断解说)
#添加一的全局插件
<skin_setting 添加 musicgroup="0"
<scene 添加 group="1或2" scenemusic="scene1music.mp3"
外部添加
<events name="scene1events" keep="true"
onxmlcomplete="
ifnot(scene[get(xml.scene)].group == skin_settings.musicgroup,
playsound(scenesound, get(scene[get(xml.scene)].scenemusic),1);
copy(skin_settings.musicgroup,scene[get(xml.scene)].group));"
/>
三、在场景中添加播放按钮
#添加一的全局插件
#复制showtext.xml 到/plugins
#添加播放按钮图片 ypopen.png,ypclose.png 到/
<krpano 添加now_play="">
<include url="%SWFPATH%/plugins/showtext.xml" />
<style name="skin_soundbutton" url="ypopen.png" onhover="showtext(get(text),STYLE2);" distorted="true"
onclick="stopallsounds();
if(url == ypopen.png,
playsound(get(name),get(sound),1);if(now_play != name, set(hotspot[get(now_play)].url,ypopen.png););set(now_play,get(name)),
stopsound(get(name));
);
switch(url,ypopen.png,ypclose.png);" />
<textstyle name="STYLE2"
font="Arial" fontsize.no-mobile="18" fontsize.mobile="28" bold="true"
background="false" border="false"
textcolor="0xFFFFFF"
textalign="center"
textshadow="0.01" textshadowrange="3" textshadowcolor="0x000000"
yoffset.touch="-40"
/>
二、B 添加每个场景解说方法2(第一次启动里有一个开始按钮,防止浏览器第一次不启动音乐播放)
#添加一的全局插件
<!-- 开始按钮 -->
<layer name="splash" type="text" keep="true" zorder="100" align="center" html="开始" vcenter="true" padding="20" onclick="FirstStart"/>
<!-- 遮罩层 -->
<layer name="dip" keep="true" type="container" align="lefttop" width="100%" height="100%" bgcolor="0x000000" bgalpha="1"/>
<action name="FirstStart">
set(_audiourl, calc:'audio/' + scene[get(xml.scene)].sound + '.mp3'); playsound(curaudio, get(_audiourl)); tween(plugin[soundinterface].volume,1,2); removelayer(splash); tween(layer[dip].alpha,0,2,,removelayer(dip));
</action>
<plugin name="soundinterface" keep="true" url="plugins/soundinterface.js" preload="true" volume="1" mute="false"/>
<action name="ChangeScene">
loadscene(%1); set(_audiourl, calc:'audio/' + scene[get(xml.scene)].sound + '.mp3'); playsound(curaudio, get(_audiourl));
</action>
<!-- audio1 is the name of the mp3 in the audio folder -->
<scene name="scene_1" ... autoload="true" sound="audio1">
...
<hotspot name="spot1" url="VT.png" ath="0" atv="0" onclick="ChangeScene(scene_2);"/>
</scene>
<scene name="scene_2" ... sound="audio2">
...
<hotspot name="spot1" url="VT.png" ath="0" atv="0" onclick="ChangeScene(scene_1);"/>
</scene>