xg
This commit is contained in:
parent
b62cb70255
commit
75ee36d1bc
@ -79,7 +79,7 @@
|
||||
}
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: `/pagesC/noticedetails/noticedetails?item=${JSON.stringify(item)}&title=${this.title}`
|
||||
url: `/pagesC/noticedetails/noticedetails?item=${JSON.stringify(item)}&title=${this.title}&videoId=${item.videoId}`
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
@ -11,6 +11,8 @@
|
||||
</view>
|
||||
<view class="" style="height: 2rpx;width: 100%;background-color: #f6f6f6;">
|
||||
</view>
|
||||
<video v-if="videoId" id="myVideo" @timeupdate="videoFun" :src="videoId" :initial-time="initial_time"
|
||||
@ended='ended' />
|
||||
<view class="text">
|
||||
<text>{{currentItem.content}}</text>
|
||||
</view>
|
||||
@ -18,11 +20,15 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import baseurl from '@/api/baseurl.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
currentItem: '',
|
||||
title: '',
|
||||
videoId: null,
|
||||
video_real_time: 0, //实时播放进度
|
||||
nitial_time: '', //视频跳转进度 秒
|
||||
};
|
||||
},
|
||||
onReady() { //更改导航栏文字
|
||||
@ -31,14 +37,55 @@
|
||||
});
|
||||
},
|
||||
onLoad(options) {
|
||||
this.initial_time = '0' //视频进度
|
||||
this.title = options.title
|
||||
this.currentItem = JSON.parse(options.item)
|
||||
if (options.videoId) {
|
||||
this.videoId = baseurl + `/applet/message/preview/${options.videoId}`
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
ended(e) {
|
||||
console.log(e)
|
||||
},
|
||||
videoFun(e) {
|
||||
var isReady = 1; // 是否开启可以视频快进 1 禁止开启
|
||||
//跳转到指定播放位置 initial-time 时间为秒
|
||||
let that = this;
|
||||
//播放的总时长
|
||||
var duration = e.detail.duration
|
||||
//实时播放进度 秒数
|
||||
var currentTime = parseInt(e.detail.currentTime)
|
||||
//当前视频进度
|
||||
// console.log("视频播放到第" + currentTime + "秒")//查看正在播放时间,以秒为单位
|
||||
if (that.video_real_time == 0) {
|
||||
var jump_time = parseInt(that.initial_time) + parseInt(that.video_real_time)
|
||||
} else {
|
||||
var jump_time = parseInt(that.video_real_time)
|
||||
}
|
||||
if (isReady == 1) {
|
||||
if (currentTime > jump_time && currentTime - jump_time > 3) {
|
||||
let videoContext = wx.createVideoContext('myVideo')
|
||||
videoContext.seek(that.video_real_time)
|
||||
wx.showToast({
|
||||
title: '未完整看完该视频,不能快进',
|
||||
icon: 'none',
|
||||
duration: 2000,
|
||||
})
|
||||
}
|
||||
}
|
||||
that.video_real_time = currentTime //实时播放进度
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.app {
|
||||
#myVideo {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.text {
|
||||
font-size: 24rpx;
|
||||
line-height: 40rpx;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user