vue项目使用阿里云播放器 Prismplayer 组件,可记录播放时间

阿里云播放器相较于video标签 兼容性更强,能支持更多格式的视频,所以在开发的时候阿里云播放器也用的很多

代码如下:

html代码

<template>
  <div class="player-wrapper">
    <div class="prism-player" :id="playerId"></div>
  </div>
</template>

js代码
组件传值:
必传: resource对象 包含bigCover(封面), viewPath(视频路径)
可传:isRecordPlayTime(是否记录播放时间), lastPlayTime(上次播放时间)


<script>
const cssUrl = 'https://g.alicdn.com/de/prismplayer/2.8.1/skins/default/aliplayer-min.css'
const jsUrl = 'https://g.alicdn.com/de/prismplayer/2.8.1/aliplayer-min.js'

export default {
   
  name: 'VideoPlayer',

  props: {
   
    resource: {
   
      type: Object,
      default: () => {
    },
    },
    isRecordPlayTime: {
   
      type: Boolean,
      default: false
    },
    lastPlayTime: {
   
      type: Number,
      default: 0
    }
  },

  components: {
   },

  computed: {
   },

  data () {
   
    return {
   
      playerId: `player-${
     Math.random().toString(36).substr(2).toLocaleUpperCase()}`,
      recordTimerInterval: 1000 * 60 * 2, // 记录播放资源的时间间隔 2分钟
      recordTimer: null
    }
  },

  filters: {
   },

  created () {
    },

  mounted () {
    },

  destroyed () {
   
    clearInterval(this.recordTimer)
  },

  watch: {
   
    resource: {
   
      handler (newValue, oldValue) {
   
        if (newValue && newValue.id) {
   
          this.$nextTick(() => {
   
            this.loadAliPlayer(
  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值