krpano使用示例

2023-10-11 14:25:09 浏览数 (1)

1.添加热点声音;

soundhelper.xml;

<include url="soundhelper.xml" />

<hotspot name="spot1" style="skin_soundbutton" ath="13.267" atv="-6.054"   /> <hotspot name="spot2" style="skin_soundbutton" ath="-105.872" atv="-7.814"  /> <hotspot name="spot3" style="skin_soundbutton" ath="151.117" atv="-2.083"    />

代码语言:javascript复制
<krpano>
	
	
<!-- 
	            bgsound 是否启用背景声音,可填true或false,建议有其它声音时,填false
                bgsoundurl 背景声音的路径
                bgsoundloop 背景声音是否循环,循环为0,不循环为1	           
                hotspoturl 音乐热点按钮的路径
                play_crop 按钮播放时的crop
                pause_crop 按钮暂停时的crop
                now_play=""  默认,不要修改
                musicgroup="" 默认,不要修改
                muteglobal="true" 静音按钮是只针对当前场景还是全局性的
-->

	<sound_settings bgsound="true"
	                bgsoundurl=""
	                bgsoundloop="0" 	                      
	                hotspoturl="soundHotsopt.png"
	                play_crop="68|0|68|68"
	                pause_crop="0|0|68|68"
	                now_play=""
	                mute="false"
	                muteglobal="true"
	                musicgroup=""
	                musicplaybutton_name="button"
	                musicchangebutton_name="button3"
	                musicchange="2"
	                buttonhtml="中文"
	               />

<!-- 
	      scenesound的name也就是scene的name。scenemusic对应该场景音乐的路径。loop为循环设置。
			hotspotmusic的name也就是对应hotspot的name,musicurl对应热点音乐的路径。
