微信小程序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>
相关推荐
倒流时光三十年4 小时前
第十八章 搜索历史保存功能实现记录
spring boot·微信小程序
倒流时光三十年5 小时前
第十七章 投票页面增加搜索功能
spring boot·微信小程序
博客zhu虎康6 小时前
小程序:UGC自定义发布内容接入微信公众平台内容安全API(imgSecCheck、msgSecCheck、mediaCheckAsync)
安全·小程序·微信公众平台
静Yu7 小时前
我用Codex开发的第一个朋友圈九宫格素材小程序上线啦
微信小程序·小程序·云开发
kyriewen1 天前
一个人+Cursor,7天上线付费小程序:第1天我就想放弃了
前端·微信小程序·cursor
暗不需求1 天前
从路虎汽车小程序看微信小程序开发的最佳实践
前端·javascript·微信小程序
博客zhu虎康1 天前
小程序:解决小程序发布上线后无分享功能
小程序
tuanyuan99o2 天前
2026商城小程序的安全怎么保障?防止黑客攻击和数据泄露
安全·小程序
facetarzan2 天前
微信小程序文件下载
小程序·文件预览·文件下载
aiguangyuan2 天前
微信小程序服务商
微信小程序·前端开发