diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..98bd648bdd3bfcfba87fc6241bbb457973d5fb7f --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.videosubtitle", + "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..9934b0fb70d84688d987cb2c625bcc2bec1ed879 --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "videosubtitle" + } + ] +} 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 613381f94f63620c7b1c31c073c43c8b7ab63356..0000000000000000000000000000000000000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# VideoSubtitle - -#### Description -给视频添加字幕 - -#### 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 459912dd698d3eade58820b53b4a088ed83dad1b..2e30e11c0c22ecd9020acd4f068105dc132d75f4 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,58 @@ -# VideoSubtitle +## 实现视频外挂字幕 -#### 介绍 -给视频添加字幕 +### 介绍 -#### 软件架构 -软件架构说明 +本示例分别使用AVPlayer实例和Video组件两种方式,实现了视频配置外挂字幕和设置字幕字体格式、字体大小、颜色。 +### 效果预览 -#### 安装教程 +| 应用首页 | 应用效果展示 | +|-------------------------------------|----------------------------------------------| +| ![](./screenshots/devices/home.png) | ![](./screenshots/devices/captionVideo.webp) | -1. xxxx -2. xxxx -3. xxxx +使用说明: +1. 打开应用,点击按钮,进入avPlayer/video组件外挂字幕页面。 +2. 点击下方字幕设置按钮,选择字幕格式,设置完成,点击确认,字幕格式修改生效。 -#### 使用说明 -1. xxxx -2. xxxx -3. xxxx +### 工程目录 -#### 参与贡献 +``` +├──entry/src/main/ets/ +│ ├──entryability +│ │ └──EntryAbility.ets // 程序入口类 +│ ├──constants +│ │ └──Constants.ets // 常量文件 +│ ├──model +│ │ └──ViewModel.ets // 视频播放参数类 +│ ├──pages +│ │ ├──Index.ets // 首页入口页面 +│ │ └──VideoPage.ets // 视频播放页 +│ ├──utils +│ │ ├──CommonUtil.ets // 公共工具类 +│ │ └──Logger.ets // 日志类 +│ └──views +│ ├──AvPlayerComponent.ets // AVPlayer视频播放组件 +│ ├──CaptionFontComponent.ets // 字幕字体设置组件 +│ └──VideoPlayerComponent.ets // Video视频播放组件 +└──entry/src/main/resources // 应用静态资源目录 +``` -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request +### 具体实现 +1. 使用avPlayer和video组件相关能力。 -#### 特技 +### 相关权限 + +无 + +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:华为手机、平板。 + +2.HarmonyOS系统:HarmonyOS 5.1.1 Release及以上。 + +3.DevEco Studio版本:DevEco Studio 5.1.1 Release及以上。 + +4.HarmonyOS SDK版本:HarmonyOS 5.1.1 Release SDK及以上。 -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/) diff --git a/build-profile.json5 b/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9e87e7e6f19020fe21192844709f192cec80fd44 --- /dev/null +++ b/build-profile.json5 @@ -0,0 +1,42 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "5.0.5(17)", + "compatibleSdkVersion": "5.0.5(17)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "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/.gitignore b/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ 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/obfuscation-rules.txt b/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ 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/constants/Constants.ets b/entry/src/main/ets/constants/Constants.ets new file mode 100644 index 0000000000000000000000000000000000000000..b4d1756d01f1df48a8fdcccb050ddbc3259be73c --- /dev/null +++ b/entry/src/main/ets/constants/Constants.ets @@ -0,0 +1,23 @@ +/* + * 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 Constant { + static readonly CAPTION_FONT_FAMILY: ResourceStr[] = ['Sans', 'Condensed']; + static readonly CAPTION_FONT_COLOR: ResourceColor[] = [Color.White, '#63B959', '#F6C800']; + static readonly CAPTION_FONT_SIZE: number[] = [14, 16, 18]; + + static readonly SECOND_TIME = 3600; + static readonly MINUTE_TIME = 60; +} \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..165dd46226b405d92cf21ab1f700ee4b3004e4fe --- /dev/null +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,56 @@ +/* + * 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'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + async onWindowStageCreate(windowStage: window.WindowStage): Promise { + // 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; + } + 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..a5acecb47eedb6eaac62f0053f03a3795971755d --- /dev/null +++ b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,30 @@ +/* + * 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/ViewModel.ets b/entry/src/main/ets/model/ViewModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..98fff50b924d07215efb0e1901de1fd2ff75a290 --- /dev/null +++ b/entry/src/main/ets/model/ViewModel.ets @@ -0,0 +1,56 @@ +/* + * 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 { Logger } from '../utils/Logger'; + +const TAG = "VIEW_MODEL"; + +export interface VideoPreparedEvent { + duration: number; +} + +export interface VideoUpdateEvent { + time: number; +} + +export interface Caption { + text: ResourceStr; + startTime: number; + endTime: number; +} + +export interface CaptionFont { + family: ResourceStr; + size: number; + color: ResourceColor; +} + +export interface CaptionFontColor { + color: ResourceColor; + backgroundColor: ResourceColor; + colorName: ResourceStr; +} + +export function registerMyFont(uiContext: UIContext) { + try { + uiContext.getFont().registerFont({ + familyName: $r('app.string.HarmonyOS_Condensed'), + familySrc: $rawfile('HarmonyOS_Condensed.ttf') + }); + } catch (err) { + let error = err as BusinessError; + Logger.error(TAG, `registerFont faile. code: ${error.code}, message:${err.message}`); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..65468901fbb86fd67209b0ab68d1c19bfc8e9539 --- /dev/null +++ b/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,101 @@ +/* + * 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 { window } from '@kit.ArkUI'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { VideoPage } from './VideoPage'; +import { Logger } from '../utils/Logger'; + +const LOG_TAG = 'INDEX'; +const orientation = window.Orientation.LANDSCAPE; + +@Entry +@Component +struct Index { + @Provide('NavPathStack') pageStack: NavPathStack = new NavPathStack(); + private currentWindow: window.Window | null = null; + + aboutToAppear(): void { + try { + window.getLastWindow(this.getUIContext().getHostContext()) + .then(async (topWindow) => { + this.currentWindow = topWindow; + topWindow.setPreferredOrientation(orientation, (err: BusinessError) => { + const errCode: number = err.code; + if (errCode) { + Logger.error(LOG_TAG, + `Failed to set window orientation. Cause code: ${err.code}, message: ${err.message}`); + return; + } + topWindow.setWindowSystemBarEnable(['status', 'navigation']); + }); + }).catch((err: BusinessError) => { + Logger.error(LOG_TAG, `Failed to obtain the top window. Cause code: ${err.code}, message: ${err.message}`); + }); + } catch (exception) { + Logger.error(LOG_TAG, 'Failed to enter immersive. Cause:', JSON.stringify(exception)); + } + } + + @Builder + buttonBuilder(text: ResourceStr, isVideo: boolean) { + Button(text) + .fontWeight(500) + .fontSize(16) + .width('50%') + .fontColor('rgb(10,89,247)') + .backgroundColor('rgba(0,0,0,0.05)') + .onClick(async () => { + await this.currentWindow?.setWindowSystemBarEnable([]); + this.pageStack.pushPathByName('videoPage', isVideo); + }) + } + + @Builder + PagesMap(name: string, isVideo: boolean) { + if (name === 'videoPage') { + VideoPage({ isVideo, currentWindow: this.currentWindow }); + } + } + + build() { + Navigation(this.pageStack) { + Column() { + Text($r('app.string.demo_title')) + .fontSize(30) + .fontWeight(700) + } + .padding({ left: 36, top: 8 }) + .width('100%') + .alignItems(HorizontalAlign.Start) + + Column({ space: 12 }) { + this.buttonBuilder($r('app.string.av_caption'), false) + this.buttonBuilder($r('app.string.video_caption'), true) + } + .width('100%') + .position({ bottom: 16 }) + } + .mode(NavigationMode.Stack) + .navDestination(this.PagesMap) + .hideToolBar(true) + .hideTitleBar(true) + .titleMode(NavigationTitleMode.Full) + .onNavBarStateChange((isVisible) => { + if (isVisible && this.currentWindow) { + this.currentWindow.setWindowSystemBarEnable(['status', 'navigation']); + } + }) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/VideoPage.ets b/entry/src/main/ets/pages/VideoPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..5189e68a561b6d6c9434ca55efe1dbcab7190d66 --- /dev/null +++ b/entry/src/main/ets/pages/VideoPage.ets @@ -0,0 +1,240 @@ +/* + * 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 { util } from '@kit.ArkTS'; +import { display, window } from '@kit.ArkUI'; +import { Caption, CaptionFont, registerMyFont } from '../model/ViewModel'; +import { VideoPlayer } from '../view/VideoPlayerComponent'; +import { AvPlayer } from '../view/AvPlayerComponent'; +import { CaptionFontComponent } from '../view/CaptionFontComponent'; + +@Component +export struct VideoPage { + @Consume('NavPathStack') pageStack: NavPathStack; + @Prop isVideo: boolean = true; + @Prop currentWindow: window.Window | null = null; + // play state + @State isPlaying: boolean = false; + @State currentTime: number = 0; + @State duration: number = 0; + @State sliderTime: number = 0; + @State showControls: boolean = false; + @State videoWidth: number = 0; + @State videoHeight: number = 0; + @State currentCaption: Caption | null = null; + @State windowWidth: number = 300; + @State windowHeight: number = 200; + @State captionFont: CaptionFont = { + family: 'Sans', + size: 14, + color: Color.White + }; + @State isShowCaptionConfig: boolean = false; + + private formatTime(seconds: number): string { + let hours = Math.floor(seconds / 3600); + let minus = Math.floor(seconds / 60); + let secs = Math.floor(seconds % 60); + return util.format('%s:%s:%s', hours.toString().padStart(2, '0'), minus.toString().padStart(2, '0'), + secs.toString().padStart(2, '0')); + } + + aboutToAppear(): void { + this.windowHeight = display.getDefaultDisplaySync().height; + registerMyFont(this.getUIContext()); + } + + closeCaptionSetting(captionFont: CaptionFont | null) { + this.isPlaying = true; + this.isShowCaptionConfig = false; + if (captionFont) { + this.captionFont = captionFont; + } + } + + build() { + NavDestination() { + Column() { + Stack() { + Column() { + if (this.isVideo) { + VideoPlayer({ + isPlaying: this.isPlaying, + currentTime: this.currentTime, + duration: this.duration, + currentCaption: this.currentCaption, + sliderTime: this.sliderTime + }) + } else { + AvPlayer({ + isPlaying: this.isPlaying, + currentTime: this.currentTime, + duration: this.duration, + currentCaption: this.currentCaption, + sliderTime: this.sliderTime + }) + } + } + .onClick(() => { + this.showControls = !this.showControls; + }) + .width('100%') + .height('100%') + + if (this.showControls) { + Column() { + Row({ space: 8 }) { + Button() { + Image($r('app.media.chevron_left')) + .width(16) + .height(16) + .align(Alignment.Center) + } + .backgroundColor('rgba(255, 255, 255, 0.1)') + .width(40) + .height(40) + .onClick(() => { + this.pageStack.pop(); + }) + + + Column() { + Text('Test.mp4') + .fontSize(20) + .fontWeight(700) + .fontColor(Color.White) + } + } + .width('100%') + } + .position({ x: 24 }) + .padding({ top: 16, bottom: 16 }) + .linearGradient({ + angle: 180, + colors: [['rgba(0,0,0,0.3)', 0.0179], ['rgba(0,0,0,0)', 1]] + }) + } + + Column() { + Text(this.currentCaption?.text || '') + .fontColor(this.captionFont.color) + .fontSize(this.captionFont.size) + .fontFamily(this.captionFont.family) + } + .width('100%') + .position({ bottom: 40 }) + + if (this.showControls) { + Column({ space: 8 }) { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) { + Column() { + Text(this.formatTime(this.currentTime)) + .fontColor(Color.White) + .fontSize(14) + } + .margin({ right: 16 }) + .flexShrink(0) + + Column() { + Slider({ + value: this.currentTime, + min: 0, + max: this.duration, + step: 1, + style: SliderStyle.OutSet + }) + .trackThickness(6) + .blockSize({ + width: 16, + height: 16 + }) + .trackColor('rgba(255, 255, 255, 0.4)') + .onChange((value: number) => { + this.sliderTime = value; + }) + } + + Column() { + Text(this.formatTime(this.duration)) + .fontColor(Color.White) + .fontSize(14) + } + .margin({ left: 16 }) + .flexShrink(0) + + } + .margin({ left: 24, right: 24 }) + + Row() { + Row({ space: 32 }) { + Button() { + Image(this.isPlaying ? $r('app.media.pause') : $r('app.media.play')) + .width(24) + .height(24) + } + .onClick(() => this.isPlaying = !this.isPlaying) + .backgroundColor(Color.Transparent) + + Button() { + Image($r('app.media.character_viewfinder')) + .width(24) + .height(24) + } + .onClick(() => { + this.isPlaying = false; + this.isShowCaptionConfig = true; + }) + .backgroundColor(Color.Transparent) + } + } + .width('100%') + .padding({ left: 24, right: 24 }) + } + .width('100%') + .position({ bottom: 0 }) + .padding({ bottom: 16 }) + .linearGradient({ + angle: 180, + colors: [['rgba(0,0,0,0)', 0.0179], ['rgba(0,0,0,0.3)', 1]] + }) + } + + if (this.isShowCaptionConfig) { + CaptionFontComponent({ + captionFont: this.captionFont, + close: (captionFont: CaptionFont | null) => { + this.closeCaptionSetting(captionFont); + } + }) + } + + } + .height('100%') + .width('100%') + } + .width('100%') + .height(`${this.windowHeight}px`) + } + .hideTitleBar(true) + .mode(NavDestinationMode.STANDARD) + .onShown(async () => { + this.isPlaying = true; + await this.currentWindow?.setWindowSystemBarEnable([]); + }) + .onHidden(() => { + this.isPlaying = false; + }) + + } +} \ No newline at end of file diff --git a/entry/src/main/ets/utils/CommonUtil.ets b/entry/src/main/ets/utils/CommonUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..39d9b6dccbdb7cdf03a6381fbe7dd4809721a822 --- /dev/null +++ b/entry/src/main/ets/utils/CommonUtil.ets @@ -0,0 +1,53 @@ +/* + * 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 { util } from '@kit.ArkTS'; +import { Caption } from '../model/ViewModel'; +import { Constant } from '../constants/Constants'; + +export function uint8ArrayToStr(uint8Array: Uint8Array): string { + const textDecoder = util.TextDecoder.create("utf-8"); + return textDecoder.decodeToString(uint8Array, { stream: false }); +} + +function getSecondTime(timeMatch: number[], i: number) { + return timeMatch[i+1] * Constant.SECOND_TIME + timeMatch[i+2] * Constant.MINUTE_TIME + timeMatch[i+3]; +} + +export function srtToJson(srt: string): Caption[] { + const lines = srt.split('\n'); + const result: Caption[] = []; + + for (let i = 0; i < lines.length; i += 4) { + if (!lines[i].trim()) { + continue; + } + + const reg = new RegExp(/(\d{2}):(\d{2}):(\d{2}),(\d{3}) --> (\d{2}):(\d{2}):(\d{2}),(\d{3})/); + const timeMatch = lines[i+1].match(reg)?.map(time => parseInt(time)); + + if (!timeMatch) { + continue; + } + const startTime = getSecondTime(timeMatch, 0); + const endTime = getSecondTime(timeMatch, 4); + + result.push({ + startTime, + endTime, + text: lines[i+2] + }); + } + return result; +} \ 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..45a26d53bf2b199a0ef7c10f57ffda3cca9cc51f --- /dev/null +++ b/entry/src/main/ets/utils/Logger.ets @@ -0,0 +1,42 @@ +/* + * 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 readonly DOMAIN: number = 0xFF00; + private static readonly TAG: string = 'com.example.video_subtitle'; + private static readonly PREFIX: string = '[video-caption-log]'; + + public static debug(logTag: string, messageFormat: string, ...args: Object[]): void { + hilog.debug(Logger.DOMAIN, Logger.TAG, `${Logger.PREFIX} ${logTag}: ${messageFormat}`, args); + } + + public static info(logTag: string, messageFormat: string, ...args: Object[]): void { + hilog.info(Logger.DOMAIN, Logger.TAG, `${Logger.PREFIX} ${logTag}: ${messageFormat}`, args); + } + + public static warn(logTag: string, messageFormat: string, ...args: Object[]): void { + hilog.warn(Logger.DOMAIN, Logger.TAG, `${Logger.PREFIX} ${logTag}: ${messageFormat}`, args); + } + + public static error(logTag: string, messageFormat: string, ...args: Object[]): void { + hilog.error(Logger.DOMAIN, Logger.TAG, `${Logger.PREFIX} ${logTag}: ${messageFormat}`, args); + } + + public static fatal(logTag: string, messageFormat: string, ...args: Object[]): void { + hilog.fatal(Logger.DOMAIN, Logger.TAG, `${Logger.PREFIX} ${logTag}: ${messageFormat}`, args); + } +} diff --git a/entry/src/main/ets/view/AvPlayerComponent.ets b/entry/src/main/ets/view/AvPlayerComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..65554b90ff6a28987041c257b180a0753a9cf467 --- /dev/null +++ b/entry/src/main/ets/view/AvPlayerComponent.ets @@ -0,0 +1,223 @@ +/* + * 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 { common } from '@kit.AbilityKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { Caption } from '../model/ViewModel'; +import { Logger } from '../utils/Logger'; +import { display } from '@kit.ArkUI'; +import { media } from '@kit.MediaKit'; + +const LOG_TAG = 'AV_PLAYER'; + +const PROPORTION = 1; +const SURFACE_W = 1; +const SURFACE_H = 1.78; + +@Component +export struct AvPlayer { + private xComponentController: XComponentController = new XComponentController(); + private avPlayer: media.AVPlayer | null = null; + private surfaceId: string = ''; + private context: common.UIAbilityContext | undefined = undefined; + @State fileName: string = 'sample.mp4'; + @State surfaceW: number | null = null; + @State surfaceH: number | null = null; + @State windowWidth: number = 300; + @State windowHeight: number = 200; + @State subtitle: string = ''; + @Link @Watch('togglePlay') isPlaying: boolean; + @Link @Watch('sliderChange') sliderTime: number; + @Link currentTime: number; + @Link duration: number; + @Link currentCaption: Caption | null; + + togglePlay() { + if (this.isPlaying) { + this.avPlay(); + } else { + this.avPause(); + } + } + + sliderChange() { + if (this.avPlayer) { + try { + this.avPlayer.seek(this.sliderTime, 1); + } catch (e) { + Logger.error(LOG_TAG, `videoSeek== ${JSON.stringify(e as BusinessError)}`); + } + } + } + + async msleepAsync(ms: number): Promise { + return new Promise((resolve) => { + setTimeout(() => { + resolve(true); + }, ms) + }) + } + + async avSetupVideoAndSubtitle() { + if (this.context == undefined) { + return; + } + let fileDescriptorVideo = await this.context.resourceManager.getRawFd(this.fileName); + let avFileDescriptor: media.AVFileDescriptor = + { fd: fileDescriptorVideo.fd, offset: fileDescriptorVideo.offset, length: fileDescriptorVideo.length }; + + if (this.avPlayer) { + this.avPlayer.release(); + // await this.msleepAsync(1500); + } + this.avPlayer = await media.createAVPlayer(); + + await this.setAVPlayerCallback(); + + this.avPlayer.fdSrc = avFileDescriptor; + + let fileDescriptorSub = await this.context.resourceManager.getRawFd('captions.srt'); + this.avPlayer.addSubtitleFromFd(fileDescriptorSub.fd, fileDescriptorSub.offset, fileDescriptorSub.length); + } + + async avTurnOffSubtitle() { + this.avPlayer?.off('subtitleUpdate'); + } + + avPlay(): void { + if (this.avPlayer) { + try { + this.avPlayer.play(); + } catch (e) { + Logger.error(LOG_TAG, `avPlay = ${JSON.stringify(e as BusinessError)}`); + } + } + } + + avPause(): void { + if (this.avPlayer) { + try { + this.avPlayer.pause(); + } catch (e) { + Logger.error(LOG_TAG, `avPause== ${JSON.stringify(e)}`); + } + } + } + + async setAVPlayerCallback(): Promise { + if (this.avPlayer == null) { + Logger.error(LOG_TAG, `avPlayer has not init!`); + return; + } + this.avPlayer.on('error', (err) => { + Logger.error(LOG_TAG, `setAVPlayerCallback Invoke avPlayer failed ${JSON.stringify(err)}`); + if (this.avPlayer == null) { + Logger.error(LOG_TAG, `avPlayer has not init on error`); + return; + } + this.avPlayer.reset(); + }); + this.avPlayer.on('stateChange', async (state) => { + if (this.avPlayer == null) { + Logger.error(LOG_TAG, `avPlayer has not init on state change`); + return; + } + switch (state) { + case 'initialized': + if (this.surfaceId) { + this.avPlayer.surfaceId = this.surfaceId; + this.avPlayer.prepare(); + } + break; + case 'prepared': + this.duration = Math.floor(this.avPlayer.duration / 1000); + this.currentTime = Math.floor(this.avPlayer.currentTime / 1000); + if (this.isPlaying) { + this.avPlay(); + } + this.isPlaying = true; + this.setVideoWH(); + break; + case 'completed': + this.isPlaying = false; + break; + case 'released': + this.isPlaying = false; + break; + default: + break; + } + }); + this.avPlayer.on('timeUpdate', (time: number) => { + this.currentTime = Math.floor(time / 1000); + }); + this.avPlayer.on('subtitleUpdate', (info: media.SubtitleInfo) => { + if (!!info) { + let text = (!info.text) ? '' : info.text; + let startTime = (!info.startTime) ? 0 : info.startTime; + let endTime = (!info.duration) ? 0 : info.duration; + this.currentCaption = { text, startTime, endTime }; + } else { + this.currentCaption = { text: '', startTime: 0, endTime: 0 } + } + }); + } + + aboutToAppear() { + this.windowWidth = display.getDefaultDisplaySync().width; + this.windowHeight = display.getDefaultDisplaySync().height; + this.surfaceW = this.windowWidth * SURFACE_W; + this.surfaceH = this.surfaceW / SURFACE_H; + this.context = this.getUIContext().getHostContext() as common.UIAbilityContext; + } + + aboutToDisappear() { + if (this.avPlayer == null) { + Logger.error(LOG_TAG, `avPlayer has not init aboutToDisappear`); + return; + } + this.avTurnOffSubtitle(); + this.avPlayer.release((err: BusinessError) => { + if (err == null) { + this.currentTime = 0; + this.duration = 0; + } else { + Logger.error(LOG_TAG, + ` videoRelease release failed, error message is = ${JSON.stringify(err.message)}`); + } + }); + } + + setVideoWH(): void { + this.surfaceH = Math.round(this.windowHeight * PROPORTION); + this.surfaceW = Math.round(this.windowWidth); + } + + build() { + Column() { + XComponent({ + id: 'xComponent', + type: XComponentType.SURFACE, + controller: this.xComponentController + }) + .id('VideoView') + .onLoad(() => { + this.surfaceId = this.xComponentController.getXComponentSurfaceId(); + this.avSetupVideoAndSubtitle(); + }) + .height(`${this.surfaceH}px`) + .width(`${this.surfaceW}px`) + } + } +} diff --git a/entry/src/main/ets/view/CaptionFontComponent.ets b/entry/src/main/ets/view/CaptionFontComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..80eae6a4325fe8595cb8d12189d800cc16260d10 --- /dev/null +++ b/entry/src/main/ets/view/CaptionFontComponent.ets @@ -0,0 +1,199 @@ +/* + * 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 { CaptionFont } from '../model/ViewModel'; +import { Constant } from '../constants/Constants'; + +@Component +export struct CaptionFontComponent { + @Prop captionFont: CaptionFont; + close: (captionFont: CaptionFont | null) => void = () => { + }; + + @Builder + FontFamily(text: ResourceStr) { + Button(text) + .fontSize(16) + .fontColor(this.captionFont.family === text ? Color.Black : Color.White) + .backgroundColor(this.captionFont.family === text ? 'rgba(255,255,255,0.9)' : 'rgba(255,255,255,0.1)') + .onClick(() => { + this.captionFont.family = text; + }) + } + + @Builder + FontColor(captionFontColor: ResourceColor) { + Column() { + if (this.captionFont.color === captionFontColor) { + Column() { + } + .width(12) + .height(12) + .borderRadius('50%') + .border({ width: 1, color: 'rgb(241,243,245)' }) + } + } + .width(24) + .height(24) + .borderRadius('50%') + .backgroundColor(captionFontColor) + .justifyContent(FlexAlign.Center) + .onClick(() => { + this.captionFont.color = captionFontColor; + }) + } + + build() { + Column() { + Column() { + Row() { + Column() { + Text($r('app.string.caption_title')) + .fontSize(18) + .fontWeight(700) + .fontColor(Color.White) + } + + Blank() + Row({ space: 32 }) { + Image($r("app.media.x_mark")) + .width(20) + .onClick(() => { + this.close(null); + }) + Image($r('app.media.checkmark')) + .width(20) + .onClick(() => { + this.close(this.captionFont); + }) + } + } + .width('100%') + .margin({ bottom: 16 }) + + Column() { + Row({ space: 20 }) { + Column() { + Text($r('app.string.caption_family')) + .fontColor(Color.White) + .fontSize(16) + .fontWeight(500) + } + + Row({ space: 12 }) { + ForEach(Constant.CAPTION_FONT_FAMILY, (captionFontFamily: ResourceStr) => { + this.FontFamily(captionFontFamily) + }, (captionFontFamily: ResourceStr, index: number) => `${captionFontFamily}_${index}`) + } + } + .width('100%') + .padding({ top: 14, bottom: 14 }) + .justifyContent(FlexAlign.SpaceBetween) + + Divider() + .color('rgba(255,255,255,0.2)') + + + Column() { + Row() { + Column() { + Text($r('app.string.caption_size')) + .fontColor(Color.White) + .fontSize(16) + .fontWeight(500) + } + + Column() { + Text(`${this.captionFont.size}`) + .fontColor('rgba(255, 255, 255, 0.6)') + .fontSize(14) + } + } + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + + Row() { + Slider({ + value: this.captionFont.size, + min: 12, + max: 24, + step: 1, + style: SliderStyle.InSet + }) + .trackThickness(20) + .blockSize({ + width: 12, + height: 12 + }) + .trackColor('rgba(255, 255, 255, 0.4)') + .onChange((value: number) => { + this.captionFont.size = value; + }) + } + .justifyContent(FlexAlign.Start) + .width('calc(100% + 10vp)') + } + .width('100%') + .justifyContent(FlexAlign.Start) + .margin({ top: 14, bottom: 4 }) + + Divider() + .color('rgba(255,255,255,0.2)') + + Row() { + Column() { + Text($r('app.string.caption_color')) + .fontColor(Color.White) + .fontSize(16) + .fontWeight(500) + } + + Row({ space: 16 }) { + ForEach(Constant.CAPTION_FONT_COLOR, (captionFontColor: ResourceColor) => { + this.FontColor(captionFontColor) + }, (captionFontColor: ResourceColor, index: number) => `${captionFontColor}_${index}`) + } + .padding({ + left: 10, + right: 10, + top: 8, + bottom: 8 + }) + .borderRadius(20) + .backgroundColor('rgba(255,255,255,0.9)') + } + .width('100%') + .justifyContent(FlexAlign.SpaceBetween) + .margin({ top: 14 }) + } + + } + .width('40%') + .height('100%') + .linearGradient({ + angle: 269.43, + colors: [['rgba(0,0,0,0.6)', 0.0148], ['rgba(0,0,0,0)', 0.99597]] + }) + .position({ right: 0 }) + .padding({ top: 40, left: 16, right: 16 }) + .onClick(() => { + }) + } + .width('100%') + .height('100%') + .onClick(() => { + this.close(null); + }) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/VideoPlayerComponent.ets b/entry/src/main/ets/view/VideoPlayerComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..cbf00e70a79227a71491d2cf6a8e497f0e6cf1c2 --- /dev/null +++ b/entry/src/main/ets/view/VideoPlayerComponent.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. + */ +import { BusinessError } from '@kit.BasicServicesKit'; +import { Caption, VideoPreparedEvent, VideoUpdateEvent } from '../model/ViewModel'; +import { srtToJson, uint8ArrayToStr } from '../utils/CommonUtil'; +import { Logger } from '../utils/Logger'; + +const LOG_TAG = 'VIDEO_PLAYER'; + +@Component +export struct VideoPlayer { + private videoSrc: Resource = $rawfile('sample.mp4'); + private controller: VideoController = new VideoController(); + @Link @Watch('togglePlay') isPlaying: boolean; + @Link @Watch('sliderChange') sliderTime: number; + @Link currentTime: number; + @Link duration: number; + @Link currentCaption: Caption | null; + @State captionList: Caption[] = []; + + aboutToAppear(): void { + const resourceManager = this.getUIContext().getHostContext()?.resourceManager; + resourceManager?.getRawFileContent('captions.srt').then((value: Uint8Array) => { + let rawFile = uint8ArrayToStr(value); + this.captionList = srtToJson(rawFile); + }).catch((error: BusinessError) => { + Logger.error(LOG_TAG, "getRawFileContent promise error is " + error.message); + }); + } + + togglePlay() { + if (this.isPlaying) { + this.controller.start(); + } else { + this.controller.pause(); + } + } + + sliderChange() { + this.controller.setCurrentTime(this.sliderTime); + } + + build() { + Column() { + Video({ + src: this.videoSrc, + controller: this.controller + }) + .size({ width: '100%', height: '100%' }) + .autoPlay(false) + .controls(false) + .onPrepared((event: VideoPreparedEvent) => { + this.controller.start() + this.duration = event.duration; + }) + .onUpdate((event: VideoUpdateEvent) => { + this.currentTime = event.time; + if (event.time > 0 && !this.isPlaying) { + this.isPlaying = true; + } + const caption: Caption[] = this.captionList.filter(caption => caption.startTime === this.currentTime); + if (caption?.length) { + this.currentCaption = caption[0]; + } else if (this.currentCaption?.endTime && this.currentCaption.endTime < this.currentTime) { + this.currentCaption = null; + } + }) + .onFinish(() => { + this.isPlaying = false; + }) + } + } +} \ 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..146b8cf5b5da08852e39f3f34348d15365c5e15e --- /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", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "icon": "$media:layered_image", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.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..419aa49d53413d68acdd73edc8d2b80d01ef60e9 --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,24 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "slider_selected", + "value": "#007DFF" + }, + { + "name": "speed_dialog", + "value": "#33bab4b4" + }, + { + "name": "video_play", + "value": "#333333" + }, + { + "name": "video_play_selected", + "value": "#5c5c5c" + } + ] +} \ 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..e81d7a695216af70cfe9adc9bede39e537385148 --- /dev/null +++ b/entry/src/main/resources/base/element/float.json @@ -0,0 +1,168 @@ +{ + "float": [ + { + "name": "splash_page_logo_img_height", + "value": "150vp" + }, + { + "name": "brightness_distance", + "value": "-680" + }, + { + "name": "volume_distance", + "value": "680" + }, + { + "name": "row_margin_left", + "value": "10" + }, + { + "name": "row_margin_top", + "value": "38" + }, + { + "name": "trackthickness", + "value": "13" + }, + { + "name": "borderradius", + "value": "10" + }, + { + "name": "slider_height", + "value": "120" + }, + { + "name": "verticalslideritem_margin_top", + "value": "-20" + }, + { + "name": "blank_height", + "value": "6" + }, + { + "name": "text_fontsize", + "value": "14" + }, + { + "name": "slider_min", + "value": "0.0" + }, + { + "name": "brightness_slider_max", + "value": "1" + }, + { + "name": "volume_slider_max", + "value": "15" + }, + { + "name": "brightness_slider_step", + "value": "0.01" + }, + { + "name": "volume_slider_step", + "value": "1" + }, + { + "name": "video_zindex", + "value": "1" + }, + { + "name": "avvolumepanel_zindex", + "value": "3" + }, + { + "name": "verticalslideritem_zindex", + "value": "3" + }, + { + "name": "page_text_font_size", + "value": "50fp" + }, + { + "name": "size_zero_five", + "value": "0.5" + }, + { + "name": "size_zero_six", + "value": "0.6" + }, + { + "name": "size_zero", + "value": "0" + }, + { + "name": "size_1", + "value": "1" + }, + { + "name": "size_5", + "value": "5" + }, + { + "name": "size_10", + "value": "10" + }, + { + "name": "size_12", + "value": "12" + }, + { + "name": "size_15", + "value": "15" + }, + { + "name": "size_16", + "value": "16" + }, + { + "name": "size_18", + "value": "18" + }, + { + "name": "size_20", + "value": "20" + }, + { + "name": "size_down_20", + "value": "-20" + }, + { + "name": "size_24", + "value": "24" + }, + { + "name": "size_25", + "value": "25" + }, + { + "name": "size_30", + "value": "30" + }, + { + "name": "size_32", + "value": "32" + }, + { + "name": "size_35", + "value": "35" + }, + { + "name": "size_40", + "value": "40" + }, + { + "name": "size_45", + "value": "45" + }, + { + "name": "size_48", + "value": "48" + }, + { + "name": "size_50", + "value": "50" + } + ] +} \ No newline at end of file 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..ee2a2d7276ecedcd8a86a4af60ed667ab8ca5b21 --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,88 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "brightness_imagesize", + "value": "2%" + }, + { + "name": "volume_imagesize", + "value": "9%" + }, + { + "name": "avvolumepanel_width", + "value": "30%" + }, + { + "name": "row_height", + "value": "100%" + }, + { + "name": "column_size", + "value": "100%" + }, + { + "name": "trackcolor", + "value": "#94fffefe" + }, + { + "name": "video_width", + "value": "100%" + }, + { + "name": "video_height", + "value": "100%" + }, + { + "name": "plus", + "value": "+" + }, + { + "name": "minus", + "value": "-" + }, + { + "name": "selectedcolor", + "value": "#beffffff" + }, + { + "name": "HarmonyOS_Sans", + "value": "Sans" + }, + { + "name": "HarmonyOS_Condensed", + "value": "Condensed" + }, + { + "name": "demo_title", + "value": "视频字幕编辑" + }, + { + "name": "av_caption", + "value": "avplayer外挂字幕" + }, + { + "name": "video_caption", + "value": "video组件外挂字幕" + }, + { + "name": "caption_title", + "value": "字幕设置" + }, + { + "name": "caption_family", + "value": "字体" + }, + { + "name": "caption_size", + "value": "字号" + }, + { + "name": "caption_color", + "value": "颜色" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/back.png b/entry/src/main/resources/base/media/back.png new file mode 100644 index 0000000000000000000000000000000000000000..1408ed47765d9634da9998ad1025b744e5d189a8 Binary files /dev/null and b/entry/src/main/resources/base/media/back.png differ 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/character_viewfinder.svg b/entry/src/main/resources/base/media/character_viewfinder.svg new file mode 100644 index 0000000000000000000000000000000000000000..78705e7e3b6c46c8117320da28de6bee869fec5a --- /dev/null +++ b/entry/src/main/resources/base/media/character_viewfinder.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/checkmark.svg b/entry/src/main/resources/base/media/checkmark.svg new file mode 100644 index 0000000000000000000000000000000000000000..ee6a804e8bad261ea296268fca29dc454e0a375f --- /dev/null +++ b/entry/src/main/resources/base/media/checkmark.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/chevron_down.svg b/entry/src/main/resources/base/media/chevron_down.svg new file mode 100644 index 0000000000000000000000000000000000000000..217908290a732b241747b67f42547dd023775c91 --- /dev/null +++ b/entry/src/main/resources/base/media/chevron_down.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/chevron_left.svg b/entry/src/main/resources/base/media/chevron_left.svg new file mode 100644 index 0000000000000000000000000000000000000000..77922e7aa4e50117c777aaf92f9db759b399d9f2 --- /dev/null +++ b/entry/src/main/resources/base/media/chevron_left.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file 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/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/next.png b/entry/src/main/resources/base/media/next.png new file mode 100644 index 0000000000000000000000000000000000000000..a7252ef722f02b80f3ff251fc56f2ef112262754 Binary files /dev/null and b/entry/src/main/resources/base/media/next.png differ diff --git a/entry/src/main/resources/base/media/pause.svg b/entry/src/main/resources/base/media/pause.svg new file mode 100644 index 0000000000000000000000000000000000000000..c84c8db6e986a7f862e63a96da6274581852912c --- /dev/null +++ b/entry/src/main/resources/base/media/pause.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/play.svg b/entry/src/main/resources/base/media/play.svg new file mode 100644 index 0000000000000000000000000000000000000000..78098f400d6bb2d3ebdabc651c57b0d89ee72ead --- /dev/null +++ b/entry/src/main/resources/base/media/play.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/send.png b/entry/src/main/resources/base/media/send.png new file mode 100644 index 0000000000000000000000000000000000000000..c8ce3756e8b06394a9d5d8662901e82542ecd88c Binary files /dev/null and b/entry/src/main/resources/base/media/send.png differ 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/media/x_mark.svg b/entry/src/main/resources/base/media/x_mark.svg new file mode 100644 index 0000000000000000000000000000000000000000..343bb7d656fb3ab33deec00c64febe6907e4716d --- /dev/null +++ b/entry/src/main/resources/base/media/x_mark.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file 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..c3bdcd16885411a770912dd4ff8942ce19747d29 --- /dev/null +++ b/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,88 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "brightness_imagesize", + "value": "2%" + }, + { + "name": "volume_imagesize", + "value": "9%" + }, + { + "name": "avvolumepanel_width", + "value": "30%" + }, + { + "name": "row_height", + "value": "100%" + }, + { + "name": "column_size", + "value": "100%" + }, + { + "name": "trackcolor", + "value": "#94fffefe" + }, + { + "name": "video_width", + "value": "100%" + }, + { + "name": "video_height", + "value": "100%" + }, + { + "name": "plus", + "value": "+" + }, + { + "name": "minus", + "value": "-" + }, + { + "name": "selectedcolor", + "value": "#beffffff" + }, + { + "name": "HarmonyOS_Sans", + "value": "Sans" + }, + { + "name": "HarmonyOS_Condensed", + "value": "Condensed" + }, + { + "name": "demo_title", + "value": "Video subtitle editing" + }, + { + "name": "av_caption", + "value": "AVPlayer cheat subtitles" + }, + { + "name": "video_caption", + "value": "Video component with external subtitles" + }, + { + "name": "caption_title", + "value": "Subtitle settings" + }, + { + "name": "caption_family", + "value": "font family" + }, + { + "name": "caption_size", + "value": "font size" + }, + { + "name": "caption_color", + "value": "font color" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/HarmonyOS_Condensed.ttf b/entry/src/main/resources/rawfile/HarmonyOS_Condensed.ttf new file mode 100644 index 0000000000000000000000000000000000000000..9d508cc915ce490d6cb8d9040eb025c01dd4346c Binary files /dev/null and b/entry/src/main/resources/rawfile/HarmonyOS_Condensed.ttf differ diff --git a/entry/src/main/resources/rawfile/captions.json b/entry/src/main/resources/rawfile/captions.json new file mode 100644 index 0000000000000000000000000000000000000000..0e58b4b3c8e63ce560aa496a448c37e076845028 --- /dev/null +++ b/entry/src/main/resources/rawfile/captions.json @@ -0,0 +1,27 @@ +[ + { + "text": "360°立体天气动态展示", + "startTime": 1, + "endTime": 3 + }, + { + "text": "实时同步窗外真实气象", + "startTime": 3, + "endTime": 6 + }, + { + "text": "雷暴预警闪电特效提示", + "startTime": 7, + "endTime": 10 + }, + { + "text": "晨曦极光自动色调变换", + "startTime": 10, + "endTime": 12 + }, + { + "text": "指尖轻触触发季节音效", + "startTime": 12, + "endTime": 14 + } +] \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/captions.srt b/entry/src/main/resources/rawfile/captions.srt new file mode 100644 index 0000000000000000000000000000000000000000..b2d0c7aa9e1ba6a702c35ae119bd8059e97316f5 --- /dev/null +++ b/entry/src/main/resources/rawfile/captions.srt @@ -0,0 +1,19 @@ +1 +00:00:01,000 --> 00:00:03,000 +360°立体天气动态展示 + +2 +00:00:03,000 --> 00:00:06,000 +实时同步窗外真实气象 + +3 +00:00:07,000 --> 00:00:10,000 +雷暴预警闪电特效提示 + +4 +00:00:10,000 --> 00:00:12,000 +晨曦极光自动色调变换 + +5 +00:00:12,000 --> 00:00:14,000 +指尖轻触触发季节音效 \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/sample.mp4 b/entry/src/main/resources/rawfile/sample.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..77a3449e18dfd4c0fe400e92721d79e09f2b34fc Binary files /dev/null and b/entry/src/main/resources/rawfile/sample.mp4 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..ee2a2d7276ecedcd8a86a4af60ed667ab8ca5b21 --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,88 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "brightness_imagesize", + "value": "2%" + }, + { + "name": "volume_imagesize", + "value": "9%" + }, + { + "name": "avvolumepanel_width", + "value": "30%" + }, + { + "name": "row_height", + "value": "100%" + }, + { + "name": "column_size", + "value": "100%" + }, + { + "name": "trackcolor", + "value": "#94fffefe" + }, + { + "name": "video_width", + "value": "100%" + }, + { + "name": "video_height", + "value": "100%" + }, + { + "name": "plus", + "value": "+" + }, + { + "name": "minus", + "value": "-" + }, + { + "name": "selectedcolor", + "value": "#beffffff" + }, + { + "name": "HarmonyOS_Sans", + "value": "Sans" + }, + { + "name": "HarmonyOS_Condensed", + "value": "Condensed" + }, + { + "name": "demo_title", + "value": "视频字幕编辑" + }, + { + "name": "av_caption", + "value": "avplayer外挂字幕" + }, + { + "name": "video_caption", + "value": "video组件外挂字幕" + }, + { + "name": "caption_title", + "value": "字幕设置" + }, + { + "name": "caption_family", + "value": "字体" + }, + { + "name": "caption_size", + "value": "字号" + }, + { + "name": "caption_color", + "value": "颜色" + } + ] +} \ No newline at end of file diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5bebc9755447385d82ce4138f54d991b1f85f348 --- /dev/null +++ b/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.5", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | 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 */ + }, + "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-lock.json5 b/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c2f6d1bc9cb330eeb990573aa7e74cbccfb64b61 --- /dev/null +++ b/oh-package-lock.json5 @@ -0,0 +1,28 @@ +{ + "meta": { + "stableOrder": true, + "enableUnifiedLockfile": false + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.21": { + "name": "@ohos/hypium", + "version": "1.0.21", + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.21.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/oh-package.json5 b/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a8aff0c5aff22d78aa26fd19c3861f4320e951ff --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.5", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/screenshots/devices/captionVideo.webp b/screenshots/devices/captionVideo.webp new file mode 100644 index 0000000000000000000000000000000000000000..f2ff765a4876c382a0b2f90e78d87d7b564e27dd Binary files /dev/null and b/screenshots/devices/captionVideo.webp differ diff --git a/screenshots/devices/home.png b/screenshots/devices/home.png new file mode 100644 index 0000000000000000000000000000000000000000..82e02b871486c40abc4bf1be8d2d3d6925be250d Binary files /dev/null and b/screenshots/devices/home.png differ