提交 69f68c9d authored 作者: zyx's avatar zyx

设置video001 和 添加 接口 /v2/education/end-aliyun-video-streaming

上级 762d2c5f
...@@ -99,6 +99,14 @@ const getCurrentChapterDetail = (vid, videoType,callback) => { ...@@ -99,6 +99,14 @@ const getCurrentChapterDetail = (vid, videoType,callback) => {
vid: vid vid: vid
}, },
callback: function (res) { callback: function (res) {
// 进入视频,开始读取视频时,存储 vid、log_key
wx.setStorageSync({
key: 'video_001',
data: {
vid: vid,
log_key: res.data.log_key || ''
}
})
let json = { let json = {
video: { video: {
src: res.data.video.SD, src: res.data.video.SD,
...@@ -119,6 +127,19 @@ const getCurrentChapterDetail = (vid, videoType,callback) => { ...@@ -119,6 +127,19 @@ const getCurrentChapterDetail = (vid, videoType,callback) => {
} }
}) })
} }
/* 结束时,调用接口 */
const endVideo = () => {
let json = wx.getStorageSync('video_001') || { vid: '', log_key: '' }
if (vid !== '') {
util.requestApi({
url: util.config.URL_PATH1 + '/v2/education/end-aliyun-video-streaming',
data: json,
callback: function (res) {}
})
}
}
/* 获取进度信息 */ /* 获取进度信息 */
// 测试 用 device_id : jjhz92fn0.le2a6c06c9g0.thhg7ekb1f8 // 测试 用 device_id : jjhz92fn0.le2a6c06c9g0.thhg7ekb1f8
const getProgress = (vid, did, sid, callback) => { const getProgress = (vid, did, sid, callback) => {
...@@ -136,9 +157,11 @@ const getProgress = (vid, did, sid, callback) => { ...@@ -136,9 +157,11 @@ const getProgress = (vid, did, sid, callback) => {
const updateProgress = (obj) => { const updateProgress = (obj) => {
let uid = wx.getStorageSync('uid'); let uid = wx.getStorageSync('uid');
let sid = wx.getStorageSync('sid'); let sid = wx.getStorageSync('sid');
let json = wx.getStorageSync('video_001') || { vid: '', log_key: '' };
util.requestApi({ util.requestApi({
url: util.config.URL_PATH1 + '/v2/analytics/upload-video', url: util.config.URL_PATH1 + '/v2/analytics/upload-video',
data: { data: {
log_key: json.log_key,
uid: uid || '', uid: uid || '',
sid: sid || '', sid: sid || '',
d: obj.did, d: obj.did,
...@@ -157,6 +180,7 @@ const updateProgress = (obj) => { ...@@ -157,6 +180,7 @@ const updateProgress = (obj) => {
module.exports = { module.exports = {
getChapterList: getChapterList, getChapterList: getChapterList,
getCurrentChapterDetail: getCurrentChapterDetail, getCurrentChapterDetail: getCurrentChapterDetail,
endVideo: endVideo,
getProgress: getProgress, getProgress: getProgress,
updateProgress: updateProgress updateProgress: updateProgress
} }
\ No newline at end of file
...@@ -174,6 +174,7 @@ Page({ ...@@ -174,6 +174,7 @@ Page({
}) })
// CC视频走这个接口 // CC视频走这个接口
ChapterApi.getCurrentChapterDetail(vid, videoType, (json) => { ChapterApi.getCurrentChapterDetail(vid, videoType, (json) => {
ChapterApi.endVideo()
// 播放的视频数据 // 播放的视频数据
this.setData({ video: json.video }) this.setData({ video: json.video })
this.setData({ audio: json.audio }) this.setData({ audio: json.audio })
...@@ -208,9 +209,11 @@ Page({ ...@@ -208,9 +209,11 @@ Page({
this.isBackend = true this.isBackend = true
this.pauseVA() this.pauseVA()
clearInterval(this.heartbeat) clearInterval(this.heartbeat)
ChapterApi.endVideo()
}, },
onUnload: function () { onUnload: function () {
this.pauseVA() this.pauseVA()
ChapterApi.endVideo()
}, },
onShow: function () { onShow: function () {
/* 兼容 android 这里发现 android 打开预览大图,然后关闭 自动播放视频,而且关不掉, 兼容android强制关闭视频 */ /* 兼容 android 这里发现 android 打开预览大图,然后关闭 自动播放视频,而且关不掉, 兼容android强制关闭视频 */
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论