<template>
  <video controls autoplay muted class="video-stream" v-bind="$attrs" ref="videoContainerRef" />
</template>

<script>
import { HttpLivePlayer, openLiveVideo } from "./videoStream.js"

export default {
  name: 'Video',
  props: {
    camId: {
      type: String,
      default: null
    },
    pileNum: {
      type: String,
      default: null
    },
    url: {
      type: String,
      default: null
    }
  },
  async mounted() {
    const player = await openLiveVideo(this.$refs.videoContainerRef, { camId: this.camId, url: this.url, pileNum: this.pileNum })
    // const player = new HttpLivePlayer(this.$refs.videoContainerRef, { camId: this.camId, url: this.url, pileNum: this.pileNum });

    this.$once("hook:beforeDestroy", () => player?.destroy());
  }
}
</script>

<style lang='scss' scoped>
.video-stream {
  background-color: #000;
}
</style>
