在 pages.json同级目录下 创建目录和文件:

components:

videoComp:

  VideoPlaySelf.vue

VideoPlaySelf.vue 内容

<template>
<video class="video" id="myVideo"
:loop="false" direction="0" :src="videoUrl" @click="$emit('hideElement')" autoplay :controls="false"
@loadedmetadata="$emit('loadedmetadataStart',$event)" @timeupdate="$emit('videoTimeUpdate',$event)"
@ended="$emit('palyNextVideo',sectionId)" :show-center-play-btn="false" :show-play-btn="false"
:show-fullscreen-btn="false" :enable-progress-gesture="false">
</video>
</template> <script lang="ts">
import { defineComponent } from 'vue'
import nav from '@/utils/nav' export default defineComponent({
name: 'VideoPlaySelf',
props: ["videoUrl",'sectionId'],
data() { },
methods: {
getVideoContext() {
return nav.uniSelf.createVideoContext('myVideo', this);
},
videoPlay() {
nav.uniSelf.createVideoContext('myVideo', this).play();
},
videoPause() {
nav.uniSelf.createVideoContext('myVideo', this).pause();
},
videoSeek(second: number) {
nav.uniSelf.createVideoContext('myVideo', this).seek(second);
}
} })
</script> <style lang="scss">
.video {
position: absolute;
width: 100vw;
height: 100vh;
}
</style>

在对应的vue页面引入:

<template>
<view>
...
  <VideoPlaySelf
style="position: absolute; width: 100vw; height: 100vh;"
v-if="current === index && (item.videoUrl !== '')"
ref='videoPlaySelf'
:videoUrl="item.videoUrl" :sectionId="item.sectionId"
@hideElement="hideElement" @loadedmetadataStart="loadedmetadataStart" @videoTimeUpdate="videoTimeUpdate"
@palyNextVideo="palyNextVideo">  </VideoPlaySelf>
...
</view>
</template>

<script lang="ts">
import VideoPlaySelf from '@/components/videoComp/VideoPlaySelf.vue'; export default defineComponent({
  components: {
    VideoPlaySelf
  }
  ...
</script>

最新文章

  1. Python导出Excel为Lua/Json/Xml实例教程(三):终极需求
  2. ASP.NET 对于文件的下载与上传
  3. JAVA 语法基础综合练习——学生成绩管理系统
  4. Entity Framework技术导游系列 开篇 (转)
  5. Apache(Web)服务器性能调整
  6. 递归遍历树结构顺序显示并且添加到list集合
  7. Kali Linux 优化过程
  8. OSS研究
  9. HDOJ 1334 Perfect Cubes(暴力)
  10. SED&amp;AWK
  11. java.lang.ClassCastException: org.springframework.web.filter.CharacterEncodingFilter cannot be cast to javax.servlet.Filter
  12. 转: Apache开启gzip
  13. 百度地图 iOS SDK - 坐标转换方法
  14. redis持久化的几种方式
  15. 【Bootstrap】bootstrap-datetimepicker日期时间插件
  16. python css选择器
  17. MySQL系列详解五: xtrabackup实现完全备份及增量备份详解-技术流ken
  18. 二维数组遍历的方式(for普通循环遍历、foreach循环遍历、toString方式遍历)
  19. rpm命令如何打印调试信息?
  20. CSS:绝对定位布局案例 position布局实例

热门文章

  1. 树莓派3B+开启wifi
  2. Vue急速入门-5
  3. FTP客户端c代码功能实现
  4. JZOJ 7392. 【2021.11.17NOIP提高组联考】数 (ds)
  5. 不借助脚手架手动搭建react项目(webpack5 + Antd4 + React18)
  6. ACR2022的辩论:DMARDs在pre-RA中的作用
  7. Spring Boot 整合 Logback 日志
  8. svn拉取出现目标机器积极拒绝,无法连接
  9. ThreadLocal最终版本
  10. windows-sam文件