Bläddra i källkod

添加头条录屏功能

tang biao 5 år sedan
förälder
incheckning
93f22b9a3b

BIN
assets/resources/textures/game/record_start.png


+ 31 - 0
assets/resources/textures/game/record_start.png.meta

@@ -0,0 +1,31 @@
+{
+  "ver": "2.2.0",
+  "uuid": "93c1aa2d-cb0f-4ca7-b59b-bc0688c60558",
+  "type": "sprite",
+  "wrapMode": "clamp",
+  "filterMode": "bilinear",
+  "premultiplyAlpha": false,
+  "subMetas": {
+    "record_start": {
+      "ver": "1.0.3",
+      "uuid": "69496493-f55e-46d9-8895-d280a1a1acea",
+      "rawTextureUuid": "93c1aa2d-cb0f-4ca7-b59b-bc0688c60558",
+      "trimType": "auto",
+      "trimThreshold": 1,
+      "rotated": false,
+      "offsetX": -1,
+      "offsetY": -3,
+      "trimX": 0,
+      "trimY": 6,
+      "width": 102,
+      "height": 76,
+      "rawWidth": 104,
+      "rawHeight": 82,
+      "borderTop": 0,
+      "borderBottom": 0,
+      "borderLeft": 0,
+      "borderRight": 0,
+      "subMetas": {}
+    }
+  }
+}

BIN
assets/resources/textures/game/record_video.png


+ 31 - 0
assets/resources/textures/game/record_video.png.meta

@@ -0,0 +1,31 @@
+{
+  "ver": "2.2.0",
+  "uuid": "f1ac1cb9-226d-4f46-aa8d-232414b0cc9c",
+  "type": "sprite",
+  "wrapMode": "clamp",
+  "filterMode": "bilinear",
+  "premultiplyAlpha": false,
+  "subMetas": {
+    "record_video": {
+      "ver": "1.0.3",
+      "uuid": "8ffee2f2-b3a5-4e36-982c-bc062b80f9ee",
+      "rawTextureUuid": "f1ac1cb9-226d-4f46-aa8d-232414b0cc9c",
+      "trimType": "auto",
+      "trimThreshold": 1,
+      "rotated": false,
+      "offsetX": 0,
+      "offsetY": -3,
+      "trimX": 1,
+      "trimY": 6,
+      "width": 102,
+      "height": 76,
+      "rawWidth": 104,
+      "rawHeight": 82,
+      "borderTop": 0,
+      "borderBottom": 0,
+      "borderLeft": 0,
+      "borderRight": 0,
+      "subMetas": {}
+    }
+  }
+}

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 747 - 243
assets/scene/game.fire


+ 0 - 29
assets/scripts/game/Game.js

@@ -439,34 +439,5 @@ cc.Class({
         }
     },
 
-    //处理头条录制视频然后分享的功能
-    handleTTRecordVideo: _.debounce((event) => {
-        const recorder = tt.getGameRecorderManager();
-
-        recorder.start({
-        microphoneEnabled: true,
-        })
-
-        recorder.onStart(res =>{
-        // 录屏开始
-        console.log(res.microphoneStatus);
-        // do somethine;
-        })
-
-        recorder.onStop(res =>{
-        // 录屏结束;
-        console.log(res.videoPath);
-        })
-
-        recorder.onPause(() =>{
-        // 录屏已暂停;
-        })
-
-        recorder.onResume(() =>{
-        // 录屏已恢复;
-        })
-
-
-    }, 1000, true),
     // update (dt) {},
 });

+ 72 - 3
assets/scripts/game/HomeSideCtrl.js

@@ -35,6 +35,14 @@ cc.Class({
         storeNode: cc.Node,
 
         drawNode: cc.Node,
+
+        //// 以下都是头条录屏功能需要的节点
+
+        recordNode: cc.Node,
+        startRecordNode: cc.Node,
+        /// 正在录屏
+        recordingNode: cc.Node,
+        recordTimeRichText: cc.RichText,
     },
 
     // LIFE-CYCLE CALLBACKS:
@@ -52,8 +60,12 @@ cc.Class({
         }
 
         /// 如果是头条那么隐藏商城
-        if (window.tt != undefined) {
+        if (window.tt !== undefined) {
             this.storeNode.active = false;
+            this._starRecord = false;
+            this._recordTime = 0;
+        } else {
+            this.recordNode.active = false;
         }
 
         //判断正在审核中的版本隐藏7天登录按钮或已完成7天登录任务
@@ -148,7 +160,7 @@ cc.Class({
         this.helpRedNode.active = redTypes.indexOf(GameRedDot.friendAward) != -1;
         /// 只要这里一个有红点就都有红点
         this.giftRedNode.active = this.awardRedNode.active || this.inviteFriendRedNode.active || this.signRedNode.active;
-        if (GameGlobal.isShowBar) {
+        if (GameGlobal.isShowBar && window.tt == undefined) {
             let isStoreRed = (redTypes.indexOf(GameRedDot.storeDiamond) != -1 || redTypes.indexOf(GameRedDot.storeCoin) != -1);
             this.storeRedNode.active = isStoreRed;
             if (isStoreRed) {
@@ -244,7 +256,64 @@ cc.Class({
 
     showMoreWelfare() {
         this.handleShowMore();
-    }
+    },
+
+    recordTimeAction() {
+        this._recordTime += 1;
+        this.recordTimeRichText.string = `<b><color=#fdfdef >${DWTool.calculateTime(this._recordTime)}</c></b>`;
+    },
+
+    //处理头条录制视频然后分享的功能
+    handleTTRecordVideo() {
+        debugger
+        let recorder = tt.getGameRecorderManager();
+        /// 如果是开始录制了
+        if (this._starRecord) {
+            recorder.stop();
+        } else {
+            recorder.start({
+                duration: 120,
+                microphoneEnabled: true,
+            });
+        }
+        recorder.onStart(res =>{
+            // 录屏开始
+            console.log('录屏开始');
+            GameGlobal.commonAlert.showCommonErrorAlert('录屏开始');
+            this._starRecord = true;
+            this.startRecordNode.active = false;
+            this.recordingNode.active = true;
+            this.schedule(this.recordTimeAction, 1);
+        })
+
+        recorder.onStop(res =>{
+            // 录屏结束;
+            GameGlobal.commonAlert.showCommonErrorAlert('录屏结束');
+            this._starRecord = false;
+            this.startRecordNode.active = true;
+            this.recordingNode.active = false;
+            this.recordTimeRichText.string = '<b><color=#fdfdef >00:00</c></b>';
+            this._recordTime = 0;
+            this.unschedule(this.recordTimeAction, this);
+            tt.shareVideo({
+                videoPath: `${res.videoPath}`,
+                success () {
+                  console.log(`分享成功!`);
+                },
+                fail (e) {
+                  console.log(`分享失败!`);
+                }
+              });
+        })
+
+        recorder.onPause(() =>{
+        // 录屏已暂停;
+        })
+
+        recorder.onResume(() =>{
+        // 录屏已恢复;
+        })
+    },
 });
 
 

+ 1 - 1
settings/builder.json

@@ -38,7 +38,7 @@
   "webOrientation": "auto",
   "wechatgame": {
     "REMOTE_SERVER_ROOT": "https://pub.dwstatic.com/wxgame/taptapstar_toutiao_test",
-    "appid": "tt672c1191f806d2a2",
+    "appid": "ttb715c1a8283f029e",
     "isSubdomain": false,
     "orientation": "portrait",
     "subContext": ""

Vissa filer visades inte eftersom för många filer har ändrats