uniapp+uview 简单实现视频播放

 

<template>
	<view class="container">
		<view class="myVideo">
			<video id="myVideo" :style="{ height: windowHeight + 'px' }" style="width: 100%;" :src="videourl"
				@error="videoErrorCallback" autoplay="true" show-center-play-btn="false" enable-play-gesture="true" v-if="type == 1">
				<cover-image class="close_video status-bar-height" @click="btn_closeVideo" src="../../static/guanbi.png"></cover-image> 
			</video>
			<u-swiper :list="imgList" bg-color="#000000" border-radius="0" style="height: 100vh;" img-mode="aspectFit" duration="1000" mode='rect' v-else/>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				windowHeight: 0,
				videourl: '',
				imgList:[],
				type:''
			}
		},
		onLoad(option) {
			console.log("option==>",option)
			if(option){
				this.type = Number(option.type)
				this.videourl = option.url
				if(this.type == 2){
					// 播放图集列表
				}
			}
			
		},
		onReady() {
			
			let that = this
			uni.getSystemInfo({
				success: function(res) {
					that.windowHeight = res.windowHeight
				}
			})
		},
		methods: {
			videoErrorCallback: function(e) {
				console.log(e)
			},
			leftClick(){
				
			},
			btn_closeVideo() {
				uni.navigateBack()
			}
		}
	}
</script>
<style>
	page {
		height: 100%;
		
	}
	/deep/.u-indicator-item-rect{
		width: 156rpx!important;
		background-color: rgba(255, 255, 255, .28)!important;
	}
	/deep/.u-indicator-item-rect-active{
		background-color: rgba(255, 255, 255, .7)!important;
	}
	/deep/.u-swiper-indicator{
		bottom: 88rpx!important;
	}
	uni-swiper{
		height: 100%!important;
	}
</style>
<style lang="scss">
	.container {
		height: 100%;
	
		.myVideo {
			position: relative;

			.close_video {
				position: absolute;
				top: 10px;
				left: 20px;
				width: 30px;
				height: 30px;
				background: rgba(255, 255, 255, .2);
			}
		}
	}
</style>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值