-->




    <plugin     name="soundinterface"
				url="%SWFPATH%/plugins/soundinterface.swf"
				alturl="%SWFPATH%/plugins/soundinterface.js"
				rootpath=""
				preload="true"
				keep="true"
				/>   

	

	<events name="musicevents"
			onnewpano="
			    
				if(scenesound[get(xml.scene)] !== null,

					if(scenesound[get(xml.scene)].scenemusic === null,
						set(scenesound[get(xml.scene)].scenemusic,'');
						);
					if(scenesound[get(xml.scene)].loop === null,set(scenesound[get(xml.scene)].loop,1));
	                if(scenesound[get(xml.scene)].scenemusic != sound_settings.musicgroup AND scenesound[get(xml.scene)].scenemusic != '',
	                	  if(sound_settings.muteglobal == false,
	                	  	if(layer[get(sound_settings.musicplaybutton_name)] !== null,set(layer[get(sound_settings.musicplaybutton_name)].html,'暂停'));
	                	  	);

	                	 if(sound_settings.muteglobal == true AND sound_settings.mute == false OR sound_settings.muteglobal == false,
	                		if(sound_settings.musicchange == 1,
	                    playsound(bgs,get(scenesound[get(xml.scene)].scenemusic),get(scenesound[get(xml.scene)].loop));
	                    );
	                		if(sound_settings.musicchange == 2,
	                			if(scenesound[get(xml.scene)].scenemusic2 === null OR 
	                				scenesound[get(xml.scene)].scenemusic2 == '',
	                			playsound(bgs,get(scenesound[get(xml.scene)].scenemusic),get(scenesound[get(xml.scene)].loop));
	                			,
	                			playsound(bgs,get(scenesound[get(xml.scene)].scenemusic2),get(scenesound[get(xml.scene)].loop));
	                    );
	                			);
	                		
	                	
	                    set(sound_settings.mute,false);
	                    );
	                    copy(sound_settings.musicgroup,scenesound[get(xml.scene)].scenemusic);
	                   
	                	);
	                if(scenesound[get(xml.scene)].scenemusic == '',  
	                    set(sound_settings.musicgroup,0);
	                	);
				,
				set(sound_settings.musicgroup,0);

				);

                if(layer[get(sound_settings.musicplaybutton_name)],

                	set(layer[get(sound_settings.musicplaybutton_name)].alpha,1);
					set(layer[get(sound_settings.musicplaybutton_name)].enabled,true); 

                	);

				if(scenesound[get(xml.scene)] === null AND sound_settings.bgsound == false AND layer[get(sound_settings.musicplaybutton_name)],
					
					set(layer[get(sound_settings.musicplaybutton_name)].alpha,0.5);
					set(layer[get(sound_settings.musicplaybutton_name)].enabled,false); 

                   
					);
				if(scenesound[get(xml.scene)] !== null AND (scenesound[get(xml.scene)].scenemusic == '' OR scenesound[get(xml.scene)].scenemusic === null ) AND sound_settings.bgsound == false AND layer[get(sound_settings.musicplaybutton_name)],
					
					set(layer[get(sound_settings.musicplaybutton_name)].alpha,0.5);
					set(layer[get(sound_settings.musicplaybutton_name)].enabled,false); 

                   
					);

				if(scenesound[get(xml.scene)].scenemusic2 != '' AND layer[get(sound_settings.musicchangebutton_name)] ,

					set(layer[get(sound_settings.musicchangebutton_name)].alpha,1);
					set(layer[get(sound_settings.musicchangebutton_name)].enabled,true); 
					);

				if((scenesound[get(xml.scene)].scenemusic2 == '' OR scenesound[get(xml.scene)].scenemusic2 === null) AND  
					layer[get(sound_settings.musicchangebutton_name)] ,

					set(layer[get(sound_settings.musicchangebutton_name)].alpha,0.5);
					set(layer[get(sound_settings.musicchangebutton_name)].enabled,false); 
					);

					

	                

	                "			
			onremovepano="
				if(scenesound[get(xml.scene)].scenemusic != sound_settings.musicgroup OR scenesound[get(xml.scene)] === null OR scenesound[get(xml.scene)].scenemusic == '',
					stopsound(bgs));
				    stopsound(get(sound_settings.now_play));
				    if(scenesound[get(xml.scene)].scenemusic == null AND scenesound[get(xml.scene)].scenemusic === null,set(sound_settings.mute,true));
				    set(sound_settings.now_play,'');
				"
			keep="true" />


	<style name="skin_soundbutton" url="get:sound_settings.hotspoturl"  onhover="" distorted="true" crop="get:sound_settings.pause_crop"
       onclick="
       			stopsound(get(sound_settings.now_play));   stopsound(bgs);
		       if(crop == sound_settings.pause_crop,
		       	playsound(get(name),get(scenesound[get(xml.scene)].hotspotmusic[get(name)].musicurl),1,sound_dispatch());
		       	
		       	if(sound_settings.now_play != name AND sound_settings.now_play != null, 
		       		set(hotspot[get(sound_settings.now_play)].crop,get(sound_settings.pause_crop)));
		       	copy(sound_settings.now_play,name),
		       	stopsound(get(name));sound_dispatch();
		       	
		       	set(sound_settings.now_play,null);
		       	);
		       switch(crop,get(sound_settings.pause_crop),get(sound_settings.play_crop));"  
		       />            

	               
	
	   

    <action name="bgsound_preinit" autorun="preinit">
		if(sound_settings.bgsound == true,

			preloadsound(get(sound_settings.bgsoundurl));
			);
	</action>  


	<action name="bgsound_startup" autorun="onstart">

		if(sound_settings.bgsound == true,
			
			playsound(bgsnd, get(sound_settings.bgsoundurl), get(bgsoundloop));set(sound_settings.mute,false);
			);
	</action>  

	<action name="sound_play_stop" >
	
        if(sound_settings.mute,
        	

            if(scenesound[get(xml.scene)].scenemusic != null AND scenesound[get(xml.scene)].scenemusic !== null,
            	 	   if(sound_settings.musicchange == 1,
	                    playsound(bgs,get(scenesound[get(xml.scene)].scenemusic),get(scenesound[get(xml.scene)].loop));
	                    );
	                   if(sound_settings.musicchange == 2,
                			if(scenesound[get(xml.scene)].scenemusic2 === null OR 
                				scenesound[get(xml.scene)].scenemusic2 == '',
                			playsound(bgs,get(scenesound[get(xml.scene)].scenemusic),get(scenesound[get(xml.scene)].loop));
                			,
                			playsound(bgs,get(scenesound[get(xml.scene)].scenemusic2),get(scenesound[get(xml.scene)].loop));
	                    );
	                			);
	                		
            	 set(sound_settings.mute,false);
	                    
	                    );

            if(sound_settings.bgsound == true,
			
			playsound(bgsnd, get(sound_settings.bgsoundurl), get(bgsoundloop));set(sound_settings.mute,false);
			);
			

			,


        	
		 if(sound_settings.now_play != '',
			    callwith(hotspot[get(sound_settings.now_play)],onclick);set(sound_settings.mute,true);
			    );
		 if(scenesound[get(xml.scene)].scenemusic != null,
		        stopsound(bgs);set(sound_settings.mute,true);
		        );
		 if(sound_settings.bgsound == true,
		        stopsound(bgsnd);set(sound_settings.mute,true);
		        );
		        
		       
		        

		 );

        
	</action>   

	<action name="sound_change" >
           if(sound_settings.mute,null
           	,
           	if(sound_settings.musicchange == 1,
           		stopsound(bgs);
           		playsound(bgs,get(scenesound[get(xml.scene)].scenemusic2),get(scenesound[get(xml.scene)].loop));
           		,
                stopsound(bgs);
           		playsound(bgs,get(scenesound[get(xml.scene)].scenemusic),get(scenesound[get(xml.scene)].loop));
           		);
           	);

           switch(sound_settings.musicchange,1,2);


	</action> 

     <action name="sound_dispatch" >

	if(scenesound[get(xml.scene)] !== null,

					if(scenesound[get(xml.scene)].scenemusic === null,
						set(scenesound[get(xml.scene)].scenemusic,'');
						);
					if(scenesound[get(xml.scene)].loop === null,set(scenesound[get(xml.scene)].loop,1));
	                if(scenesound[get(xml.scene)].scenemusic != '', 
	                	  if(sound_settings.mutemuteglobal == false,
	                	  	if(layer[get(sound_settings.musicplaybutton_name)] !== null,set(layer[get(sound_settings.musicplaybutton_name)].html,'暂停'));
	                	  	);

	                	 if(sound_settings.mute == false,
	                		if(sound_settings.musicchange == 1,
	                    playsound(bgs,get(scenesound[get(xml.scene)].scenemusic),get(scenesound[get(xml.scene)].loop));
	                    );
	                		if(sound_settings.musicchange == 2,
	                			if(scenesound[get(xml.scene)].scenemusic2 === null OR 
	                				scenesound[get(xml.scene)].scenemusic2 == '',
	                			<!-- 播放场景背景音乐 -->	
	                			<!-- playsound(bgs,get(scenesound[get(xml.scene)].scenemusic),get(scenesound[get(xml.scene)].loop));
	                			,
	                			playsound(bgs,get(scenesound[get(xml.scene)].scenemusic2),get(scenesound[get(xml.scene)].loop)); -->
	                    );
	                			);
	                		
	                	
	                    set(sound_settings.mute,false);
	                    );
	                    copy(sound_settings.musicgroup,scenesound[get(xml.scene)].scenemusic);
	                   
	                	);
	                if(scenesound[get(xml.scene)].scenemusic == '',  
	                    set(sound_settings.musicgroup,0);
	                	);
				,
				set(sound_settings.musicgroup,0);

				);

                if(layer[get(sound_settings.musicplaybutton_name)],

                	set(layer[get(sound_settings.musicplaybutton_name)].alpha,1);
					set(layer[get(sound_settings.musicplaybutton_name)].enabled,true); 

                	);

				if(scenesound[get(xml.scene)] === null AND sound_settings.bgsound == false AND layer[get(sound_settings.musicplaybutton_name)],
					
					set(layer[get(sound_settings.musicplaybutton_name)].alpha,0.5);
					set(layer[get(sound_settings.musicplaybutton_name)].enabled,false); 

                   
					);
				if(scenesound[get(xml.scene)] !== null AND (scenesound[get(xml.scene)].scenemusic == '' OR scenesound[get(xml.scene)].scenemusic === null ) AND sound_settings.bgsound == false AND layer[get(sound_settings.musicplaybutton_name)],
					
					set(layer[get(sound_settings.musicplaybutton_name)].alpha,0.5);
					set(layer[get(sound_settings.musicplaybutton_name)].enabled,false); 

                   
					);

				if(scenesound[get(xml.scene)].scenemusic2 != '' AND layer[get(sound_settings.musicchangebutton_name)] ,

					set(layer[get(sound_settings.musicchangebutton_name)].alpha,1);
					set(layer[get(sound_settings.musicchangebutton_name)].enabled,true); 
					);

				if((scenesound[get(xml.scene)].scenemusic2 == '' OR scenesound[get(xml.scene)].scenemusic2 === null) AND  
					layer[get(sound_settings.musicchangebutton_name)] ,

					set(layer[get(sound_settings.musicchangebutton_name)].alpha,0.5);
					set(layer[get(sound_settings.musicchangebutton_name)].enabled,false); 
					);

					
     </action> 

	
</krpano>

0 人点赞