视频模块

This commit is contained in:
张文涛 2024-10-23 22:24:40 +08:00
parent 2572f8273f
commit a4311e3f9e
5 changed files with 391 additions and 1 deletions

View File

@ -0,0 +1,199 @@
<template>
<view class="content">
<video id="playVideo" class="top-video" :src="url" :picture-in-picture-mode="wxsetPicture"
:show-screen-lock-button="lockButton" :show-casting-button="showCasting" autoplay="true"
@fullscreenchange="fullscreenchange" @controlstoggle="controlstoggle">
<cover-view class="video-heizith-menu" @tap.stop="showSpeedOptions"
v-show="isShowControl">{{playbackRateItem == '1.0'?'倍数':playbackRateItem+'x'}}</cover-view>
<cover-view v-if="showSpeedModal" class="modal" @tap.stop="hideSpeedOptions">
<cover-view class="modal-content" @click.stop>
<cover-view class="modal-content-txt">
倍数
</cover-view>
<cover-view class="speed-option" v-for="(items,indexs) in playbackRateList" :key="indexs"
@tap.stop="changeSpeed" :data-rate="items" :class="{ active: items == playbackRateItem }">
{{ items }}X
</cover-view>
</cover-view>
</cover-view>
</video>
</view>
</template>
<script>
export default {
props: {
showCasting: { //
type: Boolean,
default: false
},
lockButton: { //
type: Boolean,
default: false
},
isSpeed: { //
type: Boolean,
default: false
},
url: { //
type: String,
default: ''
},
},
data() {
return {
wxsetPicture: [
'push',
'pop'
],
//
isShowControl: false,
//
playbackRateItem: '1.0',
//
playbackRateList: ['0.5', '0.8', '1.0', '1.25', '1.5', '2.0'],
showSpeedModal: false,
videoCtx: null,
fullScreen: false
}
},
methods: {
//
showSpeedOptions() {
this.showSpeedModal = true;
},
//
hideSpeedOptions() {
this.showSpeedModal = false;
},
//
changeSpeed(e) {
this.playbackRateItem = e.currentTarget.dataset.rate;
let rate = Number(this.playbackRateItem);
this.videoCtx = uni.createVideoContext('playVideo', this);
this.videoCtx.playbackRate(rate);
this.hideSpeedOptions();
},
//
controlstoggle(e) {
if (!e.detail.show) {
this.isShowControl = false;
return;
}
this.isShowControl = true;
},
//
fullscreenchange(e) {
let that = this;
that.fullScreen = e.detail.fullScreen;
if (that.fullScreen) {
wx.setPageOrientation({
orientation: 'landscape'
});
} else {
wx.setPageOrientation({
orientation: 'portrait'
});
}
uni.showToast({
title: that.fullScreen ? '开启全屏' : '关闭全屏',
icon: 'none',
duration: 1500
});
},
}
}
</script>
<style>
page {
width: 100%;
height: auto;
}
.content {
position: relative;
width: 750rpx;
height: auto;
min-height: 100vh;
margin: 0;
padding: 0;
background-color: #fff;
}
.top-video {
width: 100%;
height: 422rpx;
}
.video-heizith-menu {
position: absolute;
right: 30rpx;
bottom: 20%;
z-index: 998;
font-size: 20rpx;
width: 52rpx;
height: 40rpx;
text-align: center;
line-height: 38rpx;
border: 1rpx solid #c9cccc;
border-radius: 8rpx;
color: #c9cccc;
}
.modal {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
z-index: 9999;
}
.modal-content {
position: absolute;
left: 46rpx;
bottom: 20%;
z-index: 9999;
}
.modal-content-txt {
text-align: left;
padding-bottom: 20rpx;
color: #fff;
font-size: 18rpx;
z-index: 9999;
}
.speed-option {
float: left;
width: 72rpx;
height: 72rpx;
text-align: center;
line-height: 68rpx;
font-size: 22rpx;
color: #fff;
background-color: rgba(0, 0, 0, 0.3);
border-radius: 4rpx;
margin-right: 10rpx;
z-index: 9999;
}
.speed-option.active {
/* border-bottom: 2rpx solid #fd750b; */
color: #fd750b;
}
</style>

