【vue】Easy Player实现视频播放:


一、效果:

image.png

二、文档:

GitCode - EasyPlayer.js
npm-@easydarwin/easyplayer
29a6ec6a94724d7feb5aa3ea99264f7.png

三、实现:
【1】安装插件:
npm i @easydarwin/easyplayer
【2】引入js文件:

image.png
image.png

<script src="./EasyPlayer-lib.min.js"></script>
【3】使用:

image.png

<easy-player :videoUrl="videoUrl" fluent utoplay live stretch 
  style="width:480px;height:250px;"></easy-player>

import EasyPlayer from "@easydarwin/easyplayer"

components: { EasyPlayer },
四、方法:

image.png
image.png

  • 6
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
要使用vue-video-player实现实时视频播放,需要先安装vue-video-player插件并引入相关的组件和样式文件。具体步骤如下: 1. 安装vue-video-player插件: ``` npm install vue-video-player --save ``` 2. 在Vue3的入口文件main.js中引入vue-video-player插件和相关的样式文件: ``` import { createApp } from 'vue'; import App from './App.vue'; import VueVideoPlayer from 'vue-video-player'; import 'video.js/dist/video-js.css'; import 'vue-video-player/src/custom-theme.css'; const app = createApp(App); app.use(VueVideoPlayer); app.mount('#app'); ``` 3. 在Vue3的模板中,使用vue-video-player组件来加载视频文件,并设置autoplay和controls属性来自动播放和显示控制条: ``` <template> <div> <video-player ref="videoPlayer" autoplay controls></video-player> </div> </template> ``` 4. 在Vue3的组件中,使用mounted生命周期方法来获取video-player组件的引用,并添加事件监听器来实时监控视频播放: ``` <script> export default { mounted() { const videoPlayer = this.$refs.videoPlayer.$refs.video; videoPlayer.addEventListener('timeupdate', this.handleTimeUpdate); }, methods: { handleTimeUpdate() { const videoPlayer = this.$refs.videoPlayer.$refs.video; const currentTime = videoPlayer.currentTime; // 在这里可以处理视频播放时间的更新 } } } </script> ``` 5. 在handleTimeUpdate方法中,可以获取当前视频播放的时间,并进行处理。例如,可以将当前时间展示在页面上,或者根据时间来触发其他的事件。 需要注意的是,vue-video-player是基于video.js和Vue.js的开源插件,支持多种视频格式和播放器样式。使用vue-video-player可以方便地实现视频播放和控制,同时也提供了一些自定义的配置选项和事件回调函数。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Sun Peng

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值