Object {errMsg: "shareAppMessage:fail file ...
errMsg: "shareAppMessage:fail file not readable path: ttfile://temp/700049693.596071_game_recorderVideo.mp4"
errNo: 21104
__proto__: Object
let tt = window['tt'] || {};
export default class byteDance extends basePlatform {
protected static _instance: byteDance;
private _isStart: boolean = false;
private _shareVideoUrl: string = null;
private _gameRecorder: any = null;
static get instance() {
if (this._instance == null) {
this._instance = new byteDance();
this._instance.init();
}
return this._instance;
}
// 开始录屏
startRecord() {
let self = this
if (!self._isStart) {
self._gameRecorder = tt.getGameRecorderManager()
self._gameRecorder.onStop((res) => {
console.info('录屏文件地址:'+ res.videoPath)
self._isStart = false;
self._shareVideoUrl = res.videoPath
})
//录屏开始
self._gameRecorder.onStart(() => {
self._isStart = true;
console.log('录屏开始...');
});
self._gameRecorder.onError((res) => {
console.log("错误", res);
});
self._gameRecorder.start({
duration: 300
})
}
}
// 停止录屏
stopRecord() {
if (this._gameRecorder != null && this._isStart) {
this._gameRecorder.stop();
}
}
// 分享到好友
shareAppMessage(type: number) {
let self = this
if (!self._isStart && self._shareVideoUrl) {
tt.shareAppMessage({
title: "快来看我正在玩猪猪世界",
channel: "video",
extra: {
videoPath: self._shareVideoUrl,
withVideoId: true,
},
success(res) {
console.info('分享成功')
console.info(res)
self._isStart = false;
self._gameRecorder = null;
},
fail(error){
if (error.errNo == 21105) {
viewMgr.instance.showTips("<color=#ffffff>录屏时长太短</c>");
}
self._isStart = false;
self._gameRecorder = null;
self._shareVideoUrl = null;
console.info('分享失败')
console.info(error)
}
});
} else {
viewMgr.instance.showTips("<color=#ffffff>没有录屏无法分享</c>");
}
}
recordStatus() : number {
var status = 0;
if (!this._isStart && !this._shareVideoUrl)
status = 0;
else if (this._isStart && !this._shareVideoUrl)
status = 1;
else
status = 2;
return status;
}
};