From f2ff7ddbdb965c844018d73299315640bcefc615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A2=A6=E9=BE=99?= Date: Thu, 6 Nov 2025 03:56:42 +0000 Subject: [PATCH 1/4] add ArkUI/entry/src/main/ets/pages/GetResources.ets. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨梦龙 --- .../entry/src/main/ets/pages/GetResources.ets | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 ArkUI/entry/src/main/ets/pages/GetResources.ets diff --git a/ArkUI/entry/src/main/ets/pages/GetResources.ets b/ArkUI/entry/src/main/ets/pages/GetResources.ets new file mode 100644 index 0000000..932ae41 --- /dev/null +++ b/ArkUI/entry/src/main/ets/pages/GetResources.ets @@ -0,0 +1,30 @@ +// xxx.ets +@Entry +@Component +struct VideoPlayer { + private controller: VideoController = new VideoController() + private previewUris: Resource = $r('app.media.preview') + private innerResource: Resource = $rawfile('videoTest.mp4') + + build() { + Column() { + Video({ + src: this.innerResource, + previewUri: this.previewUris, + controller: this.controller + }) + .onUpdate((event) => { // Triggered when the playback progress changes. + console.info("Video update."); + }) + .onPrepared((event) => { // Triggered when video preparation is complete. + console.info("Video prepared."); + }) + .onError(() => { // Triggered when the video playback fails. + console.error("Video error."); + }) + .onStop(() => { // Triggered when the video playback stops. + console.info("Video stopped."); + }) + } + } +} \ No newline at end of file -- Gitee From b5532cf95e7a045fa6d190ddf36595876b2ca80c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A2=A6=E9=BE=99?= Date: Thu, 6 Nov 2025 03:57:23 +0000 Subject: [PATCH 2/4] add ArkUI/entry/src/main/ets/pages/get. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨梦龙 --- ArkUI/entry/src/main/ets/pages/GetResourceManager.ets | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 ArkUI/entry/src/main/ets/pages/GetResourceManager.ets diff --git a/ArkUI/entry/src/main/ets/pages/GetResourceManager.ets b/ArkUI/entry/src/main/ets/pages/GetResourceManager.ets new file mode 100644 index 0000000..e69de29 -- Gitee From ecbb5e4570ccf5ce77d49dad20146867628b2d7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A2=A6=E9=BE=99?= Date: Thu, 6 Nov 2025 03:59:17 +0000 Subject: [PATCH 3/4] update ArkUI/entry/src/main/ets/pages/GetResourceManager.ets. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨梦龙 --- .../src/main/ets/pages/GetResourceManager.ets | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/ArkUI/entry/src/main/ets/pages/GetResourceManager.ets b/ArkUI/entry/src/main/ets/pages/GetResourceManager.ets index e69de29..0409a18 100644 --- a/ArkUI/entry/src/main/ets/pages/GetResourceManager.ets +++ b/ArkUI/entry/src/main/ets/pages/GetResourceManager.ets @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 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 +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:新建工程/模块无法加载ets目录下的资源 +*/ + +// [Start GetResourceManager] +// xxx.ets +@Entry +@Component +struct ImageExample { + private settings: RenderingContextSettings = new RenderingContextSettings(true); + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings); + // Replace "common/images/example.jpg" with the image resource file you use. + // private img: ImageBitmap = new ImageBitmap("common/images/example.jpg"); // This relative path writing will make it impossible to record pictures in the new template + private img: ImageBitmap = new ImageBitmap(this.getUIContext().getHostContext()?.resourceManager + .getDrawableDescriptorByName("example") + .getPixelMap()); // You can refer to the interface for using resourceManager + + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Canvas(this.context) + .width('100%') + .height('100%') + .backgroundColor('#ffff00') + .onReady(() => { + this.context.drawImage(this.img, 0, 0, 500, 500, 0, 0, 400, 200) + this.img.close() + }) + } + .width('100%') + .height('100%') + } +} +// [End GetResourceManager] -- Gitee From 01804c7aef343cf8e710f2a7b66f7e6fe49a42dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A2=A6=E9=BE=99?= Date: Thu, 6 Nov 2025 04:00:05 +0000 Subject: [PATCH 4/4] update ArkUI/entry/src/main/ets/pages/GetResources.ets. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨梦龙 --- .../entry/src/main/ets/pages/GetResources.ets | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/ArkUI/entry/src/main/ets/pages/GetResources.ets b/ArkUI/entry/src/main/ets/pages/GetResources.ets index 932ae41..869ea8b 100644 --- a/ArkUI/entry/src/main/ets/pages/GetResources.ets +++ b/ArkUI/entry/src/main/ets/pages/GetResources.ets @@ -1,3 +1,23 @@ +/* +* Copyright (c) 2024 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 +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:新建工程/模块无法加载ets目录下的资源 +*/ + +// [Start GetResource] // xxx.ets @Entry @Component @@ -27,4 +47,5 @@ struct VideoPlayer { }) } } -} \ No newline at end of file +} +// [End GetResource] -- Gitee