From 2c742e707d04c16308e8277a39aca811d59407e0 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 29 Oct 2024 16:34:38 +0800 Subject: [PATCH] optimized --- entry/src/main/ets/model/CameraDateModel.ets | 22 ++++++++++---------- entry/src/main/ets/pages/Index.ets | 2 +- entry/src/main/ets/pages/Recorder.ets | 12 +++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/entry/src/main/ets/model/CameraDateModel.ets b/entry/src/main/ets/model/CameraDateModel.ets index 458dbbe..e17383b 100644 --- a/entry/src/main/ets/model/CameraDateModel.ets +++ b/entry/src/main/ets/model/CameraDateModel.ets @@ -17,22 +17,22 @@ import { camera } from '@kit.CameraKit'; import { CommonConstants as Const } from '../common/CommonConstants'; export class CameraDataModel { - surfaceId: string = ''; - cameraWidth: number = Const.DEFAULT_WIDTH; - cameraHeight: number = Const.DEFAULT_HEIGHT; - isHDRVivid: number = Const.DEFAULT_VALUE; - outputfd: number = -1; - frameRate: number = Const.FRAMERATE_VIDEO_30FPS; - previewProfile: camera.Profile = Const.DEFAULT_PROFILE; - videoCodecMime: string | null = Const.MIME_VIDEO_AVC; - bitRate: number = Const.BITRATE_VIDEO_20M; + public surfaceId: string = ''; + public cameraWidth: number = Const.DEFAULT_WIDTH; + public cameraHeight: number = Const.DEFAULT_HEIGHT; + public isHDRVivid: number = Const.DEFAULT_VALUE; + public outputfd: number = -1; + public frameRate: number = Const.FRAMERATE_VIDEO_30FPS; + public previewProfile: camera.Profile = Const.DEFAULT_PROFILE; + public videoCodecMime: string | null = Const.MIME_VIDEO_AVC; + public bitRate: number = Const.BITRATE_VIDEO_20M; - setCodecFormat(isHDR: number, codecMime: string) { + setCodecFormat(isHDR: number, codecMime: string): void { this.isHDRVivid = isHDR; this.videoCodecMime = codecMime; } - setResolution(width: number, height: number, bit: number) { + setResolution(width: number, height: number, bit: number): void { this.cameraWidth = width; this.cameraHeight = height; this.bitRate = bit; diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index a564799..a3e87b6 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -76,7 +76,7 @@ struct Player { }) } - async checkIsProfileSupport() { + async checkIsProfileSupport(): Promise { let cameraManager: camera.CameraManager = camera.getCameraManager(getContext(this)); if (!cameraManager) { Logger.error(TAG, 'camera.getCameraManager error!'); diff --git a/entry/src/main/ets/pages/Recorder.ets b/entry/src/main/ets/pages/Recorder.ets index 8cc7875..1d48c9a 100644 --- a/entry/src/main/ets/pages/Recorder.ets +++ b/entry/src/main/ets/pages/Recorder.ets @@ -33,7 +33,7 @@ let XComponentPreviewOutput: camera.PreviewOutput; let encoderVideoOutput: camera.VideoOutput; let videoSession: camera.VideoSession; -async function releaseCamera() { +async function releaseCamera(): Promise { // Stop the video output stream if (encoderVideoOutput) { encoderVideoOutput.stop((err: BusinessError) => { @@ -42,7 +42,7 @@ async function releaseCamera() { return; } Logger.info(TAG, 'Callback invoked to indicate the encoder video output stop success.'); - }) + }); } // Stop the Session. videoSession.stop(); @@ -91,7 +91,7 @@ struct Recorder { } } - async release() { + async release(): Promise { if (!this.isReleased) { this.isReleased = true; clearInterval(this.timer); @@ -99,11 +99,11 @@ struct Recorder { this.videoRecorderTimeText = Const.DEFAULT_TIME; recorder.stopNative().then(async (data) => { - if (data.code == 0) { + if (data.code === 0) { await releaseCamera(); this.playFlag = false; } - }) + }); } } @@ -245,7 +245,7 @@ struct Recorder { return; } Logger.info(TAG, 'Callback invoked to indicate the encoder video output start success.'); - }) + }); } build() { -- Gitee