<krpano name="globalObject">
    <plugin name="video"
            url.html5="https://dm.static.elab-plus.com/videoplayer.js" 
            videourl=""
            muted="true"
            preload="true"
            pausedonstart="false"
            onvideoready="videoreadyFunc"
            onvideopaused="videopausedFunc"
            url.flash="https://dm.static.elab-plus.com/videoplayer.swf"
            loop="true"
            isPlayBg="false"
            voicesList=""
            playName = ""
            isPay = "false"
            isVideoreadyType="false"
            isTip = "false"
            />
    <image>
        <sphere url="plugin:video" />
    </image>
    <!-- 热点地址 -->
    <hotspot 
        name="hotspot-yard"
        type="image"
        edge="lefttop"
        url="https://dm.static.elab-plus.com/hqc-img/forward.png"
        alturl="https://dm.static.elab-plus.com/hqc-img/forward.png"
        distorted="true"
		ath="0"
        atv="0"
        width="74"
        height="91"
        visible="false"
        onclick="switchScenesType"
        />
    <settings width="100" height="50" />
    <view hlookat="0" vlookat="0" fov="120" fovmin="90.0" fovmax="130.0" fovtype="DFOV"/>
    <action name="switchScenesType">
        jscall('window.switchScenesType()');
    </action>
    <action name="mobilescale" autorun="preinit" devices="mobile">
        mul(stagescale,0.5);
    </action>
    <action name="playSceneName">
        <!-- 打印日志 -->
        <!-- showlog(true, top); -->
        mobilescale();
        <!-- 播放视频 -->
        plugin[video].playvideo(%1, %2, false);
        def(b, string, get(plugin[video].isPlayBg));
        if(b == false, playBgMusic(%3));
        if(b == suspend, delayedcall(0.5 , playBgMusic(%3, true)););
        <!-- 是否显示热点 -->
        if(
            %4 == true,
                set(hotspot[hotspot-yard].visible, true);
                ,
                set(hotspot[hotspot-yard].visible, false);
            )
    </action>
    <action name="playBgMusic">
        <!-- 播放背景音乐 -->
        ifnot(%2 == true, playsound(bgsnd, %1, 0););
        if(%2 == true, pausesoundtoggle(bgsnd););
        set(plugin[video].isPlayBg, true);
    </action>
    <!-- 播放音乐设置，引入插件 -->
    <plugin name="soundinterface" 
        url="https://dm.static.elab-plus.com/soundinterface.swf"
        alturl="https://dm.static.elab-plus.com/soundinterface.js" 
        preload="true"
        keep="true"
        loop="false"
        ></plugin>
    <!-- 音乐播放完 -->
    <action name="musicPlayComplete">
        <!-- 删掉保存的状态 -->
        <!-- 播放的数组 -->
        def(voicesList, string, get(plugin[video].voicesList));
        <!-- 刚播放完的名称 -->
        def(voicesName, string, get(plugin[video].playName));
        txtreplace(voicesList, get(voicesName), '');
        set(plugin[video].playName, '');
        set(plugin[video].isPay, false);
        set(plugin[video].voicesList, voicesList);

        jscall('window.musicPlayComplete()');
    </action>
    <!-- 播放声音 -->
    <action name="playsoundMusic">
        def(voicesList, string, get(plugin[video].voicesList));
        def(voicesName, string, %1);
        def(voicesUrl, string, %2);
        def(isStartPay, string, %3);
        <!-- 当前播放的名称 -->
        set(plugin[video].playName, get(voicesName));
        <!-- 当之前没有播放过，则播放声音 -1就是没有播放过-->
        indexoftxt(index, get(voicesList), get(voicesName));
        <!-- isStartPay true 播放音乐 false 暂停音乐  index == -1 播放音乐  其他的则切换音乐状态 -->
        if(
            isStartPay == true,
                startPayMusic(get(voicesName), get(voicesUrl), get(voicesList));
            ,
                if(
                    isStartPay == false,
                        pausesoundMusic(get(voicesName));
                    ,
                        if(
                            index == -1,
                                startPayMusic(get(voicesName), get(voicesUrl), get(voicesList));
                            ,
                                toggleMusic(get(voicesName));
                        )
                )
        );
    </action>
    <!-- 重新开始播放 -->
    <action name="startPayMusic" args="voicesName, voicesUrl, voicesList">
        <!-- 将播放的字符 添加到总字符中 -->
        txtadd(voicesConcat, get(voicesList), get(voicesName));
        <!-- 设置播放的字符集合 -->
        set(plugin[video].voicesList, get(voicesConcat));
        <!-- 是否在播放 -->
        set(plugin[video].isPay, true);
        <!-- 播放声音 -->
        def(b, string, get(plugin[video].isPlayBg));
        if(
            b == suspend,
                delayedcall(0.5,playsound(get(voicesName), get(voicesUrl), 1, musicPlayComplete););
            ,
                playsound(get(voicesName), get(voicesUrl), 1, musicPlayComplete);
        );
    </action>
    <!-- 切换状态播放，暂停 -->
    <action name="toggleMusic" args="voicesName">
        def(isPay, string, get(plugin[video].isPay));
        if(
            isPay == false,
                set(plugin[video].isPay, true);
                resumesoundMusic(get(voicesName))
            ,
                set(plugin[video].isPay, false);
                pausesoundMusic(get(voicesName));
        );
    </action>
    <!-- 暂停声音 -->
    <action name="pausesoundMusic">
        pausesound(%1);
    </action>
    <!-- 恢复声音 -->
    <action name="resumesoundMusic">
        resumesound(%1);
    </action>
    <!-- 关闭所有的声音 -->
    <action name="closeVoice">
        pausesoundtoggle(bgsnd);
    </action>
    <!-- 视频初始化完成 -->
    <action name="videoreadyFunc">
        jscall('window.videoready()');
    </action>
    <!-- 引导图加载完成后 -->
    <action name="suspendedPlay">
        set(plugin[video].isVideoreadyType, true);
    </action>
    <!-- 视频暂停 -->
    <!-- 解决ios手机 切换页面返回不自动播放的原因 devices="ios"-->
    <action name="videopausedFunc" devices="ios">
        def(isTip, string, get(plugin[video].isTip));
        trace(plugin[video].isTip);
        
        pausesound(bgsnd);
        set(plugin[video].isPay, false);
        def(voicesName, string, get(plugin[video].playName));
        ifnot(voicesName == '' ,pausesoundMusic(get(voicesName)););
     

        if(isTip == true, 
            set(plugin[video].isTip, false);
        ,
            jscall('window.videopausedFunc()');
        );
    </action>
    <!-- 滚动到中心位置 -->
    <events onclick="clickFunc"></events>
    <action name="clickFunc">
        <!-- screentosphere(mouse.x, mouse.y, h, v);
        trace(h,',',v); -->
        def(isVideoreadyType, string, get(plugin[video].isVideoreadyType));
        if(isVideoreadyType == true,
            <!-- 获取当前播放的声音名称 -->
            def(voicesName, string, get(plugin[video].playName));
            <!-- 切换播放的状态 -->
            <!-- plugin[video].togglepause(); -->

            def(isPlayBg, string, get(plugin[video].isPlayBg));
            if(isPlayBg == true,
            <!-- 暂停声音 -->
                    <!-- 暂停视频 -->
                    plugin[video].pause();
                       <!-- 是因为点击导致视频暂停 -->
                    set(plugin[video].isTip, true);
                    pausesound(bgsnd);
                    set(plugin[video].isPlayBg, false);
                    jscall(calc("window.switchPlayImg('"+ false +"')") );
                    <!-- 当有播放声音的名称，则切换播放的状态 -->
                    ifnot(voicesName == '' ,
                        <!-- 暂停声音 -->
                        set(plugin[video].isPay, false);
                        pausesoundMusic(get(voicesName));
                        jscall(calc("window.payVoiceStatus('"+ false +"')") );); 
                ,
            <!-- 播放声音 -->
                    <!-- 播放视频 -->
                    plugin[video].play();
                    resumesound(bgsnd);
                    set(plugin[video].isPlayBg, true);
                    jscall(calc("window.switchPlayImg('"+ true +"')") );
                    <!-- 当有播放声音的名称，则切换播放的状态 -->
                    ifnot(voicesName == '' ,
                        <!-- 播放声音 -->
                        set(plugin[video].isPay, true);
                        resumesoundMusic(get(voicesName));
                        jscall(calc("window.payVoiceStatus('"+ true +"')") );); 
            );
        );
        
        
    </action>
</krpano>