diff --git a/ApiUsingStandards/entry/src/main/ets/pages/AVImageGenerator.ets b/ApiUsingStandards/entry/src/main/ets/pages/AVImageGenerator.ets index 968c0fce2c6f4015a8acf4b74074c5aa43347b11..ce2700bea80461f986af0948f73d1a949b81e4db 100644 --- a/ApiUsingStandards/entry/src/main/ets/pages/AVImageGenerator.ets +++ b/ApiUsingStandards/entry/src/main/ets/pages/AVImageGenerator.ets @@ -17,6 +17,7 @@ import { media } from '@kit.MediaKit' import { image } from '@kit.ImageKit' import { fileIo as fs, ReadOptions } from '@kit.CoreFileKit'; import { display } from '@kit.ArkUI'; +import { hilog } from '@kit.PerformanceAnalysisKit'; class AVImageGeneratorClass { pixelMap: image.PixelMap[] = []; @@ -39,25 +40,24 @@ class AVImageGeneratorClass { // raw fd avImageGenerator.fdSrc = fs.openSync(this.rootPath + this.testFilename); for (let i = 0; i < 6; i++) { - console.info(`time real ${this.diffTime[i]}`); - let pixelMap = await avImageGenerator.fetchFrameByTime(this.diffTime[i], this.seekOption, + let pixelMap: image.PixelMap = await avImageGenerator.fetchFrameByTime(this.diffTime[i], this.seekOption, { width: this.pixelMapWidth, height: this.pixelMapHeight }); this.pixelMap.push(pixelMap); if (i == 0) { this.pixelLcd = pixelMap; - let rate = pixelMap.getImageInfoSync().size.height / pixelMap.getImageInfoSync().size.width; + let rate: number = pixelMap.getImageInfoSync().size.height / pixelMap.getImageInfoSync().size.width; this.lcdHeight = display.getDefaultDisplaySync().width / 2 / display.getDefaultDisplaySync().densityPixels * rate; } let imageInfo: image.ImageInfo = pixelMap.getImageInfoSync(); - console.info(`colorFormat ${imageInfo.pixelFormat} width ${imageInfo.size.width} height ${imageInfo.size.height} isHdr ${imageInfo.isHdr}`); + hilog.info(0x0000, 'testTag', + `colorFormat ${imageInfo.pixelFormat} width ${imageInfo.size.width} height ${imageInfo.size.height} isHdr ${imageInfo.isHdr}`); } } } async fetchMeta(): Promise { if (canIUse("SystemCapability.Multimedia.Media.AVMetadataExtractor")) { - console.info(`typeof ${typeof media.createAVMetadataExtractor()}`); let avMetadataExtractor: media.AVMetadataExtractor = await media.createAVMetadataExtractor(); let fd: number = fs.openSync(this.rootPath + this.testFilename).fd; let fileSize: number = fs.statSync(this.rootPath + this.testFilename).size; @@ -65,15 +65,13 @@ class AVImageGeneratorClass { fileSize: fileSize, callback: (buffer, len, pos) => { if (buffer == undefined || len == undefined || pos == undefined) { - console.error(`dataSrc callback param invalid`); return -1; } let options: ReadOptions = { offset: pos, length: len } - let num = fs.readSync(fd, buffer, options); - console.info('readAt end, num: ' + num); + let num: number = fs.readSync(fd, buffer, options); if (num > 0 && fileSize >= pos) { return num; } @@ -86,24 +84,22 @@ class AVImageGeneratorClass { try { metadata = await avMetadataExtractor.fetchMetadata(); } catch (error) { - console.info('error code ' + error.code); + hilog.error(0x0000, 'testTag', 'error code ' + error.code); return; } - console.info(`metadata ${JSON.stringify(metadata)}`); if (metadata.duration) { - console.info(`fetchMetadata success duration ${metadata.duration}`); - let duration = parseInt(metadata.duration) * 1000; - let pick = duration / 5; + let duration: number = parseInt(metadata.duration) * 1000; + let pick: number = duration / 5; this.diffTime[0] = 0; this.diffTime[5] = duration; - let time = pick; + let time: number = pick; for (let i = 1; i < 5; i++) { this.diffTime[i] = time; time += pick; } } if (metadata.videoHeight && metadata.videoWidth) { - let rate = Number(metadata.videoHeight) / Number(metadata.videoWidth); + let rate: number = Number(metadata.videoHeight) / Number(metadata.videoWidth); if (metadata.videoOrientation && Number(metadata.videoOrientation) % 180) { rate = 1 / rate; } @@ -113,5 +109,6 @@ class AVImageGeneratorClass { await avMetadataExtractor.release(); } } + // [End av_image_generator_class] } \ No newline at end of file diff --git a/ApiUsingStandards/entry/src/main/ets/pages/camera.ets b/ApiUsingStandards/entry/src/main/ets/pages/camera.ets index ed8e35a7c7e778a5d7323aaf7956003b30377b96..0e31101aef0778563fc1916350e2df96b7d7e3e5 100644 --- a/ApiUsingStandards/entry/src/main/ets/pages/camera.ets +++ b/ApiUsingStandards/entry/src/main/ets/pages/camera.ets @@ -42,7 +42,7 @@ class cameraClass { let previewOutput: camera.CameraOutput | undefined = undefined; let cameraInput: camera.CameraInput | undefined = undefined; let profile: camera.Profile = cameraOutputCapability.previewProfiles[0]; - let surfaceId = 'xxx'; + let surfaceId: string = 'xxx'; // [Start add_output] previewOutput = cameraManager.createPreviewOutput(profile, surfaceId); cameraInput = cameraManager.createCameraInput(camera); @@ -58,7 +58,7 @@ class cameraClass { let previewOutput: camera.CameraOutput | undefined = undefined; let cameraInput: camera.CameraInput | undefined = undefined; let profile: camera.Profile = cameraOutputCapability.previewProfiles[0]; - let surfaceId = 'xxx'; + let surfaceId: string = 'xxx'; // [Start add_output1] previewOutput = cameraManager.createPreviewOutput(profile, surfaceId); cameraInput = cameraManager.createCameraInput(camera); @@ -79,4 +79,5 @@ async function onBackground(): Promise { await cameraInput.close(); await cameraSession.release(); } + // [End close_release] \ No newline at end of file diff --git a/ApiUsingStandards/entry/src/main/ets/pages/playStateCallback.ets b/ApiUsingStandards/entry/src/main/ets/pages/playStateCallback.ets index 4de3c1bf34c9b2c2e1340b2cdc27723c27feb2b5..d9621a1659c6227cb8621016b74da65ca02fd1a3 100644 --- a/ApiUsingStandards/entry/src/main/ets/pages/playStateCallback.ets +++ b/ApiUsingStandards/entry/src/main/ets/pages/playStateCallback.ets @@ -18,8 +18,7 @@ */ import { BusinessError } from '@kit.BasicServicesKit'; import { avSession } from '@kit.AVSessionKit'; - -const TAG: string = 'TEST'; +import { hilog } from '@kit.PerformanceAnalysisKit'; class avSessionClass { castController!: avSession.AVCastController; @@ -32,17 +31,16 @@ class avSessionClass { create(context: Context, tag: string): void { avSession.createAVSession(context, tag, "audio").then(async (currentAVSession: avSession.AVSession) => { this.session = currentAVSession; - let sessionController = await currentAVSession.getAVCastController(); + let sessionController: avSession.AVCastController = await currentAVSession.getAVCastController(); this.castController = sessionController; // [Start play_state_callback] - let playStateCallback = (state: avSession.AVPlaybackState) => { - + let playStateCallback: (state: avSession.AVPlaybackState) => void = (state: avSession.AVPlaybackState) => { } sessionController.on('playbackStateChange', 'all', this.playStateCallback); sessionController.off('playbackStateChange', this.playStateCallback); // [End play_state_callback] }).catch((err: BusinessError) => { - console.info(`CreateAVSession BusinessError: code: ${err.code}, message: ${err.message}`); + hilog.error(0x0000, 'testTag', `CreateAVSession BusinessError: code: ${err.code}, message: ${err.message}`); }); } @@ -66,10 +64,9 @@ class avSessionClass { // [Start prepare] // Preparing to play, this will not trigger actual playback, it will load and buffer this.castController?.prepare(playItem, () => { - console.info('Preparation done'); // Start playback, truly triggering the playback on the other end. Please call start after Prepare is successful. this.castController?.start(playItem, () => { - console.info('Playback started'); + hilog.info(0x0000, 'testTag', 'Playback started'); }); }); // [End prepare] @@ -78,7 +75,6 @@ class avSessionClass { onPrepare(): void { // [Start on_prepare] this.session?.on('pause', async () => { - console.info(TAG, `on pause , do pause task`); // Execute player pause // Set the status and progress during pause this.currentState = { diff --git a/JSCrash/README.md b/JSCrash/README.md index e50d680e98a443bfd73a8de5bacf66b5db486023..c20f7ed83a625ecb9319994cc960cacf18a12103 100644 --- a/JSCrash/README.md +++ b/JSCrash/README.md @@ -11,11 +11,11 @@ ### 工程目录 ``` -├──entry/src/main/ets // 代码区 +├──entry/src/main/ets │ ├──entryability │ │ └──EntryAbility.ets // 程序入口类 │ ├──entrybackupability -│ │ └──EntryBackupAbility.ets +│ │ └──EntryBackupAbility.ets // 数据恢复类 │ └──pages │ ├──Index.ets // 首页 │ ├── JSCrashCaseAnalyse1.ets // ArkTS样例代码 @@ -23,7 +23,6 @@ │ ├── JSCrashCaseAnalyse3.ets // ArkTS样例代码 │ ├── JSCrashCaseAnalyse4.ets // ArkTS样例代码 │ ├── JSCrashCaseAnalyse5.ets // ArkTS样例代码 -│ ├── JSCrashCaseAnalyse6.ets // ArkTS样例代码 │ ├── JSCrashQuestionCheck.ets // ArkTS样例代码 │ └── utils.ets // 工具类 └──entry/src/main/resources // 应用资源目录