
<template>
    <router-view></router-view>
    <audio
      class="audio"
      src=""
      @timeupdate="timeupdatefn"
      style="display:none;"
    ></audio>
</template>
<script setup lang="ts">
// @ts-nocheck
import { useStore } from '@/store';
import { storeToRefs } from 'pinia';
import MqttUnit from "@/utils/mqttunit";
import { onMounted } from 'vue';
import {WebRtcStreamer} from '@/utils/webrtc-streamer/webrtcstreamer.js'
let pinia = useStore()
onMounted(() => {
    let client = new MqttUnit().mqttInit();
    let WebRtcStreamerRt=WebRtcStreamer()
    if (typeof window !== 'undefined' && typeof window.document !== 'undefined') {
    window.WebRtcStreamer = WebRtcStreamerRt;
}
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
    module.exports = WebRtcStreamerRt;
}
    client.on('message', (topic: string, message: Uint8Array) => {
        const utf8decoder = new TextDecoder();
        const msgString = utf8decoder.decode(message);
        if (topic.startsWith("/server/warning")) {
            // $mitt.emit("warnInfo", msgString);
            console.log(msgString);

        }
    })
})
function timeupdatefn(e:any) {
      let {audioCount,audioCurrentCount}=storeToRefs(pinia)
      if (e.target.currentTime >= e.target.duration) {
        let count_ = audioCurrentCount.value + 1;
        pinia.updateaudioCurrentCount(count_)
        if (audioCurrentCount.value < audioCount.value) {
          e.target.currentTime = 0;
          e.target.play();
        }
      }
    }
</script>



<style lang="less">
body{
    height: 100vh;
    overflow: hidden;
    user-select: none;
}
</style>
