赞
踩
接口是在其它csdn文章中找的
首先实现上下滑动的基本功能
然后再添加暂停播放功能
最后添加自定义slier进度条,通过点击或拖拽进度条进入到视频对应的时间位置
功能要素如下:
完整代码:
- <template>
- <view class="">
- <swiper class="swiper" :style="{height:screenHeight+'px'}" :vertical="true" :duration="1000"
- @transition="transition" @change="changed">
- <swiper-item class="swiper-item" :style="{height:screenHeight+'px'}" v-for="(item,index) in videoList"
- :key="index" >
- <!-- 11111{{index==changeIndex}} -->
- <video id="myVideo" class="playVideo" :style="{height:screenHeight+'px'}" object-fit="cover" autoplay
- :src="item.src" :controls="false" @tap="handleVideoTap" loop @timeupdate="onTimeUpdate($event)"
- @loadeddata="onVideoLoadedData(index)" @play="onVideoPlay" v-if="index==changeIndex||showFlag">
- </video>
- <!-- <image v-else class="fmBox" :src="item.fmsrc" mode="aspectFill"></image> -->
- <view class="txtWrap">
- <text class="nickname" style="color: #fff;font-size: 18px;">
- @Picnic熊
- </text>
- <text class="tit"
- style="width:500rpx;color: #fff;font-size: 14px;text-overflow: ellipsis; lines:2;">
- {{item.title}}
- </text>
- </view>
- </swiper-item>
- </swiper>
- <view class="iconWrap" :style="{height:screenHeight+'px'}">
- <image class="playIcon" src="/static/play.png" style="" v-if="!playFlag"></image>
- <view class="control_box">
-
- <slider class="sliderbox" :value="currentProgress" min="0" @change="sliderChange"
- @changing="sliderChanging" max="100" activeColor=" #6d6d6d" backgroundColor="#2f2f2f"
- block-color="#6d6d6d" block-size="12" />
-
- </view>
- <view class="changing" v-if="showChanging">
- <text style="color: #fff;font-size: 20px;">{{sliderchanging}}</text>
- <text style="color: #c5c5c5;font-size: 20px;">/ {{totalDuration}}</text>
- </view>
- </view>
- </view>
- </template>
-
-
- <script>
- export default {
- data() {
- return {
- screenHeight: 0,
- originList: [], // 源数据
- displaySwiperList: [], // swiper需要的数据
- displayIndex: 0, // 用于显示swiper的真正的下标数值只有:0,1,2。
- originIndex: 0, // 记录源数据的下标
- changeIndex: 0, //控制video是否渲染
- page: 0, // 视频分页
- num: 0,
- flag: true,
- showFlag:false,
- videoList: [{
- "src": "https://minivideo.xiu123.cn/original/79649956972748019fb7761c6852c5b1/25d3d19-17b2a2529da.mp4",
- "title": "……… 时过尽迁!",
- "fmsrc": "../../static/fm1.png"
- },
- {
- "src": "https://minivideo.xiu123.cn/original/6b474d2596d742ab8f1c1da42145ee4d/5a8969da-17afdba394d.mp4",
- "title": "完美收官/美女/靓仔",
- "fmsrc": "../../static/fm2.png"
- },
- {
- "src": "https://minivideo.xiu123.cn/original/95267608f6c94ec786bf2799add0aa7a/d5538f3-17b49507b12.mp4",
- "title": "人生不过如此,且行且珍惜。",
- "fmsrc": "../../static/fm.png"
- },
- {
- "src": "https://minivideo.xiu123.cn/original/e09a1efc53304a30b14258c9f81c53d3/2ca04e20-17b4ad28fe4.mp4",
- "title": "皮一下声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/人工智能uu/article/detail/1012258推荐阅读
相关标签
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。