Newer
Older
urbanLifeline_YanAn / src / views / DialogTabs / component / ImouPlayer.vue
@zhangzhihui zhangzhihui 1 day ago 1 KB 视频接入
<template>
  <div id="ImouPlayer"></div>
</template>

<script setup name="ImouPlayer">
import bus from '@/bus';

import dialogTabsStore from '@/store/modules/dialogTabs';

// const { proxy } = getCurrentInstance();

// const useDialogTabs = dialogTabsStore();

// const showData = ref(null);
// const loading = ref(false);
const props = defineProps({
  // 数据SiteNo
  SiteNo: {
    type: String,
  },
  dataID: {
    type: String,
  },
});

console.log('-----1-1------------', props);

let player = null;

const play = () => {
  player.play();
};
const pause = () => {
  player.pause();
};
const stop = () => {
  player.stop();
};
const capture = () => {
  player.capture();
};
const startTalk = () => {
  player.startTalk();
};
const stopTalk = () => {
  player.stopTalk();
};
const volume = value => {
  player.volume(value);
};
const fullScreen = () => {
  player.fullScreen();
};
const exitFullScreen = () => {
  player.exitFullScreen();
};
const startRecord = () => {
  player.startRecord();
};
const stopRecord = () => {
  player.stopRecord();
};

const destroy = () => {
  player.destroy();
  player = null;
};

const init = () => {
  if (player) {
    destroy();
  }
  player = new imouPlayer({
    id: 'ImouPlayer', // 视频容器ID
    // width: 1200,
    // height: 700,
    deviceId: '8L06A0DPANC7F5D',
    // deviceId: props.dataID,
    channelId: '0',
    token: 'Kt_hz207f7326c9b943119fcd02648831cd',
    // 1 直播  2 录播
    type: 1,
    // 直播 0 高清  1 标清  默认
    streamId: 1,
    // 录播 云录像 cloud 本地录像 localRecord 默认 云录像
    recordType: 'cloud',
    mute: false,
    handleError: err => {
      console.error('handleError', err);
    },
  });
  // window.player = player;
};

onMounted(() => {
  init();
});

onBeforeUnmount(() => {
  destroy();
});
</script>

<style lang="scss" scoped>
#ImouPlayer {
  width: 100%;
  height: 100%;
  background-color: #000;
  color: #ccc;
  text-align: center;
  // padding-top: 30px;
  font-size: 20px;
}
</style>