zhengshuiqi 3 years ago
parent
commit
981fbfbe3a
  1. 47
      pages/index/index.vue

47
pages/index/index.vue

@ -1155,6 +1155,37 @@
block_name: item.short_name,
goodid: item.id
})
//
const videoContext = uni.createVideoContext('myVideo');
//
let videoFrames = [];
let videoDuration = 0;
uni.getVideoInfo({
src: item.goods_video,
success: (res) => {
videoDuration = res.duration;
let frameCount = Math.ceil(videoDuration * 25);
for (let i = 0; i < frameCount; i++) {
videoFrames.push(item.goods_video + '#t=' + (i / 25));
}
}
});
// setInterval
let currentFrameIndex = 0;
let interval = setInterval(() => {
if (currentFrameIndex >= videoFrames.length) {
clearInterval(interval);
return;
}
videoContext.src = videoFrames[currentFrameIndex];
currentFrameIndex++;
}, 40);
console.log(videoFrames);
})
//////console.log(this.bestlist,'')
const that = this
@ -1635,13 +1666,13 @@
<view class="left">
<view v-for="(item,index) in leftList" :key="index">
<block v-if="item.goods_video">
<scroll-view style="position: relative;">
<view style="position: relative; height: 225px;">
<video :autoplay="true" :enable-progress-gesture="true" muted="" style="width: 100%;"
:mobilenet-hint-type="1" class="video_play" :http-cache="true"
:mobilenet-hint-type="1" class="video_play" :http-cache="true" loop
object-fit="contain" :direction="0" :src="item.goods_video" :show-mute-btn="true"
@touchstart="touchStart" @touchend="touchEnd" @pause="VideoPuse()">
</video>
</scroll-view>
</view>
<view class="play_icon" v-show="!video" @click="isVideo"></view>
</block>
@ -1665,13 +1696,13 @@
<view class="right">
<view v-for="(item1,index1) in rightList" :key="index1">
<block v-if="item1.goods_video">
<scroll-view style="position: relative;">
<view style="position: relative; height: 225px;">
<video x5-video-player-type="h5-page" :autoplay="true" :enable-progress-gesture="true" muted="" style="width: 100%;"
:mobilenet-hint-type="1" class="video_play" :http-cache="true" @pause="VideoPuse()"
:mobilenet-hint-type="1" class="video_play" :http-cache="true" @pause="VideoPuse()" loop
object-fit="contain" :direction="0" :src="item1.goods_video" :show-mute-btn="true"
@touchstart="touchStart" @touchend="touchEnd">
</video>
</scroll-view>
</view>
<view class="play_icon" v-show="!video" @click="isVideo"></view>
</block>
<image v-else :src="item1.block_pic" alt="" mode="widthFix" @click="imgTo(item1)"
@ -1778,6 +1809,10 @@
}
</style>
<style lang="scss" scoped>
uni-video {
position: absolute !important;
height: 225px !important;
}
.swiper-items {
border-radius: 30rpx;
overflow: hidden;

Loading…
Cancel
Save