View File

@ -15,7 +15,9 @@
"autoclose" : true,
"delay" : 0
},
"modules" : {},
"modules" : {
"VideoPlayer" : {}
},
"distribute" : {
"android" : {
"permissions" : [

View File

@ -139,6 +139,15 @@
}
}
},
{ //
"path": "pages/news/course",
"style": {
"navigationBarTitleText": "课程",
"app-plus": {
"bounce": "none"
}
}
},
{ // //
"path": "pages/news/news-topic-cate",
"style": {

View File

@ -152,6 +152,8 @@
},
//
goDetail() {
this.$u.route('pages/news/course')
return
if (this.isDetail) return //
this.$u.route('pages/home/detail', {
data: JSON.stringify({

178
pages/news/course.vue Normal file
View File

@ -0,0 +1,178 @@
<template>
<view class="content" >
<zxVideo :url="urls" :isSpeed="isSpeed" :showCasting="showCasting" :lockButton="lockButton"></zxVideo>
</view>
</template>
<script>
import zxVideo from '@/components/zx-video/zx-video.vue';
export default {
components: {
zxVideo
},
data() {
return {
urls:'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4',
//
isSpeed:true,
//
showCasting:true,
//
lockButton:true
}
},
onLoad(option) {
},
onShow() {
},
methods: {
}
}
</script>
<style>
page {
width: 100%;
height: auto;
}
.content {
position: relative;
width: 750rpx;
height: auto;
min-height: 100vh;
margin: 0;
padding: 0;
background-color: #fff;
}
.top-video {
width: 100%;
height: 422rpx;
}
.mvdetail {
width: 100%;
padding: 50rpx 40rpx 30rpx;
box-sizing: border-box;
}
.mvdetail-name {
float: left;
width: 100%;
font-size: 32rpx;
font-weight: 700;
text-align: left;
color: #333;
text-overflow: ellipsis;
}
.mvdetail-tag {
float: left;
width: 100%;
font-size: 24rpx;
font-weight: 400;
text-align: left;
color: #6cb5ff;
margin-top: 10rpx;
}
.mvdetail-tag-item {
margin-right: 20rpx;
}
.mvdetail-desc {
float: left;
width: 100%;
font-size: 24rpx;
font-weight: 400;
text-align: left;
color: #666;
margin-top: 30rpx;
padding-bottom: 24rpx;
}
.mvdetail-btn {
float: left;
width: 100%;
}
.share-item {
width: 134rpx;
height: 46rpx;
border: 2rpx solid #d2d2d2;
border-radius: 24rpx;
padding: 0 18rpx;
box-sizing: border-box;
}
.share-item-img {
float: left;
width: 26rpx;
margin-top: 8rpx;
}
.share-item-title {
float: left;
font-size: 24rpx;
font-weight: 400;
color: #666;
line-height: 1;
margin: 10rpx 0 0 16rpx;
}
.video-heizith-menu {
position: absolute;
right: 30rpx;
bottom: 20%;
z-index: 998;
font-size: 20rpx;
width: 52rpx;
height: 40rpx;
text-align: center;
line-height: 38rpx;
border: 1rpx solid #fff;
border-radius: 8rpx;
color: #fff;
}
.modal {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
z-index: 9999;
}
.modal-content {
position: absolute;
left: 46rpx;
bottom: 20%;
z-index: 9999;
}
.modal-content-txt {
text-align: left;
padding-bottom: 20rpx;
color: #fff;
font-size: 18rpx;
z-index: 9999;
}
.speed-option {
float: left;
width: 72rpx;
height: 72rpx;
text-align: center;
line-height: 68rpx;
font-size: 22rpx;
color: #fff;
background-color: rgba(0, 0, 0, 0.3);
border-radius: 4rpx;
margin-right: 10rpx;
z-index: 9999;
}
.speed-option.active {
/* border-bottom: 2rpx solid #fd750b; */
color: #fd750b;
}
</style>