180922886Sopenharmony_ci/* 280922886Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 380922886Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 480922886Sopenharmony_ci * you may not use this file except in compliance with the License. 580922886Sopenharmony_ci * You may obtain a copy of the License at 680922886Sopenharmony_ci * 780922886Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 880922886Sopenharmony_ci * 980922886Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1080922886Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1180922886Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1280922886Sopenharmony_ci * See the License for the specific language governing permissions and 1380922886Sopenharmony_ci * limitations under the License. 1480922886Sopenharmony_ci */ 1580922886Sopenharmony_ci 1680922886Sopenharmony_ciconst TAG = 'AVVolumePanel'; 1780922886Sopenharmony_ci 1880922886Sopenharmony_ciclass AVVolumePanelParameter { 1980922886Sopenharmony_ci public position?: Position; 2080922886Sopenharmony_ci} 2180922886Sopenharmony_ci 2280922886Sopenharmony_ci@Component 2380922886Sopenharmony_ciexport struct AVVolumePanel { 2480922886Sopenharmony_ci @Prop@Watch('volumeChange') 2580922886Sopenharmony_ci volumeLevel?: number = 0; 2680922886Sopenharmony_ci @Prop 2780922886Sopenharmony_ci volumeParameter?: AVVolumePanelParameter; 2880922886Sopenharmony_ci 2980922886Sopenharmony_ci volumeCallback!: UIExtensionProxy; 3080922886Sopenharmony_ci 3180922886Sopenharmony_ci volumeChange() { 3280922886Sopenharmony_ci if (this.volumeCallback != null) { 3380922886Sopenharmony_ci console.info(TAG, `volumeChange volumeLevel = ` + this.volumeLevel); 3480922886Sopenharmony_ci this.volumeCallback.send({'volume': this.volumeLevel}); 3580922886Sopenharmony_ci } 3680922886Sopenharmony_ci } 3780922886Sopenharmony_ci 3880922886Sopenharmony_ci build() { 3980922886Sopenharmony_ci Column() { 4080922886Sopenharmony_ci UIExtensionComponent( 4180922886Sopenharmony_ci { 4280922886Sopenharmony_ci abilityName: 'AVVolumeExtension', 4380922886Sopenharmony_ci bundleName: 'com.hmos.mediacontroller', 4480922886Sopenharmony_ci parameters: { 4580922886Sopenharmony_ci 'volumeParameter': this.volumeParameter, 4680922886Sopenharmony_ci } 4780922886Sopenharmony_ci }) 4880922886Sopenharmony_ci .onReceive((data) => { 4980922886Sopenharmony_ci console.info(TAG, `onReceive : ${JSON.stringify(data['state'])}`); 5080922886Sopenharmony_ci }) 5180922886Sopenharmony_ci .onRemoteReady((callback: UIExtensionProxy) => { 5280922886Sopenharmony_ci console.info(TAG, `onRemoteReady callback : ${JSON.stringify(callback)}`); 5380922886Sopenharmony_ci this.volumeCallback = callback; 5480922886Sopenharmony_ci }) 5580922886Sopenharmony_ci .size({width: '100%', height: '100%'}) 5680922886Sopenharmony_ci }.size({width: '100%', height: '100%'}) 5780922886Sopenharmony_ci } 5880922886Sopenharmony_ci}