jPlayerDemo.vue 1.66 KB
<template>
  <div class="j-player-demo">
    <div class="player-content">
      <j-player ref="jplay"
        :type="playerType"
        prefix-url=""
        player-address="52.130.155.147"
        channel-id="20000000001310000008"
        :datetime-range="datetimeRange"
        watermarkText="方案智能"
      />
    </div>
    <div class="footer">
      <button @click="handleLive">直播</button>
      <button @click="handlePlayback">回放</button>
      <button @click="handleStop">停止</button>
      <button @click="handleScreenshot">抓拍</button>
    </div>
  </div>
</template>

<script>
import JPlayer from '../../components/jPlayer';

export default {
  name: 'JPlayerDemo',
  data() {
    return {
      playerType: 'live',
      datetimeRange: [],
    }
  },
  components: {
    JPlayer,
  },
  methods: {
    handleLive() {
      this.playerType = 'live';
    },
    handlePlayback() {
      this.playerType = 'playback';
      this.datetimeRange = [
        '1693904400000',
        '1693908000000',
      ];
    },
    handleScreenshot() {
      this.$refs.jplay.screenshotWatermark().then(data => {
        console.log('handleScreenshot', data);
      });
    },
    handleStop() {
      const result = this.$refs.jplay.stopPlay();
      console.log('handleStop', result);
    },
  },
}
</script>

<style lang="scss" scoped>
.j-player-demo {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  outline: 1px solid #ccc;
  padding-top: 10px;
  padding-bottom: 10px;
  > .player-content {
    width: 800px;
    height: 480px;
  }
  > .footer {
    margin-top: 10px;
    > button {
      margin-right: 10px;
    }
  }
}
</style>