|
@@ -22,6 +22,11 @@ export class SdkUtil {
|
|
|
public static tt_isSupportSidebar:boolean = false; //抖音_是否支持侧边栏
|
|
|
public static tt_isToEnterFromSidebar:boolean = false; //抖音_是否从侧边栏进入
|
|
|
|
|
|
+ private static ttGameRecorder:any = null; //抖音游戏录制
|
|
|
+ private static ttRecordVideoPath:string = ''; //抖音录制视频路径
|
|
|
+ private static ttTotalRecord:number = 300; //抖音总录制时间
|
|
|
+ private static ttIsRecording:boolean = false; //抖音是否录制中
|
|
|
+
|
|
|
/**
|
|
|
* 自定义事件统计
|
|
|
*
|
|
@@ -102,7 +107,7 @@ export class SdkUtil {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 抖音激励视频
|
|
|
+ * 抖音/微信激励视频
|
|
|
*
|
|
|
* @static
|
|
|
* @param {string} _adUnitId
|
|
@@ -120,14 +125,16 @@ export class SdkUtil {
|
|
|
if(sys.platform==sys.Platform.BYTEDANCE_MINI_GAME) {
|
|
|
SdkUtil.videoAd = tt.createRewardedVideoAd({adUnitId: _adUnitId});
|
|
|
} else if(sys.platform==sys.Platform.WECHAT_GAME) {
|
|
|
+ gameManager.Singleton.hideLoadingLevel()
|
|
|
call_back({"isEnded":true})
|
|
|
+ return
|
|
|
// SdkUtil.videoAd = wx.createRewardedVideoAd({adUnitId: _adUnitId});
|
|
|
}
|
|
|
|
|
|
if(SdkUtil.videoAd==null){
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
SdkUtil.videoAd.onLoad(() => {
|
|
|
SdkUtil.videoAd.show();
|
|
|
console.log("广告加载完成");
|
|
@@ -212,17 +219,85 @@ export class SdkUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 抖音开启屏幕录制
|
|
|
- */
|
|
|
+ // 抖音开启屏幕录制
|
|
|
public static ttStartScreenRecording() {
|
|
|
+ return
|
|
|
+ if(sys.platform!=sys.Platform.BYTEDANCE_MINI_GAME) {
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
+ if(this.ttIsScreenRecording()==true) {
|
|
|
+ this.ttStopScreenRecording()
|
|
|
+ }
|
|
|
+
|
|
|
+ this.ttIsRecording = true
|
|
|
+ if(!this.ttGameRecorder) {
|
|
|
+ this.ttGameRecorder = tt.getGameRecorderManager()
|
|
|
+ }
|
|
|
+ this.ttGameRecorder.start({duration: this.ttTotalRecord})
|
|
|
+ this.ttGameRecorder.onStart(()=> {
|
|
|
+ console.log('GameRecorder onStart onStart onStart')
|
|
|
+ })
|
|
|
+ this.ttGameRecorder.onStop((res)=> {
|
|
|
+ console.log('GameRecorder onStop onStop onStop=',res)
|
|
|
+ this.ttIsRecording = false
|
|
|
+ this.ttRecordVideoPath = res.videoPath
|
|
|
+ SdkUtil.ttShareScreenRecordVideo('测试测试',res.videoPath)
|
|
|
+ })
|
|
|
+ this.ttGameRecorder.onError((e)=> {
|
|
|
+ console.log('ttGameRecord error:',e)
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 抖音关闭屏幕录制
|
|
|
- */
|
|
|
+ // 抖音关闭屏幕录制
|
|
|
public static ttStopScreenRecording() {
|
|
|
+ return
|
|
|
+ if(sys.platform!=sys.Platform.BYTEDANCE_MINI_GAME) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if(this.ttGameRecorder == null) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ this.ttGameRecorder.stop()
|
|
|
+ }
|
|
|
|
|
|
+ // 抖音是否屏幕录制
|
|
|
+ public static ttIsScreenRecording():boolean {
|
|
|
+ return this.ttIsRecording;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 抖音获取屏幕录制视频文件
|
|
|
+ public static ttGetScreenRecordingVideoPath():string {
|
|
|
+ return this.ttRecordVideoPath;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 抖音分享屏幕录制视频
|
|
|
+ public static ttShareScreenRecordVideo(title: string, videoPath: string, onSuccess: Function = null, onFail: Function = null) {
|
|
|
+ tt.shareAppMessage({
|
|
|
+ title: title,
|
|
|
+ channel: "video",
|
|
|
+ extra: {
|
|
|
+ videoTopics: [],
|
|
|
+ hashtag_list: [],
|
|
|
+ videoPath: videoPath,
|
|
|
+ withVideoId: true,
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ console.log('抖音分享屏幕录制视频,成功=',res)
|
|
|
+ onSuccess && onSuccess();
|
|
|
+ },
|
|
|
+ fail: (e) => {
|
|
|
+ console.log('抖音分享屏幕录制视频,失败=',e)
|
|
|
+ // if(this.checkAppName()){
|
|
|
+ // onSuccess && onSuccess();
|
|
|
+ // }else{
|
|
|
+ // onFail && onFail();
|
|
|
+ // }
|
|
|
+ // 当前今日头条ios无法获得分享成功回调 if(res.platform === 'ios' && res.appName === 'Toutiao')
|
|
|
+ onFail && onFail()
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|