diff --git a/code/BasicFeature/Graphics/DisplaySoloist/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/Graphics/DisplaySoloist/entry/src/main/ets/pages/Index.ets index 118ba0102d2d24d48af5bfdfb219b89e8f41db14..7f71e4a8439d533c58b9f147a25c7617a19e6b4e 100644 --- a/code/BasicFeature/Graphics/DisplaySoloist/entry/src/main/ets/pages/Index.ets +++ b/code/BasicFeature/Graphics/DisplaySoloist/entry/src/main/ets/pages/Index.ets @@ -84,7 +84,7 @@ struct Index { } }).margin(4) - XComponent({ id: 'xcomponentId30', type: 'surface', libraryname: 'entry' }) + XComponent({ id: 'xcomponentId30', type: XComponentType.SURFACE, libraryname: 'entry' }) .onLoad((xComponentContext) => { this.xComponentContext1 = xComponentContext as XComponentContext; }).width('640px') @@ -110,7 +110,7 @@ struct Index { } }).margin(4) - XComponent({ id: 'xcomponentId60', type: 'surface', libraryname: 'entry' }) + XComponent({ id: 'xcomponentId60', type: XComponentType.SURFACE, libraryname: 'entry' }) .onLoad((xComponentContext) => { this.xComponentContext2 = xComponentContext as XComponentContext; }).width('640px') @@ -136,7 +136,7 @@ struct Index { } }).margin(4) - XComponent({ id: 'xcomponentId120', type: 'surface', libraryname: 'entry' }) + XComponent({ id: 'xcomponentId120', type: XComponentType.SURFACE, libraryname: 'entry' }) .onLoad((xComponentContext) => { this.xComponentContext3 = xComponentContext as XComponentContext; }).width('640px') diff --git a/code/BasicFeature/Media/ImageEffect/entry/src/main/ets/pages/ImageEditPage.ets b/code/BasicFeature/Media/ImageEffect/entry/src/main/ets/pages/ImageEditPage.ets index 5d7854d1b5691c4ef1bca62e109eda40d524e013..94aa5fe9541dd7f0b0ceff46e4447662a9b951bc 100644 --- a/code/BasicFeature/Media/ImageEffect/entry/src/main/ets/pages/ImageEditPage.ets +++ b/code/BasicFeature/Media/ImageEffect/entry/src/main/ets/pages/ImageEditPage.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2024-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,12 +13,34 @@ * limitations under the License. */ -import imageEffect from 'libentry.so' +import imageEffect from 'libentry.so'; import image from '@ohos.multimedia.image'; import { ImageUtils } from '../utils/ImageUtils'; import { fileUri } from '@kit.CoreFileKit'; import fs from '@ohos.file.fs'; +interface FilterDataType { + brightnessSetValue: number, + brightnessSelect: boolean, + contrastSetValue: number, + contrastSelect: boolean, + cropSetValue: number, + cropSelect: boolean, + customSetValue: number, + customSelect: boolean +} + +const DEFAULT_FILTER_DATA: FilterDataType = { + brightnessSetValue: 100, + brightnessSelect: true, + contrastSetValue: 0, + contrastSelect: false, + cropSetValue: 100, + cropSelect: false, + customSetValue: 0, + customSelect: false +}; + @Entry @Component struct ImageEditPage { @@ -26,16 +48,9 @@ struct ImageEditPage { settingBtn: Resource = $r('app.media.ic_public_settings'); @Provide pixelMap: image.PixelMap | undefined = undefined; @Provide displayPixelMap: image.PixelMap | undefined = undefined; - @State brightnessSetValue: number = 100; - @State brightnessSelect: boolean = true; - @State contrastSetValue: number = 0; - @State contrastSelect: boolean = false; - @State cropSetValue: number = 100; - @State cropSelect: boolean = false; - @State customSetValue: number = 0; - @State customSelect: boolean = false; @State filterOptions: Array> = []; @State filterInfo: string = ""; + @State nowSelectedData: FilterDataType = DEFAULT_FILTER_DATA; aboutToAppear(): void { console.info(`${this.tag} aboutToAppear called`); @@ -99,6 +114,7 @@ struct ImageEditPage { Column() { Row() { Button("Reset").id("btn_reset").onClick(() => { + this.resetParams(); this.pixelInit(); }).width(100).margin({ left: 3, right: 3, top: 3, bottom: 6 }) @@ -137,31 +153,32 @@ struct ImageEditPage { private confirmInfo() { this.filterOptions = []; - if (this.brightnessSelect) { + if (this.nowSelectedData.brightnessSelect) { let brightnessArray: (string | number)[] = []; - brightnessArray.push("Brightness", this.brightnessSetValue); + brightnessArray.push("Brightness", this.nowSelectedData.brightnessSetValue); this.filterOptions.push(brightnessArray); } - if (this.contrastSelect) { + if (this.nowSelectedData.contrastSelect) { let contrastArray: (string | number)[] = []; - contrastArray.push("Contrast", this.contrastSetValue); + contrastArray.push("Contrast", this.nowSelectedData.contrastSetValue); this.filterOptions.push(contrastArray); } - if (this.cropSelect) { + if (this.nowSelectedData.cropSelect) { let cropArray: (string | number)[] = []; - cropArray.push("Crop", this.cropSetValue); + cropArray.push("Crop", this.nowSelectedData.cropSetValue); this.filterOptions.push(cropArray); } - if (this.customSelect) { + if (this.nowSelectedData.customSelect) { let customArray: (string | number)[] = []; - customArray.push("CustomBrightness", this.customSetValue); + customArray.push("CustomBrightness", this.nowSelectedData.customSetValue); this.filterOptions.push(customArray); } } private async doApply(): Promise { this.confirmInfo(); - if (this.brightnessSelect || this.contrastSelect || this.cropSelect || this.customSelect) { + if (this.nowSelectedData.brightnessSelect || this.nowSelectedData.contrastSelect || + this.nowSelectedData.cropSelect || this.nowSelectedData.customSelect) { await this.doSavePixel(); let filePath = getContext().filesDir + "/test.jpg"; imageEffect.apply(filePath, [...this.filterOptions]); @@ -169,6 +186,10 @@ struct ImageEditPage { } } + resetParams() { + this.nowSelectedData = DEFAULT_FILTER_DATA; + } + private async pixelInit(): Promise { this.displayPixelMap?.release(); this.displayPixelMap = await ImageUtils.getInstance().getPixelMap($r('app.media.ic_1080x1920')) @@ -179,15 +200,8 @@ struct ImageEditPage { cancel: this.onCancel, confirm: this.onAccept, filterOptions: $filterOptions, - brightnessSetValue: $brightnessSetValue, - brightnessSelect: $brightnessSelect, - contrastSetValue: $contrastSetValue, - contrastSelect: $contrastSelect, - cropSetValue: $cropSetValue, - cropSelect: $cropSelect, - customSetValue: $customSetValue, - customSelect: $customSelect, filterInfo: $filterInfo, + nowSelectedData: $nowSelectedData }), cancel: this.existApp, autoCancel: true, @@ -197,8 +211,9 @@ struct ImageEditPage { console.info(`Callback when the cancel button is clicked`); } - onAccept() { + onAccept(nowSelectedData: FilterDataType) { console.info(`Callback when the confirm button is clicked`); + this.nowSelectedData = nowSelectedData; } existApp() { @@ -208,23 +223,35 @@ struct ImageEditPage { @CustomDialog struct CustomDialogExample { - @Link brightnessSetValue: number - @Link brightnessSelect: boolean - @Link contrastSetValue: number - @Link contrastSelect: boolean - @Link cropSetValue: number - @Link cropSelect: boolean - @Link customSetValue: number - @Link customSelect: boolean - @Link filterOptions: Array> + @State brightnessSetValue: number = 100; + @State brightnessSelect: boolean = true; + @State contrastSetValue: number = 0; + @State contrastSelect: boolean = false; + @State cropSetValue: number = 100; + @State cropSelect: boolean = false; + @State customSetValue: number = 0; + @State customSelect: boolean = false; + @Link filterOptions: Array>; @Link filterInfo: string; + @Link nowSelectedData: FilterDataType; controller: CustomDialogController; cancel: () => void = () => { + }; + confirm: (nowSelectedData: FilterDataType) => void = (nowSelectedData: FilterDataType) => { + }; + @State formatList: Array = ["Format:default", "Format:rgba_8888", "Format:nv21", "Format:nv12"]; + @State handlePopup: boolean = false; + + aboutToAppear(): void { + this.brightnessSetValue = this.nowSelectedData.brightnessSetValue; + this.brightnessSelect = this.nowSelectedData.brightnessSelect; + this.contrastSetValue = this.nowSelectedData.contrastSetValue; + this.contrastSelect = this.nowSelectedData.contrastSelect; + this.cropSetValue = this.nowSelectedData.cropSetValue; + this.cropSelect = this.nowSelectedData.cropSelect; + this.customSetValue = this.nowSelectedData.customSetValue; + this.customSelect = this.nowSelectedData.customSelect; } - confirm: () => void = () => { - } - @State formatList: Array = ["Format:default", "Format:rgba_8888", "Format:nv21", "Format:nv12"] - @State handlePopup: boolean = false @Builder FilterInfoMenu() { @@ -480,9 +507,17 @@ struct CustomDialogExample { .id("btn_dialog_cancel") Button($r('app.string.btn_confirm')) .onClick(() => { - - this.controller.close() - this.confirm() + this.controller.close(); + this.confirm({ + brightnessSetValue: this.brightnessSetValue, + brightnessSelect: this.brightnessSelect, + contrastSetValue: this.contrastSetValue, + contrastSelect: this.contrastSelect, + cropSetValue: this.cropSetValue, + cropSelect: this.cropSelect, + customSetValue: this.customSetValue, + customSelect: this.customSelect + }); }).backgroundColor(0xffffff) .fontColor(Color.Red) .id("btn_dialog_confirm") diff --git a/code/DocsSample/graphic/DisplaySoloist/entry/src/main/ets/pages/Index.ets b/code/DocsSample/graphic/DisplaySoloist/entry/src/main/ets/pages/Index.ets index ad64905125d8e6c3983e6fee9b7af17cd3b9a41f..69e4c3b1d7d241a964656a7fc5af9c79c22f2f59 100644 --- a/code/DocsSample/graphic/DisplaySoloist/entry/src/main/ets/pages/Index.ets +++ b/code/DocsSample/graphic/DisplaySoloist/entry/src/main/ets/pages/Index.ets @@ -79,7 +79,7 @@ struct Index { } }).margin(4) - XComponent({ id: 'xcomponentId30', type: 'surface', libraryname: 'entry' }) + XComponent({ id: 'xcomponentId30', type: XComponentType.SURFACE, libraryname: 'entry' }) .onLoad((xComponentContext) => { this.xComponentContext1 = xComponentContext as XComponentContext; }).width('640px') @@ -105,7 +105,7 @@ struct Index { } }).margin(4) - XComponent({ id: 'xcomponentId60', type: 'surface', libraryname: 'entry' }) + XComponent({ id: 'xcomponentId60', type: XComponentType.SURFACE, libraryname: 'entry' }) .onLoad((xComponentContext) => { this.xComponentContext2 = xComponentContext as XComponentContext; }).width('640px') @@ -131,7 +131,7 @@ struct Index { } }).margin(4) - XComponent({ id: 'xcomponentId120', type: 'surface', libraryname: 'entry' }) + XComponent({ id: 'xcomponentId120', type: XComponentType.SURFACE, libraryname: 'entry' }) .onLoad((xComponentContext) => { this.xComponentContext3 = xComponentContext as XComponentContext; }).width('640px') diff --git a/code/Solutions/Media/MultiMedia/README_zh.md b/code/Solutions/Media/MultiMedia/README_zh.md index 2f37207cc31f4c516f9f3aefbc4ab520c7a229d9..4dd7820a56e3edad4f31c2b818d50dce21cc346c 100644 --- a/code/Solutions/Media/MultiMedia/README_zh.md +++ b/code/Solutions/Media/MultiMedia/README_zh.md @@ -99,7 +99,7 @@ entry/src/main/ets/ 1.本示例仅支持标准系统上运行。 -2.本示例为Stage模型,已适配API version 10版本SDK,版本号:4.0.10.15。 +2.本示例为Stage模型,已适配API version 12版本SDK,版本号:5.0.0。 3.本示例需要使用DevEco Studio NEXT Developer Preview1 (Build Version: 4.1.3.500, built on January 20, 2024)及以上版本才可编译运行。 diff --git a/code/Solutions/Media/MultiMedia/build-profile.json5 b/code/Solutions/Media/MultiMedia/build-profile.json5 index 0b16333dd4688c963604607f714cbbff93cc04fd..0cdb7f30d4c747a631db77c5f9448d420cc057a4 100644 --- a/code/Solutions/Media/MultiMedia/build-profile.json5 +++ b/code/Solutions/Media/MultiMedia/build-profile.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -18,8 +18,8 @@ "signingConfigs": [], "products": [ { - "compileSdkVersion": 10, - "compatibleSdkVersion": 10, + "compileSdkVersion": 12, + "compatibleSdkVersion": 12, "name": "default", "signingConfig": "default", } diff --git a/code/Solutions/Media/MultiMedia/entry/src/main/ets/model/CameraService.ts b/code/Solutions/Media/MultiMedia/entry/src/main/ets/model/CameraService.ts index 6f3704aa4dd245ad6310c4904ce5f2d5d085da0e..6ac06f1ee97c2edd32f1c6b7d06df7c0d46f381c 100644 --- a/code/Solutions/Media/MultiMedia/entry/src/main/ets/model/CameraService.ts +++ b/code/Solutions/Media/MultiMedia/entry/src/main/ets/model/CameraService.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,14 +13,15 @@ * limitations under the License. */ -import camera from '@ohos.multimedia.camera' -import deviceInfo from '@ohos.deviceInfo' -import fileio from '@ohos.file.fs' -import image from '@ohos.multimedia.image' -import media from '@ohos.multimedia.media' -import userFileManager from '@ohos.filemanagement.userFileManager' -import Logger from '../model/Logger' -import MediaUtils, { FileType } from '../model/MediaUtils' +import camera from '@ohos.multimedia.camera'; +import deviceInfo from '@ohos.deviceInfo'; +import fileio from '@ohos.file.fs'; +import image from '@ohos.multimedia.image'; +import media from '@ohos.multimedia.media'; +import userFileManager from '@ohos.filemanagement.userFileManager'; +import Logger from '../model/Logger'; +import MediaUtils, { FileType } from '../model/MediaUtils'; +import { Size } from '@kit.ArkUI'; const CameraMode = { MODE_PHOTO: 0, // 拍照模式 @@ -33,25 +34,26 @@ const CameraSize = { } export default class CameraService { - private tag: string = 'CameraService' - private context: any = undefined - private mediaUtil: MediaUtils = undefined - private cameraManager: camera.CameraManager = undefined - private cameras: Array = undefined - private cameraId: string = '' - private cameraInput: camera.CameraInput = undefined - private previewOutput: camera.PreviewOutput = undefined - private photoOutPut: camera.PhotoOutput = undefined - private captureSession: camera.CaptureSession = undefined - private mReceiver: image.ImageReceiver = undefined - private photoUri: string = '' - private fileAsset: userFileManager.FileAsset = undefined - private fd: number = -1 - private curMode = CameraMode.MODE_PHOTO - private videoRecorder: media.VideoRecorder = undefined - private videoOutput: camera.VideoOutput = undefined - private handleTakePicture: (photoUri: string) => void = undefined - private cameraOutputCapability: camera.CameraOutputCapability = undefined + private tag: string = 'CameraService'; + private context: any = undefined; + private mediaUtil: MediaUtils = undefined; + private cameraManager: camera.CameraManager = undefined; + private cameras: Array = undefined; + private cameraId: string = ''; + private cameraInput: camera.CameraInput = undefined; + private previewOutput: camera.PreviewOutput = undefined; + private photoOutPut: camera.PhotoOutput = undefined; + private captureSession: camera.CaptureSession = undefined; + private mReceiver: image.ImageReceiver = undefined; + private photoUri: string = ''; + private fileAsset: userFileManager.FileAsset = undefined; + private fd: number = -1; + private curMode = CameraMode.MODE_PHOTO; + private videoRecorder: media.VideoRecorder = undefined; + private videoOutput: camera.VideoOutput = undefined; + private handleTakePicture: (photoUri: string) => void = undefined; + private cameraOutputCapability: camera.CameraOutputCapability = undefined; + private previewSize: Size = undefined; private videoConfig: any = { audioSourceType: 1, videoSourceType: 0, @@ -75,7 +77,7 @@ export default class CameraService { }, maxSize: 10000, maxDuration: 10000 - } + }; constructor(context: any) { this.context = context @@ -125,44 +127,45 @@ export default class CameraService { } async initCamera(surfaceId: string) { - Logger.info(this.tag, 'initCamera') - await this.releaseCamera() - Logger.info(this.tag, `deviceInfo.deviceType = ${deviceInfo.deviceType}`) + Logger.info(this.tag, 'initCamera'); + await this.releaseCamera(); + Logger.info(this.tag, `deviceInfo.deviceType = ${deviceInfo.deviceType}`); if (deviceInfo.deviceType === 'default') { - this.videoConfig.videoSourceType = 1 + this.videoConfig.videoSourceType = 1; } else { - this.videoConfig.videoSourceType = 0 + this.videoConfig.videoSourceType = 0; } - this.cameraManager = camera.getCameraManager(this.context) - Logger.info(this.tag, 'getCameraManager') - this.cameras = this.cameraManager.getSupportedCameras() - Logger.info(this.tag, `get cameras ${this.cameras.length}`) + this.cameraManager = camera.getCameraManager(this.context); + Logger.info(this.tag, 'getCameraManager'); + this.cameras = this.cameraManager.getSupportedCameras(); + Logger.info(this.tag, `get cameras ${this.cameras.length}`); if (this.cameras.length === 0) { - Logger.info(this.tag, 'cannot get cameras') - return + Logger.info(this.tag, 'cannot get cameras'); + return; } - let cameraDevice = this.cameras[0] - this.cameraInput = this.cameraManager.createCameraInput(cameraDevice) - this.cameraInput.open() - Logger.info(this.tag, 'createCameraInput') - this.cameraOutputCapability = this.cameraManager.getSupportedOutputCapability(cameraDevice) - let previewProfile = this.cameraOutputCapability.previewProfiles[0] - this.previewOutput = this.cameraManager.createPreviewOutput(previewProfile, surfaceId) - Logger.info(this.tag, 'createPreviewOutput') - let mSurfaceId = await this.mReceiver.getReceivingSurfaceId() - let profile = this.cameraOutputCapability.photoProfiles[0] - this.photoOutPut = this.cameraManager.createPhotoOutput(profile, mSurfaceId) - this.captureSession = this.cameraManager.createCaptureSession() - Logger.info(this.tag, 'createCaptureSession') - this.captureSession.beginConfig() - Logger.info(this.tag, 'beginConfig') - this.captureSession.addInput(this.cameraInput) - this.captureSession.addOutput(this.previewOutput) - this.captureSession.addOutput(this.photoOutPut) - await this.captureSession.commitConfig() - await this.captureSession.start() - Logger.info(this.tag, 'captureSession start') + let cameraDevice = this.cameras[0]; + this.cameraInput = this.cameraManager.createCameraInput(cameraDevice); + this.cameraInput.open(); + Logger.info(this.tag, 'createCameraInput'); + this.cameraOutputCapability = this.cameraManager.getSupportedOutputCapability(cameraDevice, camera.SceneMode.NORMAL_VIDEO); + let previewProfile = this.cameraOutputCapability.previewProfiles[0]; + this.previewSize = previewProfile.size; + this.previewOutput = this.cameraManager.createPreviewOutput(previewProfile, surfaceId); + Logger.info(this.tag, 'createPreviewOutput'); + let mSurfaceId = await this.mReceiver.getReceivingSurfaceId(); + let profile = this.cameraOutputCapability.photoProfiles[0]; + this.photoOutPut = this.cameraManager.createPhotoOutput(profile, mSurfaceId); + this.captureSession = this.cameraManager.createCaptureSession(); + Logger.info(this.tag, 'createCaptureSession'); + this.captureSession.beginConfig(); + Logger.info(this.tag, 'beginConfig'); + this.captureSession.addInput(this.cameraInput); + this.captureSession.addOutput(this.previewOutput); + this.captureSession.addOutput(this.photoOutPut); + await this.captureSession.commitConfig(); + await this.captureSession.start(); + Logger.info(this.tag, 'captureSession start'); } setTakePictureCallback(callback) { @@ -189,64 +192,90 @@ export default class CameraService { } async startVideo() { - Logger.info(this.tag, 'startVideo begin') - await this.captureSession.stop() - this.captureSession.beginConfig() + Logger.info(this.tag, 'startVideo begin'); + await this.captureSession.stop(); + this.captureSession.beginConfig(); if (this.curMode === CameraMode.MODE_PHOTO) { - this.curMode = CameraMode.MODE_VIDEO + this.curMode = CameraMode.MODE_VIDEO; if (this.photoOutPut) { - this.captureSession.removeOutput(this.photoOutPut) - this.photoOutPut.release() + try { + this.captureSession.removeOutput(this.photoOutPut); + this.photoOutPut.release(); + } catch (err) { + Logger.error(this.tag, 'remove photoOutPut error: ' + JSON.stringify(err)); + } } } else { if (this.videoOutput) { - this.captureSession.removeOutput(this.videoOutput) + try { + this.captureSession.removeOutput(this.videoOutput); + } catch (err) { + Logger.error(this.tag, 'remove videoOutput error: ' + JSON.stringify(err)); + } } } if (this.videoOutput) { - this.captureSession.removeOutput(this.videoOutput) - await this.videoOutput.release() + try { + this.captureSession.removeOutput(this.videoOutput); + await this.videoOutput.release(); + } catch (err) { + Logger.error(this.tag, 'remove videoOutput error: ' + JSON.stringify(err)); + } } - this.fileAsset = await this.mediaUtil.createAndGetUri(FileType.VIDEO) - this.fd = await this.mediaUtil.getFdPath(this.fileAsset) - this.videoRecorder = await media.createVideoRecorder() - this.videoConfig.url = `fd://${this.fd}` - await this.videoRecorder.prepare(this.videoConfig) - let videoId = await this.videoRecorder.getInputSurface() + this.fileAsset = await this.mediaUtil.createAndGetUri(FileType.VIDEO); + this.fd = await this.mediaUtil.getFdPath(this.fileAsset); + this.videoRecorder = await media.createVideoRecorder(); + this.videoConfig.url = `fd://${this.fd}`; + this.videoConfig.profile.videoFrameWidth = this.previewSize.width; + this.videoConfig.profile.videoFrameHeight = this.previewSize.height; + await this.videoRecorder.prepare(this.videoConfig); + let videoId = await this.videoRecorder.getInputSurface(); let profile = this.cameraOutputCapability.videoProfiles[0]; - this.videoOutput = this.cameraManager.createVideoOutput(profile, videoId) - this.captureSession.addOutput(this.videoOutput) - await this.captureSession.commitConfig() - await this.captureSession.start() - await this.videoOutput.start() - await this.videoRecorder.start() - Logger.info(this.tag, 'startVideo end') + this.videoOutput = this.cameraManager.createVideoOutput(profile, videoId); + this.captureSession.addOutput(this.videoOutput); + try { + await this.captureSession.commitConfig(); + await this.captureSession.start(); + await this.videoOutput.start(); + await this.videoRecorder.start(); + } catch (err) { + Logger.error(this.tag, 'record start error: ' + JSON.stringify(err)); + } + Logger.info(this.tag, 'startVideo end'); } async stopVideo() { - Logger.info(this.tag, 'stopVideo called') - await this.videoRecorder.stop() - await this.videoOutput.stop() - await this.videoRecorder.release() - await this.fileAsset.close(this.fd) + Logger.info(this.tag, 'stopVideo called'); + try { + await this.videoRecorder.stop(); + await this.videoOutput.stop(); + await this.videoRecorder.release(); + await this.fileAsset.close(this.fd); + } catch (err) { + Logger.error(this.tag, 'stopVideo error: ' + JSON.stringify(err)); + } } async releaseCamera() { - Logger.info(this.tag, 'releaseCamera') - if (this.cameraInput) { - await this.cameraInput.close() - } - if (this.previewOutput) { - await this.previewOutput.release() - } - if (this.photoOutPut) { - await this.photoOutPut.release() - } - if (this.videoOutput) { - await this.videoOutput.release() - } - if (this.captureSession) { - await this.captureSession.release() + Logger.info(this.tag, 'releaseCamera'); + try { + if (this.cameraInput) { + await this.cameraInput.close(); + } + if (this.previewOutput) { + await this.previewOutput.release(); + } + if (this.photoOutPut) { + await this.photoOutPut.release(); + } + if (this.videoOutput) { + await this.videoOutput.release(); + } + if (this.captureSession) { + await this.captureSession.release(); + } + } catch (err) { + Logger.error(this.tag, 'releaseCamera error: ' + JSON.stringify(err)); } } } \ No newline at end of file diff --git a/code/Solutions/Media/MultiMedia/entry/src/main/module.json5 b/code/Solutions/Media/MultiMedia/entry/src/main/module.json5 index 2cafdd31e49b1af441b046fb47b7a7d8d3ffa4e6..fe361512ae120181dded7925951f1de0117b0e87 100644 --- a/code/Solutions/Media/MultiMedia/entry/src/main/module.json5 +++ b/code/Solutions/Media/MultiMedia/entry/src/main/module.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -27,15 +27,14 @@ "deliveryWithInstall": true, "installationFree": false, "pages": "$profile:main_pages", - "uiSyntax": "ets", "abilities": [ { "name": "MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "srcEntry": "./ets/MainAbility/MainAbility.ts", "description": "$string:MainAbility_desc", "icon": "$media:icon", "label": "$string:MainAbility_label", - "visible": true, + "exported": true, "launchType": "singleton", "startWindowIcon": "$media:icon", "startWindowBackground": "$color:white", diff --git a/code/Solutions/Media/MultiMedia/hvigor/hvigor-config.json5 b/code/Solutions/Media/MultiMedia/hvigor/hvigor-config.json5 index 9dda70c28ba04933a49f4ca30c31b8d4f448d0f6..7f3034e8a4e4ce20b61de712284eb2567c191581 100644 --- a/code/Solutions/Media/MultiMedia/hvigor/hvigor-config.json5 +++ b/code/Solutions/Media/MultiMedia/hvigor/hvigor-config.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,8 +13,8 @@ * limitations under the License. */ { - "hvigorVersion": "4.0.2", + "hvigorVersion": "4.1.2", "dependencies": { - "@ohos/hvigor-ohos-plugin": "4.0.2" + "@ohos/hvigor-ohos-plugin": "4.1.2" } } \ No newline at end of file diff --git a/code/Solutions/Media/MultiMedia/lib/CameraPage-1.0.0.hap b/code/Solutions/Media/MultiMedia/lib/CameraPage-1.0.0.hap index 01c91b5e651579d15023eddcfe18e1d4b57521a2..d100ca5611b003357856c8415a261069fa4c8645 100644 Binary files a/code/Solutions/Media/MultiMedia/lib/CameraPage-1.0.0.hap and b/code/Solutions/Media/MultiMedia/lib/CameraPage-1.0.0.hap differ diff --git a/code/Solutions/Media/MultiMedia/lib/CameraPage-1.0.0.tgz b/code/Solutions/Media/MultiMedia/lib/CameraPage-1.0.0.tgz index 51ec9eeeab28eaeb0e95172a8d6c878e529e6d41..196b6271ddc046954b4ab716672b4b6bc0a91418 100644 --- a/code/Solutions/Media/MultiMedia/lib/CameraPage-1.0.0.tgz +++ b/code/Solutions/Media/MultiMedia/lib/CameraPage-1.0.0.tgz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9faa526ab4c7fc32a4516fad0826b5569b78bdcb2b3fbb247404ffece345e8a2 -size 75600 +oid sha256:33d1b3ec43c014912f929cd730e99570dec772fc162a5a1d18b67469f9340dd1 +size 75237 diff --git a/file.txt b/file.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/test.txt b/test.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391