文章來源地址http://www.zghlxwxcb.cn/news/detail-825848.html
//因為這個地址可能是圖片也可能是視頻 點擊 圖片可以預(yù)覽,點擊視頻可放大全屏自動播放。 代碼如下
<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是數(shù)組格式
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循環(huán)里邊的視頻或者圖片嗎,這里id要保持唯一,不然會出現(xiàn)無論點擊哪一個都會播放同一個視頻的情況。
this.videoContext=uni.createVideoContext("video_play"+index,this);
//進入全屏狀態(tài)
this.videoContext.requestFullScreen();
},
fullscreenchange(e) {
if (!e.detail.fullScreen) {
uni.createVideoContext('video_play'+this.indexVideo, this).pause();
}
}
}
<script>
文章來源:http://www.zghlxwxcb.cn/news/detail-825848.html
到了這里,關(guān)于微信小程序video 點擊自動全屏播放的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!