微信小程序video 点击自动全屏播放

java 复制代码
//因为这个地址可能是图片也可能是视频  点击 图片可以预览,点击视频可放大全屏自动播放。 代码如下
<view v-else :class='{contentImg: x.picture.length==0}' style="margin-top: 10px;"
								v-for="(x1, y1) in x.picture" :key="y">
								
								<image v-if="imgType.includes(x.picture[y1].split('.').pop())" style="width: 217px;height: 167px; margin-top: 14px"  :src="x.picture[y1]" @click="yulan(x.picture,y)">
								</image>

								
								<video  :id="'video_play'+x.id" v-else style="width: 217px;height: 167px; margin-top: 14px" @play="playVedio(x.id)" @fullscreenchange="fullscreenchange" :src="x.picture[y1]" :poster="x.capture_videos_img" controls   >
								</video>
							</view>
							
		<script>	
		methods: {				
     yulan(url,index){
			    uni.previewImage({
					urls: url, // 图片地址,urls是数组格式
					current: index, // 选填:图片默认打开第一张;第一次打开的图片url地址
					success: function(res) {
						console.log("333",res)
					},
					fail: function(res) {
						console.log("22",res)
					},
					complete: function(res) {
				    },
				})
		
		},
		playVedio(index){
				
				this.indexVideo=index;
				//此处需要注意一下,因为是for循环里边的视频或者图片吗,这里id要保持唯一,不然会出现无论点击哪一个都会播放同一个视频的情况。
				this.videoContext=uni.createVideoContext("video_play"+index,this);
				//进入全屏状态
				this.videoContext.requestFullScreen();
				
			},
			fullscreenchange(e) {
				
				if (!e.detail.fullScreen) {
				uni.createVideoContext('video_play'+this.indexVideo, this).pause();
				} 
			}
		}
		<script>
相关推荐
CHU72903515 小时前
便捷约玩,沉浸推理:线上剧本杀APP功能版块设计详解
前端·小程序
px不是xp19 小时前
微信小程序组件化开发最佳实践
微信小程序·小程序·notepad++
曲江涛19 小时前
微信小程序 摄像头 授权同页面丝滑调用
微信小程序
code_Bo20 小时前
kiro生成小程序商业案例
前端·微信小程序·小程序·云开发
编程迪21 小时前
基于SpringBoot开发的预约停车系统共享停车位小程序app
小程序·停车场小程序·预约停车·错峰出行·共享车位app
云起SAAS21 小时前
早晚安打卡签到小程序完整源码 | 三级分销+红包广告+PC后台 | 商业级系统
小程序
职豚求职小程序21 小时前
浙商银行笔试题库小程序练习2026新版题库
小程序
Kingexpand_com21 小时前
旅游小程序选型指南:模板与定制开发全解析
小程序·旅游·软件开发·小程序开发·旅游小程序·旅行·定制开发
克里斯蒂亚诺更新21 小时前
微信小程序引入vant weapp,button宽度100%
微信小程序·小程序
一品威客网1 天前
租车小程序 APP 版本开发 全端适配高效用车体验一站式搭建
小程序