diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b1d626e99fd79e99ba8153402aa0e01835945ff7 --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.sample.AudioFormatSwitch", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..12d1c26bd7d1944b23576c8eac6dcacee6ed6804 --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AudioFormatSwitch" + } + ] +} diff --git a/AppScope/resources/base/media/background.png b/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/AppScope/resources/base/media/background.png differ diff --git a/AppScope/resources/base/media/foreground.png b/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..eb9427585b36d14b12477435b6419d1f07b3e0bb Binary files /dev/null and b/AppScope/resources/base/media/foreground.png differ diff --git a/AppScope/resources/base/media/layered_image.json b/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..18795a48d6b12fcdc1aa7bac9a9cb99f83815267 --- /dev/null +++ b/LICENSE @@ -0,0 +1,78 @@ + Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved. + + 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. + +Apache License, Version 2.0 +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: +1.You must give any other recipients of the Work or Derivative Works a copy of this License; and +2.You must cause any modified files to carry prominent notices stating that You changed the files; and +3.You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +4.If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/README.en.md b/README.en.md deleted file mode 100644 index e4f50fdc5190e690205be072419772942aeb514f..0000000000000000000000000000000000000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# AudioFormatSwitch - -#### Description -本示例主要介绍了AudioRender和AVPlayer、AVPlayer和AVPlayer实例之间如何进行不同音频格式文件的播放切换,且切换后保持播放进度一致,并续播。 - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md index ab085750e5a36e3649b5deb0940c492aa4179297..5827d87d3ec7d135261d6300357e2a0c4a61c80a 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,64 @@ -# AudioFormatSwitch +# 实现音质切换 -#### 介绍 -本示例主要介绍了AudioRender和AVPlayer、AVPlayer和AVPlayer实例之间如何进行不同音频格式文件的播放切换,且切换后保持播放进度一致,并续播。 +## 项目简介 -#### 软件架构 -软件架构说明 +本案例实现了音质切换的功能,指导开发者了解在AVPlayer和AudioRenderer之间如何进行切换播放。其中,AVPlayer用于播放MP3、FLAC的音频格式,AudioRenderer用于播放PCM的音频格式。同时,还包含了AudioRenderer播放字节进度与AVPlayer播放时间进度之间的转化。 -#### 安装教程 +## 效果预览 -1. xxxx -2. xxxx -3. xxxx +| 主页面 | +|--------------------------------------| +| ![](screenshots/MainPage.png) | -#### 使用说明 +## 使用说明 +1. 安装进入应用。 +2. 点击切换音频格式,音频格式包含MP3、FLAC、PCM三种格式。 -1. xxxx -2. xxxx -3. xxxx +## 工程目录 -#### 参与贡献 +``` +├──entry/src/main/ets/ +│ ├──common +│ │ └──Constants.ets // 常量 +│ ├──components // 各模块组件 +│ │ └──ControlAreaComponent.ets // 音频操控区组件 +│ ├──entryability +│ │ └──EntryAbility.ets // Ability的生命周期回调内容 +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets // EntryBackupAbility的生命周期回调内容 +│ ├──model +│ │ └──SongData.ets // 歌曲实体 +│ ├──pages +│ │ └──Index.ets // 首页 +│ ├──player +│ │ ├──AudioRendererController.ets // AudioRenderer播放控制 +│ │ ├──AVPlayerController.ets // AVPlayer播放控制 +│ │ └──PlayerController.ets // 整体播放控制 +│ └──utils +│ ├──ColorTools.ets // 背景颜色工具类 +│ ├──Logger.ets // 日志工具类 +│ └──MediaTools.ets // 媒体工具类 +└──entry/src/main/resources // 应用静态资源目录 +``` -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request +## 具体实现 +1. 通过AVPlayer实现播放MP3、FLAC的功能,包括AVPlayer初始化、播放、暂停等功能。 +2. 通过AudioRenderer实现播放PCM的功能,包括AudioRenderer初始化、播放、暂停等功能。 +3. 记录AVPlayer与AudioRenderer的当前播放的进度。其中,AVPlayer记录的为时间进度,AudioRenderer记录的为文件字节读取的进度。 +4. 在切换音频格式时,将AVPlayer与AudioRenderer之间的进度相互转化。 +## 相关权限 -#### 特技 +不涉及 -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +## 依赖 + +不涉及 + +## 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:华为手机。 +2. HarmonyOS系统:HarmonyOS 6.0.0 Release及以上。 +3. DevEco Studio版本:DevEco Studio 6.0.0 Release及以上。 +4. HarmonyOS SDK版本:HarmonyOS 6.0.0 Release SDK及以上。 \ No newline at end of file diff --git a/build-profile.json5 b/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9a1a212d0524c67bd93e82f56a65e74d6a1e2ae9 --- /dev/null +++ b/build-profile.json5 @@ -0,0 +1,40 @@ +{ + "app": { + "signingConfigs": [ + ], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "6.0.0(20)", + "compatibleSdkVersion": "6.0.0(20)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code-linter.json5 b/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..14e1253e73749ad0eedc61efc4b90036db8a89cc --- /dev/null +++ b/entry/build-profile.json5 @@ -0,0 +1,30 @@ +{ + "apiType": "stageMode", + "buildOption": { + "resOptions": { + "copyCodeResource": { + "enable": false + } + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + } + ] +} \ No newline at end of file diff --git a/entry/hvigorfile.ts b/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0e3a1ab98a91bc918d6404b2413111a5011f14a --- /dev/null +++ b/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/entry/src/main/ets/common/Constants.ets b/entry/src/main/ets/common/Constants.ets new file mode 100644 index 0000000000000000000000000000000000000000..1b3fd461cb4fed4568df1870a748d2a290083667 --- /dev/null +++ b/entry/src/main/ets/common/Constants.ets @@ -0,0 +1,38 @@ +/* + * 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 { SongData } from '../model/SongData'; + +export enum AudioType { + MP3 = 1, + FLAC = 2, + PCM = 3 +} + +export enum AudioName { + MP3 = '.mp3', + FLAC = '.flac', + PCM = '.pcm' +} + +export const songDataList: SongData[] = [{ + id: 1, + title: 'Dream It Possible', + singer: 'Delacey', + label: $r('app.media.ic_dream'), + src: 'Delacey - Dream It Possible', + index: 0, + isDarkBackground: true, + mark: $r('app.media.ic_vip') +}] \ No newline at end of file diff --git a/entry/src/main/ets/components/ControlAreaComponent.ets b/entry/src/main/ets/components/ControlAreaComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..4d422bf74a685ea5c079e84e79a2a7391b8b6c49 --- /dev/null +++ b/entry/src/main/ets/components/ControlAreaComponent.ets @@ -0,0 +1,224 @@ +/* + * 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 { LengthMetrics, SymbolGlyphModifier, TextModifier } from '@kit.ArkUI'; +import { SongData } from '../model/SongData'; +import { PlayerController } from '../player/PlayerController'; +import { Logger } from '../utils/Logger'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { AudioType, AudioName } from '../common/Constants'; + +@Component +export struct ControlAreaComponent { + @State isPlay: boolean = false; + @StorageLink('currentTime') currentTime: string = '00:00'; + @StorageLink('totalTime') totalTime: string = '00:00'; + @StorageLink('progress') value: number = 0; + @StorageLink('progressMax') max: number = 0; + @Prop songData: SongData = new SongData(); + @Prop imageColor: string = 'rgba(0, 0, 2, 1.00)'; + @State isShowPlayList: boolean = false; + @State isFavorite: boolean = false; + private index: number = 0; + @State text: Resource = $r('app.string.standard_quality'); + symbolGlyphModifier: SymbolGlyphModifier = new SymbolGlyphModifier(); + selectedOptionTextModifier: TextModifier = new TextModifier(); + private playerController: PlayerController = new PlayerController(); + + aboutToAppear(): void { + this.symbolGlyphModifier + .fontSize(12) + .fontColor(['#999999']) + + this.selectedOptionTextModifier + .maxLines(1) + .fontSize(12) + .textAlign(TextAlign.Start) + .fontWeight(FontWeight.Bold) + .width(160) + this.getUIContext().getHostContext()?.resourceManager.getRawFd(this.songData.src + AudioName.MP3) + .then((rawFileDescriptor) => { + this.playerController.defaultPlay(rawFileDescriptor); + this.isPlay = true; + }) + .catch((error: BusinessError) => { + Logger.error(`resourceManager error code ${error.code} message ${error.message}`); + }); + } + + aboutToDisappear(): void { + this.playerController.release(); + } + + build() { + Column() { + Row() { + Button(this.text) + .fontSize(16) + .width(100) + .bindMenu(this.MyMenu) + .backgroundColor(this.imageColor); + + Image(this.isFavorite ? $r('app.media.heart_fill') : $r('app.media.heart')) + .fillColor(this.isFavorite ? Color.Red : Color.White) + .controlImageBuilder() + .animation({ + duration: 500 + }) + .width(24) + .onClick(() => { + this.isFavorite = !this.isFavorite; + }) + } + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + + Column() { + Slider({ + min: 0, + max: this.max, + step: 1, + style: SliderStyle.OutSet, + value: this.value + }) + .selectedColor('#DBFFFFFF') + .trackColor('#33FFFFFF') + .onChange((value: number, mode: SliderChangeMode) => { + if (mode === SliderChangeMode.End || mode === SliderChangeMode.Begin) { + this.playerController.seek(value); + } + }) + .height(16) + .margin({ + left: -4, + right: -4 + }) + .hitTestBehavior(HitTestMode.Block) + Row() { + Text(this.currentTime) + .fontColor('#99FFFFFF') + .fontSize(10) + .fontFamily('HarmonyHeiTi') + .lineHeight('14vp') + Text(this.totalTime) + .fontColor('#99FFFFFF') + .fontSize(10) + .fontFamily('HarmonyHeiTi') + .lineHeight('14vp') + } + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + } + .margin({ + top: 24, + bottom: 12 + }) + + Row() { + Image($r('app.media.ic_public_forward')) + .controlImageBuilder() + .width(32) + Image(this.isPlay ? $r('app.media.ic_public_play') : $r('app.media.ic_public_pause')) + .controlImageBuilder() + .width(72) + .onClick(() => { + if (this.isPlay) { + this.playerController.pause(); + } else { + this.playerController.start(); + } + this.isPlay = !this.isPlay; + }) + Image($r('app.media.ic_public_next')) + .controlImageBuilder() + .width(32) + } + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + .padding({ + left: 36, + right: 36 + }) + } + } + + @Builder + MyMenu() { + Menu() { + MenuItem({ + content: $r('app.string.standard_quality'), + }).onClick(() => { + if (this.index === 0) { + return; + } + this.text = $r('app.string.standard_quality'); + this.index = 0; + this.changeType(this.songData.src + AudioName.MP3, AudioType.MP3); + this.isPlay = true; + }) + MenuItem({ + content: $r('app.string.flac_high_quality'), + }) + .onClick(() => { + if (this.index === 1) { + return; + } + this.text = $r('app.string.flac_high_quality'); + this.index = 1; + this.changeType(this.songData.src + AudioName.FLAC, AudioType.FLAC); + this.isPlay = true; + }) + MenuItem({ + content: $r('app.string.pcm_high_quality'), + }) + .onClick(() => { + if (this.index === 2) { + return; + } + this.text = $r('app.string.pcm_high_quality'); + this.index = 2; + this.changeType(this.songData.src + AudioName.PCM, AudioType.PCM); + this.isPlay = true; + }) + } + .width(224) + .font({ size: 16 }) + .height(152) + .menuItemDivider({ + strokeWidth: LengthMetrics.vp(0.5), + color: '#d5d5d5', + mode: DividerMode.EMBEDDED_IN_MENU + }) + .subMenuExpandingMode(SubMenuExpandingMode.EMBEDDED_EXPAND) + .backgroundColor(Color.White) + } + + private changeType(songSrc: string, audioType: AudioType): void { + let current: number = this.value; + this.getUIContext().getHostContext()?.resourceManager.getRawFd(songSrc).then((rawFileDescriptor) => { + this.playerController.changeType(rawFileDescriptor, audioType); + this.playerController.seek(current); + }).catch((error: BusinessError) => { + Logger.error(`resourceManager error code ${error.code} message ${error.message}`); + }); + } +} + +@Extend(Image) +function controlImageBuilder() { + .aspectRatio(1) + .opacity(0.86) + .objectFit(ImageFit.Contain) +} diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..05e8bd1b67746d177bbbaeb648dcc9e1dbe2addc --- /dev/null +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,82 @@ +/* + * 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 { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; +import { Logger } from '../utils/Logger'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + try { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } catch (err) { + hilog.error(DOMAIN, 'testTag', 'Failed to set colorMode. Cause: %{public}s', JSON.stringify(err)); + } + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + + windowStage.getMainWindow().then((window: window.Window) => { + window.setWindowLayoutFullScreen(true).catch(() => { + Logger.error('setWindowLayoutFullScreen error!'); + }); + let systemBarProperties: window.SystemBarProperties = { + statusBarContentColor: '#ffffff', + }; + + window.setWindowSystemBarProperties(systemBarProperties).catch(() => { + Logger.error('setWindowSystemBarProperties fail '); + }).then(() => { + Logger.info('setWindowSystemBarProperties success '); + }) + }).catch(() => { + Logger.error('getMainWindow error!'); + }) + + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a97e21bd7a15599af76a806695860ff1eb0ebfe --- /dev/null +++ b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,31 @@ +/* + * 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 { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/model/SongData.ets b/entry/src/main/ets/model/SongData.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ac7007694fd8e847ad66c017d449e1ccf9e7b9f --- /dev/null +++ b/entry/src/main/ets/model/SongData.ets @@ -0,0 +1,52 @@ +/* + * 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. + */ + +/** + * Music information entity class. + */ +export class SongData { + /** + * Primary key ID. + */ + id: number = 0; + /** + * Music name. + */ + title: string = ''; + /** + * Music author name. + */ + singer: string = ''; + /** + * Music logo information. + */ + mark: Resource = $r('app.string.page_show'); + /** + * Music avatar information. + */ + label: Resource = $r('app.string.page_show'); + /** + * Music file path information. + */ + src: string = ''; + /** + * Index of the current music list. + */ + index: number = 0; + /** + * Is the background dark. + */ + isDarkBackground: boolean = false; +} diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..7b495a84f40ac705a8536c9b0a93d626e1370e51 --- /dev/null +++ b/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,143 @@ +/* + * 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 { BusinessError } from '@kit.BasicServicesKit'; +import { effectKit } from '@kit.ArkGraphics2D'; +import { image } from '@kit.ImageKit'; +import { Logger } from '../utils/Logger'; +import { SongData } from '../model/SongData'; +import { ControlAreaComponent } from '../components/ControlAreaComponent'; +import { songDataList } from '../common/Constants'; +import { ColorTools } from '../utils/ColorTools'; + +@Entry +@Component +struct Index { + private songDataList: SongData[] = songDataList; + @State imageColor: string = 'rgba(0, 0, 2, 1.00)'; + @State imageLabel: PixelMap | Resource = this.songDataList[0].label; + + aboutToAppear(): void { + this.getImageColor(); + } + + build() { + Stack() { + Image(this.imageLabel) + .size({ height: '120%' }) + .aspectRatio(1) + .objectFit(ImageFit.Cover) + .opacity(0.5) + + Column() { + this.CoverInfo() + this.MusicInfo() + Blank() + ControlAreaComponent({ songData: this.songDataList[0], imageColor: this.imageColor }) + } + .height('100%') + .width('100%') + .padding({ + top: 64, + left: 24, + right: 24, + bottom: 24 + }) + + } + .height('100%') + .width('100%') + .backgroundColor(this.imageColor) + } + + @Builder + CoverInfo() { + Row() { + Image(this.songDataList[0].label) + .height('100%') + .aspectRatio(1) + .borderRadius(8) + .shadow({ + radius: 12, + color: '#66000000', + offsetX: 0, + offsetY: 8 + }) + .margin(3) + } + .height('40%') + } + + @Builder + MusicInfo() { + Column() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text(this.songDataList[0].title) + .fontSize(20) + .fontColor(Color.White) + .opacity(0.86) + .fontWeight(FontWeight.Bold) + .fontFamily('HarmonyHeiTi-Bold') + } + + Text(this.songDataList[0].singer) + .textAlign(TextAlign.Start) + .fontSize(14) + .fontColor('#99FFFFFF') + .fontFamily('HarmonyHeiTi') + .width('100%') + .fontWeight(FontWeight.Regular) + } + .margin({ top: 24 }) + } + + getImageColor() { + this.getUIContext().getHostContext()!.resourceManager.getMediaContent(this.songDataList[0].label.id) + .then((value: Uint8Array) => { + let buffer = value.buffer as ArrayBuffer; + let imageSource: image.ImageSource = image.createImageSource(buffer); + let currentPixelMap: image.PixelMap | undefined = undefined; + imageSource.createPixelMap().then((pixelMap) => { + effectKit.createColorPicker(pixelMap, (error, colorPicker) => { + if (error) { + Logger.error(`Failed to create color picker. Error: ${error.code}, message: ${error.message}`); + } else { + currentPixelMap = pixelMap; + let color: effectKit.Color = colorPicker.getLargestProportionColor(); + let colorArr: number[] = ColorTools.dealColor(color.red, color.green, color.blue); + this.imageColor = `rgba(${colorArr[0]}, ${colorArr[1]}, ${colorArr[2]}, 1)`; + } + }) + let headFilter = effectKit.createEffect(pixelMap); + if (headFilter !== null) { + headFilter.blur(15); + headFilter.getEffectPixelMap().then((value) => { + this.imageLabel = value; + }) + } + }) + .finally(() => { + imageSource?.release(); + currentPixelMap?.release(); + }) + .catch((error: BusinessError) => { + Logger.error(`createPixelMap error: ${error.code}, message: ${error.message}`); + }) + }) + .catch((error: BusinessError) => { + Logger.error(`getMediaContent error: ${error.code}, message: ${error.message}`); + }) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/player/AVPlayerController.ets b/entry/src/main/ets/player/AVPlayerController.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc3608b7e21988c6470f702f6b7874f1c692b3d5 --- /dev/null +++ b/entry/src/main/ets/player/AVPlayerController.ets @@ -0,0 +1,138 @@ +/* + * 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 { media } from '@kit.MediaKit'; +import { Logger } from '../utils/Logger'; +import { MediaTools } from '../utils/MediaTools'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { audio } from '@kit.AudioKit'; + +export class AVPlayerController { + private avPlayer: media.AVPlayer | undefined = undefined; + private currentTime: number = 0; + private isReset = false; + + async init(fd: number, offset: number, length: number): Promise { + try { + this.avPlayer = await media.createAVPlayer(); + this.avPlayer.audioInterruptMode = audio.InterruptMode.INDEPENDENT_MODE; + await this.setAVPlayerCallback(); + this.avPlayer.fdSrc = { fd: fd, offset: offset, length: length }; + } catch (error) { + Logger.error('AVPlayer init fail.'); + } + } + + prepare(): void { + this.avPlayer?.prepare((err: BusinessError) => { + if (err) { + Logger.error('Failed to prepare,error message is :' + err.message); + } else { + Logger.info('Succeeded in preparing'); + } + }); + } + + reset(fd: number, offset: number, length: number): void { + this.currentTime = AppStorage.get('progress') as number; + this.isReset = true; + this.avPlayer?.reset(() => { + if (this.avPlayer != undefined) { + this.avPlayer.fdSrc = { fd: fd, offset: offset, length: length }; + } + }) + } + + stop(): void { + this.avPlayer?.stop().catch(() => { + Logger.error('AVPlayerController stop error!'); + }) + } + + play(): void { + this.avPlayer?.play().catch(() => { + Logger.error('AVPlayerController play error!'); + }) + } + + pause(): void { + this.avPlayer?.pause().catch(() => { + Logger.error('AVPlayerController pause error!'); + }) + } + + seek(currentTime: number): void { + this.avPlayer?.seek(currentTime, media.SeekMode.SEEK_NEXT_SYNC); + } + + private async setAVPlayerCallback(): Promise { + if (!this.avPlayer) { + return; + } + + this.avPlayer.on('timeUpdate', (currentTime: number) => { + if (!this.isReset) { + AppStorage.setOrCreate('progress', currentTime); + AppStorage.setOrCreate('currentTime', MediaTools.msToCountdownTime(currentTime)); + } + }); + + this.avPlayer.on('durationUpdate', (time: number) => { + AppStorage.setOrCreate('progressMax', time); + AppStorage.setOrCreate('totalTime', MediaTools.msToCountdownTime(time)); + }); + + this.avPlayer.on('error', (error: BusinessError) => { + Logger.error('error happened,and error message is :' + error.message); + Logger.error('error happened,and error code is :' + error.code); + }); + + this.avPlayer.on('stateChange', (state, reason) => { + if (!this.avPlayer) { + return; + } + switch (state) { + case 'idle': + break; + case 'initialized': + this.prepare(); + break; + case 'prepared': // This state machine is reported after the prepare interface is successfully invoked. + this.avPlayer.loop = true + this.avPlayer.play().then(() => { + this.seek(this.currentTime); + this.isReset = false; + }).catch(() => { + }); + break; + case 'playing': // After the play interface is successfully invoked, the state machine is reported. + break; + case 'completed': // This state machine is triggered to report when the playback ends. + break; + case 'error': + Logger.error('AVPlayer error!' + reason); + break; + default: + break; + } + }); + } + + release() { + this.avPlayer?.release().catch(() => { + Logger.error('AVPlayerController release error!'); + }); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/player/AudioRendererController.ets b/entry/src/main/ets/player/AudioRendererController.ets new file mode 100644 index 0000000000000000000000000000000000000000..ec86fef7a9eb01a3065cba415cd5bf4b4f334e22 --- /dev/null +++ b/entry/src/main/ets/player/AudioRendererController.ets @@ -0,0 +1,178 @@ +/* + * 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 { audio } from '@kit.AudioKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { Logger } from '../utils/Logger'; +import { fileIo, ReadOptions } from '@kit.CoreFileKit'; +import { MediaTools } from '../utils/MediaTools'; + +export class AudioRendererController { + private audioRenderer: audio.AudioRenderer | undefined = undefined; + private currentOffset: number = 0; + private offset: number = 0; + private length: number = 0; + private fd: number = 0; + private curMs: number = 0; + + public async initAudioRenderer(fd: number, offset: number, length: number): Promise { + this.fd = fd; + this.offset = offset; + this.currentOffset = offset; + this.length = length; + let audioStreamInfo: audio.AudioStreamInfo = { + samplingRate: audio.AudioSamplingRate.SAMPLE_RATE_48000, + channels: audio.AudioChannel.CHANNEL_2, + sampleFormat: audio.AudioSampleFormat.SAMPLE_FORMAT_S16LE, + encodingType: audio.AudioEncodingType.ENCODING_TYPE_RAW + }; + + let audioRendererInfo: audio.AudioRendererInfo = { + usage: audio.StreamUsage.STREAM_USAGE_MUSIC, + rendererFlags: 0 + }; + + let audioRendererOptions: audio.AudioRendererOptions = { + streamInfo: audioStreamInfo, + rendererInfo: audioRendererInfo + }; + + await audio.createAudioRenderer(audioRendererOptions).then((data) => { + this.audioRenderer = data; + if (this.audioRenderer !== undefined) { + try { + this.audioRenderer.setInterruptMode(audio.InterruptMode.INDEPENDENT_MODE); + this.setWriteDataCallback(); + } catch (error) { + Logger.error('createAudioRenderer is calling.'); + } + } + }); + + AppStorage.setOrCreate('progressMax', MediaTools.getMsFromByteLength(this.length)); + AppStorage.setOrCreate('totalTime', MediaTools.msToCountdownTime(MediaTools.getMsFromByteLength(this.length))); + } + + private setWriteDataCallback(): void { + try { + this.audioRenderer?.on('writeData', (buffer) => { + if (this.currentOffset - this.offset >= this.length) { + this.currentOffset = this.offset; + this.seek(0); + } + let options: ReadOptions = { + offset: this.currentOffset, + length: buffer.byteLength + }; + let bufferLength = fileIo.readSync(this.fd, buffer, options); + this.currentOffset += buffer.byteLength; + let processOffset = this.currentOffset - this.offset; + + if (this.offset + this.length <= this.currentOffset) { + let view = new DataView(buffer); + Logger.info('currentOffset :' + this.currentOffset + ' endOffset:' + (this.offset + this.length) + + ' bufferLength:' + bufferLength); + for (let i = bufferLength - 1; i > processOffset - this.length; i--) { + view.setUint8(i, 0); + } + } + + let curMs = MediaTools.getMsFromByteLength(processOffset); + AppStorage.setOrCreate('progress', curMs); + AppStorage.setOrCreate('currentTime', MediaTools.msToCountdownTime(curMs)); + }) + } catch (error) { + Logger.error('setWriteDataCallback is failed. ' + error); + } + } + + + public async start(): Promise { + if (this.audioRenderer !== undefined) { + let stateGroup = [audio.AudioState.STATE_PREPARED, audio.AudioState.STATE_PAUSED, audio.AudioState.STATE_STOPPED]; + if (stateGroup.indexOf(this.audioRenderer.state.valueOf()) === -1) { + return; + } + this.audioRenderer.start((err: BusinessError) => { + if (err) { + Logger.error('Renderer start failed.'); + } else { + Logger.info('Renderer start success.'); + } + }); + } + } + + public pause(): void { + if (this.audioRenderer !== undefined) { + if (this.audioRenderer.state.valueOf() !== audio.AudioState.STATE_RUNNING) { + return; + } + + this.audioRenderer.pause((err: BusinessError) => { + if (err) { + Logger.error('Renderer pause failed.'); + } else { + Logger.info('Renderer pause success.'); + } + }); + } + } + + public seek(ms: number): void { + this.curMs = ms; + AppStorage.setOrCreate('progress', this.curMs); + AppStorage.setOrCreate('currentTime', MediaTools.msToCountdownTime(this.curMs)); + this.currentOffset = this.offset + MediaTools.getOffsetFromTime(this.curMs); + } + + public stop(): void { + if (this.audioRenderer !== undefined) { + + if (this.audioRenderer.state.valueOf() !== audio.AudioState.STATE_RUNNING && + this.audioRenderer.state.valueOf() !== audio.AudioState.STATE_PAUSED) { + return; + } + + this.audioRenderer.stop(() => { + Logger.error('audioRenderer stop failed.'); + }); + } + } + + public release(): void { + try { + if (this.audioRenderer !== undefined) { + if (this.audioRenderer.state.valueOf() === audio.AudioState.STATE_RELEASED) { + return; + } + + this.audioRenderer.off('writeData'); + this.audioRenderer.release(); + } + } catch (error) { + Logger.info('Renderer release fail.'); + } + } + + reset(fd: number, offset: number, length: number): void { + this.fd = fd; + this.offset = offset; + this.length = length; + this.curMs = 0; + AppStorage.setOrCreate('progress', 0); + AppStorage.setOrCreate('currentTime', MediaTools.msToCountdownTime(this.curMs)); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/player/PlayerController.ets b/entry/src/main/ets/player/PlayerController.ets new file mode 100644 index 0000000000000000000000000000000000000000..a8ec9e21bab28014710219b1449702c277387a68 --- /dev/null +++ b/entry/src/main/ets/player/PlayerController.ets @@ -0,0 +1,102 @@ +/* + * 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 { AudioType } from '../common/Constants'; +import { AudioRendererController } from './AudioRendererController'; +import { AVPlayerController } from './AVPlayerController'; +import { resourceManager } from '@kit.LocalizationKit'; +import { Logger } from '../utils/Logger'; + +export class PlayerController { + private avPlayerController: AVPlayerController | undefined = undefined; + private audioRendererController: AudioRendererController | undefined = undefined; + private currentType: AudioType = 0; + private rawFileDescriptor?: resourceManager.RawFileDescriptor; + + defaultPlay(rawFileDescriptor: resourceManager.RawFileDescriptor) { + this.rawFileDescriptor = rawFileDescriptor; + this.currentType = 1; + this.avPlayerController = new AVPlayerController(); + this.avPlayerController.init(rawFileDescriptor.fd, rawFileDescriptor.offset, rawFileDescriptor.length); + } + + changeType(rawFileDescriptor: resourceManager.RawFileDescriptor, audioType: AudioType) { + try { + this.rawFileDescriptor = rawFileDescriptor; + if (audioType === 1 || audioType === 2) { + this.audioRendererController?.pause(); + this.avPlayerController?.reset(this.rawFileDescriptor.fd, this.rawFileDescriptor.offset, + this.rawFileDescriptor.length); + } else { + this.avPlayerController?.pause(); + if (this.audioRendererController === undefined) { + this.audioRendererController = new AudioRendererController(); + } + this.audioRendererController.initAudioRenderer(this.rawFileDescriptor.fd, this.rawFileDescriptor.offset, + this.rawFileDescriptor.length).then(() => { + this.audioRendererController?.start(); + }); + } + this.currentType = audioType; + } catch (error) { + Logger.error('changeType error!'); + } + } + + start(): void { + if (this.isAVPlayer()) { + this.avPlayerController?.play(); + } else { + this.audioRendererController?.start(); + } + } + + stop(): void { + if (this.isAVPlayer()) { + this.avPlayerController?.stop(); + } else { + this.audioRendererController?.stop(); + } + } + + pause(): void { + if (this.isAVPlayer()) { + this.avPlayerController?.pause(); + } else { + this.audioRendererController?.pause(); + } + } + + seek(currentTime: number): void { + if (this.isAVPlayer()) { + this.avPlayerController?.seek(currentTime); + } else { + this.audioRendererController?.seek(currentTime); + } + } + + release() { + if (this.avPlayerController) { + this.avPlayerController.release(); + } + if (this.audioRendererController) { + this.audioRendererController.release(); + } + } + + isAVPlayer(): boolean { + return this.currentType === 1 || this.currentType === 2; + } +} \ No newline at end of file diff --git a/entry/src/main/ets/utils/ColorTools.ets b/entry/src/main/ets/utils/ColorTools.ets new file mode 100644 index 0000000000000000000000000000000000000000..e5faefb7d9e2e14db5844f6c56e75bdb5a02f76c --- /dev/null +++ b/entry/src/main/ets/utils/ColorTools.ets @@ -0,0 +1,85 @@ +/* + * 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. + */ + +export class ColorTools { + public static dealColor(rRGB: number, gRGB: number, bRGB: number): number[] { + let max = Math.max(Math.max(rRGB, gRGB), bRGB); + let min = Math.min(Math.min(rRGB, gRGB), bRGB); + let sHSB = max === 0 ? 0 : (max - min) / max; + let bHSB = max / 255; + let hHSB = 0; + if (max === rRGB && gRGB >= bRGB) { + hHSB = 60 * (gRGB - bRGB) / (max - min) + 0; + } + if (max === rRGB && gRGB < bRGB) { + hHSB = 60 * (gRGB - bRGB) / (max - min) + 360; + } + if (max === gRGB) { + hHSB = 60 * (bRGB - rRGB) / (max - min) + 120; + } + if (max === bRGB) { + hHSB = 60 * (rRGB - gRGB) / (max - min) + 240; + } + + if (bHSB >= 0.4) { + bHSB = 0.3; + } else if (bHSB >= 0.2) { + bHSB -= 0.1; + } else { + bHSB = bHSB + 0.2; + } + + let i: number = Math.floor((hHSB / 60) % 6); + let f = (hHSB / 60) - i; + let p = bHSB * (1 - sHSB); + let q = bHSB * (1 - f * sHSB); + let t = bHSB * (1 - (1 - f) * sHSB); + switch (i) { + case 0: + rRGB = bHSB; + gRGB = t; + bRGB = p; + break; + case 1: + rRGB = q; + gRGB = bHSB; + bRGB = p; + break; + case 2: + rRGB = p; + gRGB = bHSB; + bRGB = t; + break; + case 3: + rRGB = p; + gRGB = q; + bRGB = bHSB; + break; + case 4: + rRGB = t; + gRGB = p; + bRGB = bHSB; + break; + case 5: + rRGB = bHSB; + gRGB = p; + bRGB = q; + break; + default: + break; + } + return [Math.floor(rRGB * 255.0), Math.floor(gRGB * 255.0), Math.floor(bRGB * 255.0)]; + } +} \ No newline at end of file diff --git a/entry/src/main/ets/utils/Logger.ets b/entry/src/main/ets/utils/Logger.ets new file mode 100644 index 0000000000000000000000000000000000000000..10be069e54d0d4534cca1303ab5f6452b08f1ab0 --- /dev/null +++ b/entry/src/main/ets/utils/Logger.ets @@ -0,0 +1,38 @@ +/* + * 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 { hilog } from '@kit.PerformanceAnalysisKit'; + +export class Logger { + private static domain: number = 0xFF00; + private static prefix: string = 'AudioFormatSwitch'; + private static format: string = '%{public}s, %{public}s'; + + static debug(...args: string[]): void { + hilog.debug(Logger.domain, Logger.prefix, Logger.format, args); + } + + static info(...args: string[]): void { + hilog.info(Logger.domain, Logger.prefix, Logger.format, args); + } + + static warn(...args: string[]): void { + hilog.warn(Logger.domain, Logger.prefix, Logger.format, args); + } + + static error(...args: string[]): void { + hilog.error(Logger.domain, Logger.prefix, Logger.format, args); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/utils/MediaTools.ets b/entry/src/main/ets/utils/MediaTools.ets new file mode 100644 index 0000000000000000000000000000000000000000..d9dcecf2effe82c88baefad1f09913816e8b4423 --- /dev/null +++ b/entry/src/main/ets/utils/MediaTools.ets @@ -0,0 +1,65 @@ +/* + * 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 { image } from '@kit.ImageKit'; +import { common } from '@kit.AbilityKit'; +import { resourceManager } from '@kit.LocalizationKit'; +import { Logger } from './Logger'; + +const TAG = 'MediaTools'; +const SECOND_BUFFER_WALK = 48000 * 2 * 2; + +export class MediaTools { + static async getPixelMapFromResource(context: common.UIAbilityContext, + name: resourceManager.Resource): Promise { + let resourceMgr = context.resourceManager; + let fileData: Uint8Array | undefined; + try { + fileData = await resourceMgr.getMediaContent(name.id); + } catch (error) { + Logger.info(TAG, 'getMediaContent error'); + } + return await image.createImageSource(fileData?.buffer as ArrayBuffer).createPixelMap(); + } + + static async getPixelMapFromFile(id: string, path: string): Promise { + Logger.info(TAG, 'getPixelMapFromFile id:' + id + ', path:' + path); + return await image.createImageSource(path).createPixelMap(); + } + + private static fill(value: number): string { + return value.toString().padStart(2, '0'); + } + + static msToCountdownTime(ms: number): string { + if (!ms) { + return '00:00'; + } + const days = Math.floor(ms / (1000 * 60 * 60 * 24)); + const hours = Math.floor((ms % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); + const minutes = Math.floor((ms % (1000 * 60 * 60)) / (1000 * 60)); + const seconds = Math.floor((ms % (1000 * 60)) / 1000); + return `${(days ? MediaTools.fill(days) + ':' : '')}${(hours ? MediaTools.fill(hours) + ':' : '')} + ${MediaTools.fill(minutes)}:${MediaTools.fill(seconds)} `.trim(); + } + + static getMsFromByteLength(byteLength: number): number { + return 1000 * (byteLength / SECOND_BUFFER_WALK); + } + + static getOffsetFromTime(curMs: number) { + return (curMs / 1000) * SECOND_BUFFER_WALK; + } +} \ No newline at end of file diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..53024e8f020cc0824592631ba6924108c8028f0f --- /dev/null +++ b/entry/src/main/module.json5 @@ -0,0 +1,50 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "ohos.want.action.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..6a7cb94402f3683b802678ce46d1ae29dd28d333 --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "AudioFormatSwitch" + }, + { + "name": "page_show", + "value": "page from package" + }, + { + "name": "play_list", + "value": "play list(%d)" + }, + { + "name": "standard_quality", + "value": "MP3 SQ(AVPlayer)" + }, + { + "name": "flac_high_quality", + "value": "FLAC HQ(AVPlayer)" + }, + { + "name": "pcm_high_quality", + "value": "PCM HQ(AudioRenderer)" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/background.png b/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/entry/src/main/resources/base/media/background.png differ diff --git a/entry/src/main/resources/base/media/foreground.png b/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/entry/src/main/resources/base/media/foreground.png differ diff --git a/entry/src/main/resources/base/media/heart.svg b/entry/src/main/resources/base/media/heart.svg new file mode 100644 index 0000000000000000000000000000000000000000..0cb86bd405578277715ece7075ed4f40280b7c9a --- /dev/null +++ b/entry/src/main/resources/base/media/heart.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/heart_fill.svg b/entry/src/main/resources/base/media/heart_fill.svg new file mode 100644 index 0000000000000000000000000000000000000000..93f227853978782ade78a8ef38d951f94cdf9ffc --- /dev/null +++ b/entry/src/main/resources/base/media/heart_fill.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_dream.png b/entry/src/main/resources/base/media/ic_dream.png new file mode 100644 index 0000000000000000000000000000000000000000..807515dc689390f15869267a4104543d8a855d63 Binary files /dev/null and b/entry/src/main/resources/base/media/ic_dream.png differ diff --git a/entry/src/main/resources/base/media/ic_music_list.svg b/entry/src/main/resources/base/media/ic_music_list.svg new file mode 100644 index 0000000000000000000000000000000000000000..6f89a64c5ad30aa7b0576570b6fdc8672c4412d6 --- /dev/null +++ b/entry/src/main/resources/base/media/ic_music_list.svg @@ -0,0 +1,7 @@ + + + ic_Music_list + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_forward.svg b/entry/src/main/resources/base/media/ic_public_forward.svg new file mode 100644 index 0000000000000000000000000000000000000000..e4f6ec63f2729149d2bb12642130a3b55c548967 --- /dev/null +++ b/entry/src/main/resources/base/media/ic_public_forward.svg @@ -0,0 +1,8 @@ + + + play/ic_previous_song_24 + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_next.svg b/entry/src/main/resources/base/media/ic_public_next.svg new file mode 100644 index 0000000000000000000000000000000000000000..b85e026329306cbb9f0211983fbc40540d74c4d8 --- /dev/null +++ b/entry/src/main/resources/base/media/ic_public_next.svg @@ -0,0 +1,8 @@ + + + play/ic_next_song_24 + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_pause.svg b/entry/src/main/resources/base/media/ic_public_pause.svg new file mode 100644 index 0000000000000000000000000000000000000000..6b4bf5aaa29127e510e730471c17c925b536c21b --- /dev/null +++ b/entry/src/main/resources/base/media/ic_public_pause.svg @@ -0,0 +1,8 @@ + + + play/ic_play_72 + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_public_play.svg b/entry/src/main/resources/base/media/ic_public_play.svg new file mode 100644 index 0000000000000000000000000000000000000000..dc75132974bb65fe74f107d2191803d4b9201692 --- /dev/null +++ b/entry/src/main/resources/base/media/ic_public_play.svg @@ -0,0 +1,8 @@ + + + play/ic_stop_72 + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_sort_list.svg b/entry/src/main/resources/base/media/ic_sort_list.svg new file mode 100644 index 0000000000000000000000000000000000000000..77cd7de67701e5e8b8b6630a0d6827fe3a15a069 --- /dev/null +++ b/entry/src/main/resources/base/media/ic_sort_list.svg @@ -0,0 +1,7 @@ + + + ic_sort_list + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_vip.svg b/entry/src/main/resources/base/media/ic_vip.svg new file mode 100644 index 0000000000000000000000000000000000000000..1b0561309697f7045a8f05e6f986e23848111f97 --- /dev/null +++ b/entry/src/main/resources/base/media/ic_vip.svg @@ -0,0 +1,7 @@ + + + icon_vip + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/layered_image.json b/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/order_play.svg b/entry/src/main/resources/base/media/order_play.svg new file mode 100644 index 0000000000000000000000000000000000000000..b1affe03fdd6be1a6b70972cf7555fe44fb271bf --- /dev/null +++ b/entry/src/main/resources/base/media/order_play.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/startIcon.png b/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/entry/src/main/resources/base/media/startIcon.png differ diff --git a/entry/src/main/resources/base/profile/backup_config.json b/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/entry/src/main/resources/dark/element/color.json b/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..6a7cb94402f3683b802678ce46d1ae29dd28d333 --- /dev/null +++ b/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "AudioFormatSwitch" + }, + { + "name": "page_show", + "value": "page from package" + }, + { + "name": "play_list", + "value": "play list(%d)" + }, + { + "name": "standard_quality", + "value": "MP3 SQ(AVPlayer)" + }, + { + "name": "flac_high_quality", + "value": "FLAC HQ(AVPlayer)" + }, + { + "name": "pcm_high_quality", + "value": "PCM HQ(AudioRenderer)" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/Delacey - Dream It Possible.flac b/entry/src/main/resources/rawfile/Delacey - Dream It Possible.flac new file mode 100644 index 0000000000000000000000000000000000000000..24837a36cf16fb5c3a761043c267a3ebd3b2cb5c Binary files /dev/null and b/entry/src/main/resources/rawfile/Delacey - Dream It Possible.flac differ diff --git a/entry/src/main/resources/rawfile/Delacey - Dream It Possible.mp3 b/entry/src/main/resources/rawfile/Delacey - Dream It Possible.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..ea6d2c77259e8622b7a4395edaece527356c2e23 Binary files /dev/null and b/entry/src/main/resources/rawfile/Delacey - Dream It Possible.mp3 differ diff --git a/entry/src/main/resources/rawfile/Delacey - Dream It Possible.pcm b/entry/src/main/resources/rawfile/Delacey - Dream It Possible.pcm new file mode 100644 index 0000000000000000000000000000000000000000..6b843ee753c8a79743f3ccb0f3e8817e93d75d5c Binary files /dev/null and b/entry/src/main/resources/rawfile/Delacey - Dream It Possible.pcm differ diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..5738c22fc6aa629cbf1675deb8b1618b00423c99 --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "AudioFormatSwitch" + }, + { + "name": "page_show", + "value": "page from package" + }, + { + "name": "play_list", + "value": "play list(%d)" + }, + { + "name": "standard_quality", + "value": "标清(AVPlayer)" + }, + { + "name": "flac_high_quality", + "value": "FLAC无损(AVPlayer)" + }, + { + "name": "pcm_high_quality", + "value": "PCM无损(AudioRender)" + } + ] +} \ No newline at end of file diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a7ab8914d8db6ab89758e185df5855dffe88d04 --- /dev/null +++ b/hvigor/hvigor-config.json5 @@ -0,0 +1,23 @@ +{ + "modelVersion": "6.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | "ultrafine" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + // "optimizationStrategy": "memory" /* Define the optimization strategy. Value: [ "memory" | "performance" ]. Default: "memory" */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/hvigorfile.ts b/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..47113e2e36ecefde41c136272a0bd6ff745cffe4 --- /dev/null +++ b/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/oh-package.json5 b/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..de6d59dbf4c1ef2715242f0cc34744e6075de0b8 --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,8 @@ +{ + "modelVersion": "6.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + } +} diff --git a/screenshots/MainPage.png b/screenshots/MainPage.png new file mode 100644 index 0000000000000000000000000000000000000000..a8d6d1d50f9242c2b77e9c7ce2bf2bdd387d2893 Binary files /dev/null and b/screenshots/MainPage.png differ