Commit 0a284ed9 authored by lvtz's avatar lvtz

fix + add 学员详情音视频播放

parent 09b2e9fd
......@@ -13,7 +13,8 @@ import {
newCommentIndex
} from '../../../service/customer/circleindex.js';
import {
LocalStorage
LocalStorage,
audioorigin,
} from '../../../utilities/index.js';
function compare(property) {
......@@ -76,13 +77,22 @@ Page({
tid: 0,
cid: 0,
}
}
},
audioStorage: {},
videostatus: {
preSrc: '',
currentSrc: '',
videoShow: false,
videoId: '',
src: ''
},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.innerAudioContext = wx.createInnerAudioContext(); // 当前页面唯一的一个音频容器
const {
sid,
studentId
......@@ -123,14 +133,20 @@ Page({
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
this.innerAudioContext.pause();
this.resetAudiosPlayStatus()
clearInterval(this.data.voiceInterval);
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
this.innerAudioContext.pause();
this.setData({
audioStorage: {}
})
clearInterval(this.data.voiceInterval);
},
/**
......@@ -624,6 +640,162 @@ Page({
[`clockList[${listindex}][${index}]`]: _clockList[listindex][index]
})
},
// 跟录音相关的操作
// 跟录音相关的操作
// 播放录音的相关操作
// 格式是以录音名字为key value为{play: true || false, currentTime: 0}的一个对象
voiceIntervalPlay (value) { // 初始化录音的状态
let voiceInterval = setInterval(() => {
let audioStorage = this.data.audioStorage;
let currentTime = ++audioStorage[value].currentTime;
this.setData({
audioStorage
})
if (currentTime >= this.data.audioStorage[value].duration) {
audioStorage[value].play = false;
audioStorage[value].currentTime = 0;
this.setData({
audioStorage
})
clearInterval(this.data.voiceInterval);
}
}, 1000);
this.setData({
voiceInterval
})
},
playvoice (e) {
const {value, duration} = e.detail;
this.innerAudioContext.src = audioorigin(value);
this.innerAudioContext.obeyMuteSwitch = false;
this.resetAudiosPlayStatus();
clearInterval(this.data.voiceInterval);
let audioStorage = this.data.audioStorage;
if (!audioStorage[value]) {
audioStorage[value] = {
play: true,
currentTime: 0,
duration
}
} else {
if (audioStorage[value].currentTime == audioStorage[value].duration) {
audioStorage[value].currentTime = 0;
audioStorage[value].play = true;
} else {
audioStorage[value].play = true;
}
}
this.innerAudioContext.seek(audioStorage[value].currentTime)
this.innerAudioContext.play();
this.voiceIntervalPlay(value);
this.setData({
audioStorage,
})
},
pausevoice (e) {
const {value} = e.detail;
let audioStorage = this.data.audioStorage;
audioStorage[value].play = false;
this.setData({
audioStorage,
})
this.innerAudioContext.pause();
clearInterval(this.data.voiceInterval);
},
voiceslide (e) {
const {value, slide, duration} = e.detail;
let audioStorage = this.data.audioStorage;
if (!audioStorage[value]) {
audioStorage[value] = {
play: false,
currentTime: slide,
duration
}
} else {
audioStorage[value].currentTime = slide;
}
this.innerAudioContext.seek(slide);
this.setData({
audioStorage,
})
},
slidestart (e) {
const {value, slide} = e.detail;
let audioStorage = this.data.audioStorage;
if (audioStorage[value] && audioStorage[value].play) { // 如果当前是播放状态 则先暂停音乐盒计时器 播放按钮状态不需要改
this.innerAudioContext.pause();
clearInterval(this.data.voiceInterval);
} else { // 如果当前不是播放状态 则该干嘛干嘛
}
},
slideend (e) {
const {value, slide} = e.detail;
let audioStorage = this.data.audioStorage;
if (audioStorage[value] && audioStorage[value].play) { // 如果当前是播放状态 则启用定时器 播放按钮状态不需要改
// clearInterval(this.data.voiceInterval);
this.innerAudioContext.play();
this.voiceIntervalPlay(value);
} else { // 如果当前不是播放状态 则该干嘛干嘛
}
},
resetAudiosPlayStatus () { // 点击一个录音的时候把其他的录音状态改成暂停状态
let audioStorage = this.data.audioStorage;
Object.keys(audioStorage).forEach((key) => {
audioStorage[key].play = false
});
this.setData({
audioStorage,
})
},
delvoice (e) {
const {value} = e.detail;
let audioStorage = this.data.audioStorage;
if (audioStorage[value] && audioStorage[value].play) { // 如果当前是播放状态 删除录音的操作要把录音销毁掉
delete audioStorage[value]
this.innerAudioContext.pause();
clearInterval(this.data.voiceInterval);
}
this.setData({
audioStorage,
})
},
// 跟录音相关的操作
// 视频播放相关代码
playvideo (e) {
console.log(e)
const that = this;
const {src, from, mode} = e.detail;
this.setData({
'videostatus.videoId': src,
'videostatus.videoShow': true,
'videostatus.src': src,
'videostatus.mode': mode || 'mp4',
})
setTimeout(() => {
that.videoContext = wx.createVideoContext(src);
that.videoContext.play();
that.videoContext.requestFullScreen();
}, 500)
},
screenchange (e) {
const {fullScreen} = e.detail;
if (!fullScreen) { // 退出全屏时的操作
this.setData({
'videostatus.videoId': '',
'videostatus.videoShow': false,
'videostatus.src': '',
})
}
},
closeVideo () {
this.setData({
'videostatus.videoId': '',
'videostatus.videoShow': false,
'videostatus.src': '',
})
},
// 视频播放相关代码
showcommenteditor(e) {
const { listindex , index} = e.currentTarget.dataset;
Object.assign(this.data,{
......
......@@ -242,6 +242,10 @@
</view>
</view>
<view class="videodialog" wx:if="{{videostatus.videoShow}}">
<view class="videodialogmask" bindtap="closeVideo"></view>
<video class="" src="{{filter.transformOssVideofy(videostatus.src,videostatus.mode)}}" id="{{videostatus.videoId}}" initial-time="0" autoplay="false" loop="false" direction="0" bindplay="" bindpause="" bindended="" bindtimeupdate="" bindwaiting="" binderror="" bindfullscreenchange="screenchange"></video>
</view>
<view class="" data-editor="commenteditor">
<comment-editor wx:if="{{commenteditor}}" prams="{{commentclock}}" bind:hidecommenteditor="hidecommenteditor" type="2b"></comment-editor>
</view>
......
......@@ -32,7 +32,7 @@ Page({
onLoad: function (options) {
// 页面需要的参数sid
let that = this;
options.scene = 's=3&uuid=298bbb84';
// options.scene = 's=3&uuid=298bbb84';
if(options.scene){
let sceneQuery = scenQueryGet(options.scene);
const {s,uuid} = sceneQuery;
......@@ -43,9 +43,9 @@ Page({
that.schoolInfoGet();
})
}else{
const {sid,uuid} = options;
const {s,uuid} = options;
that.setData({
sid: sid,
sid: s,
uuid: uuid,
},()=>{
that.schoolInfoGet()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment