forked from drone/command-center-dashboard

shuishen
2025-04-16 a7e6761ba0cfccdf33ed552eb2d3b783c8e4ab4a
src/components/LiveVideo.vue
@@ -20,6 +20,7 @@
let liveVideoRef = ref(null);
const play = (url) => {
   pause();
  webrtcPlayer = new window.ZLMRTCClient.Endpoint({
    element: liveVideoRef.value, // video 标签
    debug: true, // 是否打印日志
@@ -73,6 +74,7 @@
    )
};
// 销毁
const pause = () => {
  if (webrtcPlayer) {
    webrtcPlayer.close();
@@ -84,7 +86,6 @@
  (newValue) => {
    if (!newValue) return;
    nextTick(() => {
      pause();
      play(newValue);
    });
  },
@@ -92,6 +93,10 @@
    immediate: true
  }
);
onBeforeUnmount(() => {
   pause()
})
onMounted(() => {
  if (props.videoUrl) {
@@ -113,4 +118,4 @@
    object-fit: cover;
  }
}
</style>
</style>