Files
im/components/videoPlayer.vue
T

108 lines
1.9 KiB
Vue
Raw Normal View History

2025-11-27 07:48:42 +08:00
<template>
2025-12-11 22:33:31 +08:00
<u-overlay
v-if="previewVideoFlag"
:show="previewVideoFlag"
opacity="1"
:custom-style="customMaskStyle">
<view @tap.stop
class="playBox"
style="height:100vh;width:100vw;">
<video
v-if="previewVideoFlag"
:style="{height:videoHeight+'vw',width:'100vw'}"
:controls="true"
:show-fullscreen-btn="false"
:autoplay="true"
:src="previewVideoSrc"
@ended="play_end">
</video>
<view class="quitBox" @click="quitPlay">
<u-icon name="close-circle" color="#FFF" size="32"></u-icon>
<cover-view class="icon"></cover-view>
2025-11-27 07:48:42 +08:00
</view>
2025-12-11 22:33:31 +08:00
</view>
</u-overlay>
2025-11-27 07:48:42 +08:00
</template>
<script>
export default {
name:"videoPlayer",
props:{
previewVideoFlag:{
type:Boolean,
default:false,
required:true
},
previewVideoSrc:{
type:String,
default:"",
required:true
}
},
data() {
return {
customMaskStyle:{
display:"flex",
flexDirection: "column",
justifyContent: "center",
2025-12-11 22:33:31 +08:00
alignItems: "center"
2025-11-27 07:48:42 +08:00
},
2025-12-11 22:33:31 +08:00
videoHeight:100,
2025-11-27 07:48:42 +08:00
winHeight:0,
winWidth:0
};
},
2025-12-11 22:33:31 +08:00
watch:{
previewVideoSrc(nv,ov){
const _this = this;
console.log(nv,ov);
if(nv && nv != ov){
uni.getVideoInfo({
src:nv,
success(res) {
_this.videoHeight = res.width/ res.height * 100;
},
complete(res) {
console.log(res);
}
})
}
}
},
2025-11-27 07:48:42 +08:00
created:function(){
this.winHeight=this.$u.sys().windowHeight;
this.winWidth=this.$u.sys().windowWidth;
},
methods:{
2025-12-11 22:33:31 +08:00
play_end(res){
console.log(res);
},
2025-11-27 07:48:42 +08:00
quitPlay:function(){
2025-12-11 22:33:31 +08:00
console.log('quit');
2025-11-27 07:48:42 +08:00
this.$emit("quitPlay");
}
}
}
</script>
<style lang="scss">
.playBox{
2025-12-11 22:33:31 +08:00
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
2025-11-27 07:48:42 +08:00
}
.quitBox{
2025-12-11 22:33:31 +08:00
position: absolute;
z-index: 9999;
right: 5%;
top: 10%;
.icon{
color: #fff;
font-size: 32px;
font-family: uicon-iconfont;
}
2025-11-27 07:48:42 +08:00
}
</style>