初始化(包含登录模块)

This commit is contained in:
2024-03-29 17:37:48 +08:00
commit 1bcb13ce7a
1306 changed files with 152772 additions and 0 deletions

View File

@@ -0,0 +1,104 @@
<template>
<div>
<video id='video1' class="video" :src="src" autoplay="false" duration="" controls="true" :danmu-list="list"
danmu-btn="true" enable-danmu="true" :loop="true" muted="true" initial-time="" direction="-90"
show-mute-btn="true" @play="onstart" @pause="onpause" @ended="onfinish" @error="onfail" @waiting="waiting"
@timeupdate="timeupdate" @fullscreenchange="fullscreenchange"></video>
<button class="btn" @click="play">播放</button>
<button class="btn" @click="pause">暂停</button>
<button class="btn" @click="seek">跳转到指定位置</button>
<button class="btn" @click="stop">停止</button>
<button class="btn" @click="fullScreen">全屏</button>
<button class="btn" @click="exitFullScreen">退出全屏</button>
<button class="btn" @click="playbackRate">设置倍速</button>
<button class="btn" @click="sendDanmu">发送弹幕</button>
</div>
</template>
<script>
export default {
data() {
return {
src: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4",
fil: true,
list: [{
text: '要显示的文本',
color: '#FF0000',
time: 9
}]
}
},
onReady() {
this.context = uni.createVideoContext("video1", this);
},
methods: {
onstart(e) {
console.log("onstart:" + JSON.stringify(e));
},
onpause(e) {
console.log("onpause:" + JSON.stringify(e));
},
onfinish(e) {
console.log("onfinish:" + JSON.stringify(e));
},
onfail(e) {
console.log("onfail:" + JSON.stringify(e));
},
fullscreenchange(e) {
console.log("fullscreenchange:" + JSON.stringify(e));
},
waiting(e) {
console.log("waiting:" + JSON.stringify(e));
},
timeupdate(e) {
console.log("timeupdate:" + JSON.stringify(e));
},
play() {
this.context.play();
},
pause() {
this.context.pause();
},
seek() {
this.context.seek(20);
},
stop() {
this.context.stop();
},
fullScreen() {
this.context.requestFullScreen({
direction: 90
});
},
exitFullScreen() {
this.context.exitFullScreen();
},
sendDanmu() {
this.context.sendDanmu({
text: '要显示的弹幕文本',
color: '#FF0000'
});
},
playbackRate() {
this.context.playbackRate(2);
}
}
}
</script>
<style>
.video {
width: 750rpx;
/* #ifdef H5 */
width: 100%;
/* #endif */
height: 400rpx;
background-color: #808080;
}
.btn {
margin-top: 5px;
margin-bottom: 5px;
}
</style>

View File

@@ -0,0 +1,94 @@
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt" v-if="showVideo">
<view>
<video id="myVideo" src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4"
@error="videoErrorCallback" :danmu-list="danmuList" enable-danmu danmu-btn controls poster="https://web-assets.dcloud.net.cn/unidoc/zh/poster.png"></video>
</view>
<!-- #ifndef MP-ALIPAY || MP-TOUTIAO || MP-KUAISHOU || MP-LARK || MP-JD -->
<view class="uni-list uni-common-mt">
<view class="uni-list-cell">
<view>
<view class="uni-label">弹幕内容</view>
</view>
<view class="uni-list-cell-db">
<input v-model="danmuValue" class="uni-input" type="text" placeholder="在此处输入弹幕内容" />
</view>
</view>
</view>
<view class="uni-btn-v">
<button @click="sendDanmu" class="page-body-button">发送弹幕</button>
</view>
<!-- #endif -->
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: 'video',
src: '',
danmuList: [{
text: '第 1s 出现的弹幕',
color: '#ff0000',
time: 1
},
{
text: '第 3s 出现的弹幕',
color: '#ff00ff',
time: 3
}
],
danmuValue: '',
showVideo: false
}
},
onReady: function(res) {
// #ifndef MP-ALIPAY || MP-TOUTIAO
this.videoContext = uni.createVideoContext('myVideo')
// #endif
// #ifdef APP-PLUS || MP-BAIDU
setTimeout(()=>{
this.showVideo = true
},350)
// #endif
// #ifndef APP-PLUS || MP-BAIDU
this.showVideo = true
// #endif
},
methods: {
sendDanmu: function() {
this.videoContext.sendDanmu({
text: this.danmuValue,
color: this.getRandomColor()
});
this.danmuValue = '';
},
videoErrorCallback: function(e) {
uni.showModal({
content: e.target.errMsg,
showCancel: false
})
},
getRandomColor: function() {
const rgb = []
for (let i = 0; i < 3; ++i) {
let color = Math.floor(Math.random() * 256).toString(16)
color = color.length == 1 ? '0' + color : color
rgb.push(color)
}
return '#' + rgb.join('')
}
}
}
</script>
<style>
video {
width: 690rpx;
width: 100%;
height: 400px;
}
</style>