diff --git a/avvolumepanel_static/BUILD.gn b/avvolumepanel_static/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f8fff1bad108c9903e7137a7fc82dde35e6f7f38 --- /dev/null +++ b/avvolumepanel_static/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright (c) 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 +# +# 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. + +import("//build/ohos.gni") +import("//build/config/components/ace_engine/ace_gen_obj.gni") + +group("avvolumepanel_static") { + deps = [] + if ("${target_platform}" == "watch") { + deps += [ + "avvolumepanel_watch:av_volume_panel_watch", + ] + } else { + deps += [ + "avvolumepanel:av_volume_panel", + ] + } +} diff --git a/avvolumepanel_static/avvolumepanel/@ohos.multimedia.avVolumePanel.d.ets b/avvolumepanel_static/avvolumepanel/@ohos.multimedia.avVolumePanel.d.ets new file mode 100644 index 0000000000000000000000000000000000000000..0721efd3798f48d28840fdd46048165ca2c8b369 --- /dev/null +++ b/avvolumepanel_static/avvolumepanel/@ohos.multimedia.avVolumePanel.d.ets @@ -0,0 +1,80 @@ +/* + * Copyright (c) 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 + * + * 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. + */ + +import { Component, UIExtensionComponent, UIExtensionProxy, Column, Position } from '@ohos.arkui.component'; +import { Watch, PropRef } from '@ohos.arkui.stateManagement' +import { RecordData } from '@ohos.base'; +import Want from '@ohos.app.ability.Want' + +const TAG = 'AVVolumePanel'; + +class AVVolumePanelParameter { + public position?: Position; +} + +@Component +export struct AVVolumePanel { + @PropRef@Watch('volumeChange') + volumeLevel?: number = 0; + @PropRef + volumeParameter?: AVVolumePanelParameter; + + /* + * UIExtensionProxy. + */ + private volumeCallback!: UIExtensionProxy; + private panelCountOncreation: number = 0; + + private static currentPanelCount: number = 0; + + volumeChange(volumeChange : string) { + if (this.volumeCallback != null) { + console.info(TAG, `volumeChange volumeLevel = ` + this.volumeLevel); + this.volumeCallback.send({'volume': this.volumeLevel}); + } + } + + aboutToAppear(): void { + AVVolumePanel.currentPanelCount += 1; + this.panelCountOncreation = AVVolumePanel.currentPanelCount; + } + + aboutToDisAppear(): void { + AVVolumePanel.currentPanelCount -= 1; + } + + build() { + Column() { + UIExtensionComponent( + { + abilityName: 'AVVolumeExtension', + bundleName: 'com.hmos.mediacontroller', + parameters: { + 'volumeParameter': this.volumeParameter, + 'ability.want.params.uiExtensionType': 'sysPicker/mediaControl', + 'currentPanelCount': this.panelCountOncreation, + } as Record + } as Want) + .onReceive((data) => { + console.info(TAG, `onReceive : ${JSON.stringify(data['state'])}`); + }) + .onRemoteReady((callback: UIExtensionProxy) => { + console.info(TAG, `onRemoteReady callback : ${JSON.stringify(callback)}`); + this.volumeCallback = callback; + }) + .size({width: '100%', height: '100%'}) + }.size({width: '100%', height: '100%'}) + } +} \ No newline at end of file diff --git a/avvolumepanel_static/avvolumepanel/BUILD.gn b/avvolumepanel_static/avvolumepanel/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..14bd7adad9d6154e37516f15148b8584910e61ee --- /dev/null +++ b/avvolumepanel_static/avvolumepanel/BUILD.gn @@ -0,0 +1,47 @@ +# Copyright (c) 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 +# +# 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. + +import("//build/config/components/ets_frontend/ets2abc_config.gni") +import("//build/ohos.gni") + +generate_static_abc("av_volume_panel_ets_abc") { + base_url = "./" + files = [ "./@ohos.multimedia.avVolumePanel.d.ets" ] + ui_enable = "True" + is_boot_abc = "True" + device_dst_file = "/system/framework/av_volume_panel_ets_abc.abc" + dst_file = target_out_dir + "/av_volume_panel_ets_abc/modules_static.abc" + out_puts = [ target_out_dir + "/av_volume_panel_ets_abc/modules_static.abc" ] +} + +ohos_copy("copy_av_volume_panel_ets_abc") { + sources = [ + target_out_dir + "/av_volume_panel_ets_abc/modules_static.abc" + ] + outputs = [ + target_out_dir + "/av_volume_panel_ets_abc.abc" + ] + deps = [ ":av_volume_panel_ets_abc" ] +} + +ohos_prebuilt_etc("av_volume_panel_ets_abc_etc") { + source = "$target_out_dir/av_volume_panel_ets_abc.abc" + module_install_dir = "framework" + subsystem_name = "multimedia" + part_name = "av_session" + deps = [ ":copy_av_volume_panel_ets_abc" ] +} + +group("av_volume_panel"){ + deps = [":av_volume_panel_ets_abc_etc"] +} \ No newline at end of file diff --git a/avvolumepanel_static/avvolumepanel_watch/@ohos.multimedia.avVolumePanel.d.ets b/avvolumepanel_static/avvolumepanel_watch/@ohos.multimedia.avVolumePanel.d.ets new file mode 100644 index 0000000000000000000000000000000000000000..0721efd3798f48d28840fdd46048165ca2c8b369 --- /dev/null +++ b/avvolumepanel_static/avvolumepanel_watch/@ohos.multimedia.avVolumePanel.d.ets @@ -0,0 +1,80 @@ +/* + * Copyright (c) 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 + * + * 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. + */ + +import { Component, UIExtensionComponent, UIExtensionProxy, Column, Position } from '@ohos.arkui.component'; +import { Watch, PropRef } from '@ohos.arkui.stateManagement' +import { RecordData } from '@ohos.base'; +import Want from '@ohos.app.ability.Want' + +const TAG = 'AVVolumePanel'; + +class AVVolumePanelParameter { + public position?: Position; +} + +@Component +export struct AVVolumePanel { + @PropRef@Watch('volumeChange') + volumeLevel?: number = 0; + @PropRef + volumeParameter?: AVVolumePanelParameter; + + /* + * UIExtensionProxy. + */ + private volumeCallback!: UIExtensionProxy; + private panelCountOncreation: number = 0; + + private static currentPanelCount: number = 0; + + volumeChange(volumeChange : string) { + if (this.volumeCallback != null) { + console.info(TAG, `volumeChange volumeLevel = ` + this.volumeLevel); + this.volumeCallback.send({'volume': this.volumeLevel}); + } + } + + aboutToAppear(): void { + AVVolumePanel.currentPanelCount += 1; + this.panelCountOncreation = AVVolumePanel.currentPanelCount; + } + + aboutToDisAppear(): void { + AVVolumePanel.currentPanelCount -= 1; + } + + build() { + Column() { + UIExtensionComponent( + { + abilityName: 'AVVolumeExtension', + bundleName: 'com.hmos.mediacontroller', + parameters: { + 'volumeParameter': this.volumeParameter, + 'ability.want.params.uiExtensionType': 'sysPicker/mediaControl', + 'currentPanelCount': this.panelCountOncreation, + } as Record + } as Want) + .onReceive((data) => { + console.info(TAG, `onReceive : ${JSON.stringify(data['state'])}`); + }) + .onRemoteReady((callback: UIExtensionProxy) => { + console.info(TAG, `onRemoteReady callback : ${JSON.stringify(callback)}`); + this.volumeCallback = callback; + }) + .size({width: '100%', height: '100%'}) + }.size({width: '100%', height: '100%'}) + } +} \ No newline at end of file diff --git a/avvolumepanel_static/avvolumepanel_watch/BUILD.gn b/avvolumepanel_static/avvolumepanel_watch/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9b6d893798ef6aa53d5279a1cd47272b24f5cd43 --- /dev/null +++ b/avvolumepanel_static/avvolumepanel_watch/BUILD.gn @@ -0,0 +1,47 @@ +# Copyright (c) 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 +# +# 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. + +import("//build/config/components/ets_frontend/ets2abc_config.gni") +import("//build/ohos.gni") + +generate_static_abc("av_volume_panel_ets_abc") { + base_url = "./" + files = [ "./@ohos.multimedia.avVolumePanel.d.ets" ] + ui_enable = "True" + is_boot_abc = "True" + device_dst_file = "/system/framework/av_volume_panel_ets_abc.abc" + dst_file = target_out_dir + "/av_volume_panel_ets_abc/modules_static.abc" + out_puts = [ target_out_dir + "/av_volume_panel_ets_abc/modules_static.abc" ] +} + +ohos_copy("copy_av_volume_panel_ets_abc") { + sources = [ + target_out_dir + "/av_volume_panel_ets_abc/modules_static.abc" + ] + outputs = [ + target_out_dir + "/av_volume_panel_ets_abc.abc" + ] + deps = [ ":av_volume_panel_ets_abc" ] +} + +ohos_prebuilt_etc("av_volume_panel_ets_abc_etc") { + source = "$target_out_dir/av_volume_panel_ets_abc.abc" + module_install_dir = "framework" + subsystem_name = "multimedia" + part_name = "av_session" + deps = [ ":copy_av_volume_panel_ets_abc" ] +} + +group("av_volume_panel_watch"){ + deps = [":av_volume_panel_ets_abc_etc"] +} \ No newline at end of file diff --git a/bundle.json b/bundle.json index 58d7391668f7279ff4a10e09d34bedfb67002a7e..fd596ebe2ff4605e3cf0c51dc3105dc9d0b4f0d4 100644 --- a/bundle.json +++ b/bundle.json @@ -83,7 +83,8 @@ "//foundation/multimedia/av_session/avpicker:avcastpickerparam", "//foundation/multimedia/av_session/avvolumepanel:avvolumepanel", "//foundation/multimedia/av_session/avinputcastpicker:avinputcastpicker", - "//foundation/multimedia/av_session/avpicker_static:avpicker_static" + "//foundation/multimedia/av_session/avpicker_static:avpicker_static", + "//foundation/multimedia/av_session/avvolumepanel_static:avvolumepanel_static" ], "service_group": [ "//foundation/multimedia/av_session/services/session:avsession_item",