//wx.wxml文件
<view class="title">3.视频管理</view>
<view class="demo-box">
<view class="title">视频管理综合应用</view>
<button bindtap="chooseVideo">选择视频</button>
<video id="myVideo" src="{{src}}" enable-danmu danmu-btn controls></video>
<button type="primary" size="mini" bindtap="play">播放</button>
<button type="primary" size="mini" bindtap="pause">暂停</button>
<button type="primary" size="mini" bindtap="saveVideo">保存</button>
<input placeholder="请在此处输入弹幕" bindblur="bindInputBlur"></input>
<button type="primary" size="mini" bindtap="bindSendDanmu">发送弹幕</button>
</view>
//wx.js文件
// pages/test5/test5.js
//生成随机颜色
function getRandomColor()
{
let rgb=[]
for(let i=0;i<3;++i)
{
let color=Math.floor(Math.random()*256).toString(16)
color=color.length==i?'0'+color:color
rgb.push(color)
}
return '#'+rgb.join('')
}
Page({
// data: {
// src:"http://localhost/music/Uptown Funk.mp4"
// },
chooseVideo:function(){
var that=this
wx.chooseVideo({
sourceType: ['album','camera'],
maxDuration: 60,
camera:'back',
success: function(res) {
that.setData({
src:res.tempFilePath
})
}
})
},
//开始播放
play: function () {
this.videoContext.play()
},
//暂停播放
pause: function () {
this.videoContext.pause()
},
//保存视频
saveVideo: function () {
var src=this.data.src
wx.saveVideoToPhotosAlbum({
filePath:src,
success: function(res) {
wx.showToast({
title: '保存成功'
})
}
})
},
inputValue:'',//弹幕文本内容
//更新弹幕文本
bindInputBlur:function(e){
this.inputValue=e.detail.value
},
//发送弹幕
bindSendDanmu:function(){
this.videoContext.sendDanmu({
text:this.inputValue,
color:getRandomColor()
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.videoContext=wx.createVideoContext('myVideo')
}
})
在模拟器和手机上测试的时候,其他功能都没问题,就是保存视频的功能(saveVideo)失效,请问应该怎么修改?