diff --git a/libs/ohos/media_kit_libs_ohos/.gitignore b/libs/ohos/media_kit_libs_ohos/.gitignore new file mode 100644 index 000000000..69c1c2bf8 --- /dev/null +++ b/libs/ohos/media_kit_libs_ohos/.gitignore @@ -0,0 +1,47 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.build/ +.buildlog/ +.history +.svn/ +.swiftpm/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test diff --git a/libs/ohos/media_kit_libs_ohos/.metadata b/libs/ohos/media_kit_libs_ohos/.metadata new file mode 100644 index 000000000..0e977a0dc --- /dev/null +++ b/libs/ohos/media_kit_libs_ohos/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "aed8f5e4a84a99c5832fedb8ea11bf030644c8cb" + channel: "[user-branch]" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: aed8f5e4a84a99c5832fedb8ea11bf030644c8cb + base_revision: aed8f5e4a84a99c5832fedb8ea11bf030644c8cb + - platform: ohos + create_revision: aed8f5e4a84a99c5832fedb8ea11bf030644c8cb + base_revision: aed8f5e4a84a99c5832fedb8ea11bf030644c8cb + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/libs/ohos/media_kit_libs_ohos/CHANGELOG.md b/libs/ohos/media_kit_libs_ohos/CHANGELOG.md new file mode 100644 index 000000000..275d71fc1 --- /dev/null +++ b/libs/ohos/media_kit_libs_ohos/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +- Initial release diff --git a/libs/ohos/media_kit_libs_ohos/README.md b/libs/ohos/media_kit_libs_ohos/README.md new file mode 100644 index 000000000..7aa830891 --- /dev/null +++ b/libs/ohos/media_kit_libs_ohos/README.md @@ -0,0 +1,11 @@ +# [package:media_kit_libs_ohos](https://github.com/media-kit/media-kit) + +[![](https://img.shields.io/discord/1079685977523617792?color=33cd57&label=Discord&logo=discord&logoColor=discord)](https://discord.gg/h7qf2R9n57) [![Github Actions](https://github.com/media-kit/media-kit/actions/workflows/ci.yml/badge.svg)](https://github.com/media-kit/media-kit/actions/workflows/ci.yml) + +GNU/Linux dependency package for [`package:media_kit`](https://github.com/media-kit/media-kit). Necessary for initialization. + +## License + +Copyright © 2021 & onwards, Hitesh Kumar Saini <> + +This project & the work under this repository is governed by MIT license that can be found in the [LICENSE](./LICENSE) file. diff --git a/libs/ohos/media_kit_libs_ohos/analysis_options.yaml b/libs/ohos/media_kit_libs_ohos/analysis_options.yaml new file mode 100644 index 000000000..0d2902135 --- /dev/null +++ b/libs/ohos/media_kit_libs_ohos/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/libs/ohos/media_kit_libs_ohos/example/README.md b/libs/ohos/media_kit_libs_ohos/example/README.md new file mode 100644 index 000000000..8a36ae8b4 --- /dev/null +++ b/libs/ohos/media_kit_libs_ohos/example/README.md @@ -0,0 +1,10 @@ +## Installation + +Add in your `pubspec.yaml`: + +```yaml +dependencies: + media_kit_libs_ohos: ^1.0.0 +``` + +This will automatically invoke the necessary initialization code. diff --git a/libs/ohos/media_kit_libs_ohos/ohos/.gitignore b/libs/ohos/media_kit_libs_ohos/ohos/.gitignore new file mode 100644 index 000000000..ea50ce406 --- /dev/null +++ b/libs/ohos/media_kit_libs_ohos/ohos/.gitignore @@ -0,0 +1,10 @@ +/node_modules +/oh_modules +/local.properties +/.preview +/.idea +/build +/.cxx +/.test +**/BuildProfile.ets +**/oh-package-lock.json5 diff --git a/libs/ohos/media_kit_libs_ohos/ohos/build-profile.json5 b/libs/ohos/media_kit_libs_ohos/ohos/build-profile.json5 new file mode 100644 index 000000000..efb9d6e57 --- /dev/null +++ b/libs/ohos/media_kit_libs_ohos/ohos/build-profile.json5 @@ -0,0 +1,14 @@ +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "abiFilters": ["arm64-v8a"], + } + }, + "targets": [ + { + "name": "default" + } + ] +} diff --git a/libs/ohos/media_kit_libs_ohos/ohos/hvigorfile.ts b/libs/ohos/media_kit_libs_ohos/ohos/hvigorfile.ts new file mode 100644 index 000000000..421870714 --- /dev/null +++ b/libs/ohos/media_kit_libs_ohos/ohos/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/libs/ohos/media_kit_libs_ohos/ohos/index.ets b/libs/ohos/media_kit_libs_ohos/ohos/index.ets new file mode 100644 index 000000000..2dfb19ba5 --- /dev/null +++ b/libs/ohos/media_kit_libs_ohos/ohos/index.ets @@ -0,0 +1,2 @@ +import MediaKitLibsOhosPlugin from "./src/main/ets/MediaKitLibsOhosPlugin"; +export default MediaKitLibsOhosPlugin; diff --git a/libs/ohos/media_kit_libs_ohos/ohos/oh-package.json5 b/libs/ohos/media_kit_libs_ohos/ohos/oh-package.json5 new file mode 100644 index 000000000..b347a84b3 --- /dev/null +++ b/libs/ohos/media_kit_libs_ohos/ohos/oh-package.json5 @@ -0,0 +1,8 @@ +{ + "name": "media_kit_libs_ohos", + "version": "1.0.0", + "description": "Please describe the basic information.", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/libs/ohos/media_kit_libs_ohos/ohos/src/main/cpp/CMakeLists.txt b/libs/ohos/media_kit_libs_ohos/ohos/src/main/cpp/CMakeLists.txt new file mode 100644 index 000000000..840445682 --- /dev/null +++ b/libs/ohos/media_kit_libs_ohos/ohos/src/main/cpp/CMakeLists.txt @@ -0,0 +1,88 @@ +cmake_minimum_required(VERSION 3.15) + +# ------------------------------------------------------------------------------ +function(download_and_verify url sha locationForArchive) + # Check if the archive exists. + if(EXISTS "${locationForArchive}") + file(SHA256 "${locationForArchive}" ARCHIVE_SHA) + + # If SHA256 doesn't match, delete the archive to download again. + if(NOT sha STREQUAL ARCHIVE_SHA) + file(REMOVE "${locationForArchive}") + message(STATUS "MD5 mismatch. File deleted.") + endif() + endif() + + # Download the archive if it doesn't exist. + if(NOT EXISTS "${locationForArchive}") + message(STATUS "Downloading archive from ${url}...") + file(DOWNLOAD "${url}" "${locationForArchive}") + message(STATUS "Downloaded archive to ${locationForArchive}.") + + # Verify SHA256 of the newly downloaded file. + file(SHA256 "${locationForArchive}" ARCHIVE_SHA) + + if(sha STREQUAL ARCHIVE_SHA) + message(STATUS "${locationForArchive} Verification successful.") + else() + message(FATAL_ERROR "${locationForArchive} Integrity check failed, please try to re-build project again.") + endif() + endif() +endfunction() + +function(check_directory_exists_and_not_empty dir result_var) + # Check if the directory exists + if(EXISTS "${dir}") + # Check if the directory is not empty + file(GLOB dir_contents "${dir}/*") + + if(dir_contents) + set(${result_var} TRUE PARENT_SCOPE) + else() + set(${result_var} FALSE PARENT_SCOPE) + message(STATUS "Directory ${dir} exists but is empty!") + endif() + else() + set(${result_var} FALSE PARENT_SCOPE) + message(STATUS "Directory ${dir} does not exist!") + endif() +endfunction() + +# libmpv archive containing the pre-built shared libraries. +set(LIBMPV "libmpv_aarch64.zip") + +# Download URL & SHA256 hash of the libmpv archive. +set(LIBMPV_URL "https://github.com/ErBWs/libmpv-ohos-build/releases/download/20251110/${LIBMPV}") +set(LIBMPV_SHA "5e9c41ef80996c6691f4d860c24278c43933511559d71683f24488a2b5bd6d7d") + +# Download location of the libmpv archive. +set(LIBMPV_ARCHIVE "${CMAKE_CURRENT_SOURCE_DIR}/${LIBMPV}") +set(LIBMPV_SRC "${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/arm64-v8a/") + +download_and_verify( + ${LIBMPV_URL} + ${LIBMPV_SHA} + ${LIBMPV_ARCHIVE} +) + +check_directory_exists_and_not_empty(${LIBMPV_SRC} LIBMPV_SRC_VALID) + +# Extract the libmpv archive. +if(NOT LIBMPV_SRC_VALID) + message(STATUS "Extracting ${LIBMPV}...") + make_directory("${LIBMPV_SRC}") + add_custom_target("LIBMPV_EXTRACT" ALL) + add_custom_command( + TARGET "LIBMPV_EXTRACT" + COMMAND "${CMAKE_COMMAND}" -E tar -xf "${LIBMPV_ARCHIVE}" + WORKING_DIRECTORY "${LIBMPV_SRC}" + ) +endif() +# ------------------------------------------------------------------------------ + +project(mediakit_libs_ohos) + +set(LIBS + ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/arm64-v8a/libmpv.so.2) + +link_libraries(DART_SHARED_LIB ${LIBS}) diff --git a/libs/ohos/media_kit_libs_ohos/ohos/src/main/ets/MediaKitLibsOhosPlugin.ets b/libs/ohos/media_kit_libs_ohos/ohos/src/main/ets/MediaKitLibsOhosPlugin.ets new file mode 100644 index 000000000..7d0075029 --- /dev/null +++ b/libs/ohos/media_kit_libs_ohos/ohos/src/main/ets/MediaKitLibsOhosPlugin.ets @@ -0,0 +1,16 @@ +import { + FlutterPlugin, + FlutterPluginBinding, +} from "@ohos/flutter_ohos"; + +export default class MediaKitLibsOhosPlugin implements FlutterPlugin { + getUniqueClassName(): string { + return "MediaKitLibsOhosPlugin" + } + + onAttachedToEngine(binding: FlutterPluginBinding): void { + } + + onDetachedFromEngine(binding: FlutterPluginBinding): void { + } +} \ No newline at end of file diff --git a/libs/ohos/media_kit_libs_ohos/ohos/src/main/module.json5 b/libs/ohos/media_kit_libs_ohos/ohos/src/main/module.json5 new file mode 100644 index 000000000..8d7c10441 --- /dev/null +++ b/libs/ohos/media_kit_libs_ohos/ohos/src/main/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "media_kit_libs_ohos", + "type": "har", + "deviceTypes": [ + "phone", + "tablet", + "2in1", + "car", + "tv" + ] + } +} diff --git a/libs/ohos/media_kit_libs_ohos/pubspec.yaml b/libs/ohos/media_kit_libs_ohos/pubspec.yaml new file mode 100644 index 000000000..d5a71be45 --- /dev/null +++ b/libs/ohos/media_kit_libs_ohos/pubspec.yaml @@ -0,0 +1,24 @@ +name: media_kit_libs_ohos +description: HarmonyOS dependency package for package:media_kit. Necessary for initialization. +version: 1.0.0 +homepage: https://github.com/media-kit/media-kit.git +repository: https://github.com/media-kit/media-kit.git + +environment: + sdk: ">=2.17.0 <4.0.0" + flutter: ">=3.0.0" + +dependencies: + flutter: + sdk: flutter + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^5.0.0 + +flutter: + plugin: + platforms: + ohos: + pluginClass: MediaKitLibsOhosPlugin diff --git a/libs/universal/media_kit_libs_video/pubspec.yaml b/libs/universal/media_kit_libs_video/pubspec.yaml index 15555443c..0a400f344 100644 --- a/libs/universal/media_kit_libs_video/pubspec.yaml +++ b/libs/universal/media_kit_libs_video/pubspec.yaml @@ -10,13 +10,15 @@ environment: flutter: ">=3.7.0" dependencies: - media_kit_libs_android_video: + media_kit_libs_android_video: path: ../../android/media_kit_libs_android_video media_kit_libs_ios_video: path: ../../ios/media_kit_libs_ios_video - media_kit_libs_macos_video: + media_kit_libs_macos_video: path: ../../macos/media_kit_libs_macos_video - media_kit_libs_windows_video: + media_kit_libs_windows_video: path: ../../windows/media_kit_libs_windows_video - media_kit_libs_linux: + media_kit_libs_linux: path: ../../linux/media_kit_libs_linux + media_kit_libs_ohos: + path: ../../ohos/media_kit_libs_ohos diff --git a/libs/universal/media_kit_libs_video/pubspec_overrides.yaml b/libs/universal/media_kit_libs_video/pubspec_overrides.yaml index 0ac008080..9817ac404 100644 --- a/libs/universal/media_kit_libs_video/pubspec_overrides.yaml +++ b/libs/universal/media_kit_libs_video/pubspec_overrides.yaml @@ -10,3 +10,5 @@ dependency_overrides: path: ../../macos/media_kit_libs_macos_video media_kit_libs_windows_video: path: ../../windows/media_kit_libs_windows_video + media_kit_libs_ohos: + path: ../../ohos/media_kit_libs_ohos diff --git a/media_kit/lib/src/media_kit.dart b/media_kit/lib/src/media_kit.dart index 752045e50..9e6e10bc3 100644 --- a/media_kit/lib/src/media_kit.dart +++ b/media_kit/lib/src/media_kit.dart @@ -34,6 +34,8 @@ abstract class MediaKit { nativeEnsureInitialized(libmpv: libmpv); } else if (UniversalPlatform.isAndroid) { nativeEnsureInitialized(libmpv: libmpv); + } else if (UniversalPlatform.operatingSystem == 'ohos') { + nativeEnsureInitialized(libmpv: libmpv); } else if (UniversalPlatform.isWeb) { webEnsureInitialized(libmpv: libmpv); } diff --git a/media_kit/lib/src/player/native/core/execmem_restriction.dart b/media_kit/lib/src/player/native/core/execmem_restriction.dart index 32bb6a542..b766cc590 100644 --- a/media_kit/lib/src/player/native/core/execmem_restriction.dart +++ b/media_kit/lib/src/player/native/core/execmem_restriction.dart @@ -14,7 +14,7 @@ final bool isExecmemRestricted = _checkIfExecmemRestricted(); /// Checks if creating new anonymous executable memory mappings is blocked by the system. /// Only applies to Linux-based systems, since Dart doesn't use them for [NativeCallback]s on Fuchsia and Apple systems. bool _checkIfExecmemRestricted() { - if (Platform.isLinux || Platform.isAndroid) { + if (Platform.isLinux || Platform.isAndroid || Platform.operatingSystem == 'ohos') { try { final libs = DynamicLibrary.process(); final mmap = libs.lookupFunction( diff --git a/media_kit/lib/src/player/native/core/native_library.dart b/media_kit/lib/src/player/native/core/native_library.dart index 367d3d23c..106c6761e 100644 --- a/media_kit/lib/src/player/native/core/native_library.dart +++ b/media_kit/lib/src/player/native/core/native_library.dart @@ -64,6 +64,9 @@ abstract class NativeLibrary { 'android': [ 'libmpv.so', ], + 'ohos': [ + 'libmpv.so.2', + ], }[Platform.operatingSystem]; if (names != null) { // Try to load the dynamic library from the system using [DynamicLibrary.open]. @@ -88,6 +91,8 @@ abstract class NativeLibrary { 'Cannot find Mpv.framework/Mpv. Please ensure it\'s presence in the Frameworks folder of the application.', 'android': 'Cannot find libmpv.so. Please ensure it\'s presence in the APK.', + 'ohos': + 'Cannot find libmpv.so.2. Please ensure it\'s presence in the HAP.', }[Platform.operatingSystem]!, ); } diff --git a/media_kit/lib/src/player/native/utils/asset_loader.dart b/media_kit/lib/src/player/native/utils/asset_loader.dart index 56590b8ef..df9363cca 100644 --- a/media_kit/lib/src/player/native/utils/asset_loader.dart +++ b/media_kit/lib/src/player/native/utils/asset_loader.dart @@ -70,6 +70,18 @@ class AssetLoader { ), ), ); + } else if (Platform.operatingSystem == 'ohos') { + asset = path.normalize( + path.join( + path.dirname(Platform.resolvedExecutable), + '..', + '..', + 'resources', + 'rawfile', + 'flutter_assets', + key, + ), + ); } else { throw UnimplementedError( '$_kAssetScheme is not supported on ${Platform.operatingSystem}', diff --git a/media_kit/lib/src/player/native/utils/temp_file.dart b/media_kit/lib/src/player/native/utils/temp_file.dart index 6782dd2c3..af116d094 100644 --- a/media_kit/lib/src/player/native/utils/temp_file.dart +++ b/media_kit/lib/src/player/native/utils/temp_file.dart @@ -31,6 +31,8 @@ abstract class TempFile { result = Directory.systemTemp.path; } else if (Platform.isAndroid) { result = AndroidHelper.filesDir; + } else if (Platform.operatingSystem == 'ohos') { + result = Directory.systemTemp.path; } if (result != null) { return result; diff --git a/media_kit/lib/src/player/player.dart b/media_kit/lib/src/player/player.dart index 0d11ea7f0..aa950d29e 100644 --- a/media_kit/lib/src/player/player.dart +++ b/media_kit/lib/src/player/player.dart @@ -113,6 +113,8 @@ class Player { platform = NativePlayer(configuration: configuration); } else if (UniversalPlatform.isAndroid) { platform = NativePlayer(configuration: configuration); + } else if (UniversalPlatform.operatingSystem == 'ohos') { + platform = NativePlayer(configuration: configuration); } else if (UniversalPlatform.isWeb) { platform = WebPlayer(configuration: configuration); } diff --git a/media_kit_test/ohos/.gitignore b/media_kit_test/ohos/.gitignore new file mode 100644 index 000000000..e32649140 --- /dev/null +++ b/media_kit_test/ohos/.gitignore @@ -0,0 +1,20 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +**/BuildProfile.ets +**/oh-package-lock.json5 +/package.json +/package-lock.json + +**/src/main/resources/rawfile/flutter_assets/ +**/libs/**/libapp.so +**/libs/**/libflutter.so +**/libs/**/libvmservice_snapshot.so diff --git a/media_kit_test/ohos/AppScope/app.json5 b/media_kit_test/ohos/AppScope/app.json5 new file mode 100644 index 000000000..ed0367074 --- /dev/null +++ b/media_kit_test/ohos/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.github.alexmercerind.media_kit_test", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/media_kit_test/ohos/AppScope/resources/base/element/string.json b/media_kit_test/ohos/AppScope/resources/base/element/string.json new file mode 100644 index 000000000..160ea9251 --- /dev/null +++ b/media_kit_test/ohos/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "media_kit_test" + } + ] +} diff --git a/media_kit_test/ohos/AppScope/resources/base/media/app_icon.png b/media_kit_test/ohos/AppScope/resources/base/media/app_icon.png new file mode 100644 index 000000000..ce307a882 Binary files /dev/null and b/media_kit_test/ohos/AppScope/resources/base/media/app_icon.png differ diff --git a/media_kit_test/ohos/build-profile.json5 b/media_kit_test/ohos/build-profile.json5 new file mode 100644 index 000000000..60a44bf17 --- /dev/null +++ b/media_kit_test/ohos/build-profile.json5 @@ -0,0 +1,38 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.1.0(18)", + "runtimeOS": "HarmonyOS", + } + ], + "buildModeSet": [ + { + "name": "debug" + }, + { + "name": "profile" + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/media_kit_test/ohos/entry/.gitignore b/media_kit_test/ohos/entry/.gitignore new file mode 100644 index 000000000..5254b880d --- /dev/null +++ b/media_kit_test/ohos/entry/.gitignore @@ -0,0 +1,7 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test +GeneratedPluginRegistrant.ets \ No newline at end of file diff --git a/media_kit_test/ohos/entry/build-profile.json5 b/media_kit_test/ohos/entry/build-profile.json5 new file mode 100644 index 000000000..6de31ee22 --- /dev/null +++ b/media_kit_test/ohos/entry/build-profile.json5 @@ -0,0 +1,15 @@ + +{ + "apiType": 'stageMode', + "buildOption": { + }, + "targets": [ + { + "name": "default", + "runtimeOS": "HarmonyOS" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/media_kit_test/ohos/entry/hvigorfile.ts b/media_kit_test/ohos/entry/hvigorfile.ts new file mode 100644 index 000000000..ff3bfe082 --- /dev/null +++ b/media_kit_test/ohos/entry/hvigorfile.ts @@ -0,0 +1,7 @@ + +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +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. */ +} diff --git a/media_kit_test/ohos/entry/oh-package.json5 b/media_kit_test/ohos/entry/oh-package.json5 new file mode 100644 index 000000000..854eec208 --- /dev/null +++ b/media_kit_test/ohos/entry/oh-package.json5 @@ -0,0 +1,11 @@ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {}, +} + diff --git a/media_kit_test/ohos/entry/src/main/ets/entryability/EntryAbility.ets b/media_kit_test/ohos/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 000000000..f85a65508 --- /dev/null +++ b/media_kit_test/ohos/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,10 @@ + +import { FlutterAbility, FlutterEngine } from '@ohos/flutter_ohos'; +import { GeneratedPluginRegistrant } from '../plugins/GeneratedPluginRegistrant'; + +export default class EntryAbility extends FlutterAbility { + configureFlutterEngine(flutterEngine: FlutterEngine) { + super.configureFlutterEngine(flutterEngine) + GeneratedPluginRegistrant.registerWith(flutterEngine) + } +} diff --git a/media_kit_test/ohos/entry/src/main/ets/pages/Index.ets b/media_kit_test/ohos/entry/src/main/ets/pages/Index.ets new file mode 100644 index 000000000..7bb6543fe --- /dev/null +++ b/media_kit_test/ohos/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,24 @@ + +import common from '@ohos.app.ability.common'; +import { FlutterPage } from '@ohos/flutter_ohos' + +let storage = LocalStorage.getShared() +const EVENT_BACK_PRESS = 'EVENT_BACK_PRESS' + +@Entry(storage) +@Component +struct Index { + private context = getContext(this) as common.UIAbilityContext + @LocalStorageLink('viewId') viewId: string = ""; + + build() { + Column() { + FlutterPage({ viewId: this.viewId }) + } + } + + onBackPress(): boolean { + this.context.eventHub.emit(EVENT_BACK_PRESS) + return true + } +} \ No newline at end of file diff --git a/media_kit_test/ohos/entry/src/main/module.json5 b/media_kit_test/ohos/entry/src/main/module.json5 new file mode 100644 index 000000000..5ab7a8c15 --- /dev/null +++ b/media_kit_test/ohos/entry/src/main/module.json5 @@ -0,0 +1,46 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1", + "car", + "tv" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "orientation": "auto_rotation_unspecified", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + }, + ] + } +} \ No newline at end of file diff --git a/media_kit_test/ohos/entry/src/main/resources/base/element/color.json b/media_kit_test/ohos/entry/src/main/resources/base/element/color.json new file mode 100644 index 000000000..3c712962d --- /dev/null +++ b/media_kit_test/ohos/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/media_kit_test/ohos/entry/src/main/resources/base/element/string.json b/media_kit_test/ohos/entry/src/main/resources/base/element/string.json new file mode 100644 index 000000000..1130a14a6 --- /dev/null +++ b/media_kit_test/ohos/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "media_kit_test" + } + ] +} \ No newline at end of file diff --git a/media_kit_test/ohos/entry/src/main/resources/base/media/icon.png b/media_kit_test/ohos/entry/src/main/resources/base/media/icon.png new file mode 100644 index 000000000..ce307a882 Binary files /dev/null and b/media_kit_test/ohos/entry/src/main/resources/base/media/icon.png differ diff --git a/media_kit_test/ohos/entry/src/main/resources/base/profile/main_pages.json b/media_kit_test/ohos/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 000000000..1898d94f5 --- /dev/null +++ b/media_kit_test/ohos/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/media_kit_test/ohos/entry/src/main/resources/rawfile/buildinfo.json5 b/media_kit_test/ohos/entry/src/main/resources/rawfile/buildinfo.json5 new file mode 100644 index 000000000..6125c99c0 --- /dev/null +++ b/media_kit_test/ohos/entry/src/main/resources/rawfile/buildinfo.json5 @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "enable_impeller", + "value": "true" + } + ] +} \ No newline at end of file diff --git a/media_kit_test/ohos/hvigor/hvigor-config.json5 b/media_kit_test/ohos/hvigor/hvigor-config.json5 new file mode 100644 index 000000000..ad3ecab4a --- /dev/null +++ b/media_kit_test/ohos/hvigor/hvigor-config.json5 @@ -0,0 +1,6 @@ + +{ + "modelVersion": "5.1.0", + "dependencies": { + } +} \ No newline at end of file diff --git a/media_kit_test/ohos/hvigorconfig.ts b/media_kit_test/ohos/hvigorconfig.ts new file mode 100644 index 000000000..fc2b20863 --- /dev/null +++ b/media_kit_test/ohos/hvigorconfig.ts @@ -0,0 +1,4 @@ +import path from 'path' +import { injectNativeModules } from 'flutter-hvigor-plugin'; + +injectNativeModules(__dirname, path.dirname(__dirname)) \ No newline at end of file diff --git a/media_kit_test/ohos/hvigorfile.ts b/media_kit_test/ohos/hvigorfile.ts new file mode 100644 index 000000000..a64db460c --- /dev/null +++ b/media_kit_test/ohos/hvigorfile.ts @@ -0,0 +1,8 @@ +import path from 'path' +import { appTasks } from '@ohos/hvigor-ohos-plugin'; +import { flutterHvigorPlugin } from 'flutter-hvigor-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[flutterHvigorPlugin(path.dirname(__dirname))] /* Custom plugin to extend the functionality of Hvigor. */ +} \ No newline at end of file diff --git a/media_kit_test/ohos/oh-package.json5 b/media_kit_test/ohos/oh-package.json5 new file mode 100644 index 000000000..ce5a31139 --- /dev/null +++ b/media_kit_test/ohos/oh-package.json5 @@ -0,0 +1,13 @@ +{ + "modelVersion": "5.1.0", + "name": "media_kit_test", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {}, + "devDependencies": { + "@ohos/hypium": "1.0.6" + } +} diff --git a/media_kit_test/pubspec_overrides.yaml b/media_kit_test/pubspec_overrides.yaml index 5819c7d06..b4643f48b 100644 --- a/media_kit_test/pubspec_overrides.yaml +++ b/media_kit_test/pubspec_overrides.yaml @@ -14,5 +14,13 @@ dependency_overrides: path: ../libs/universal/media_kit_libs_video media_kit_libs_windows_video: path: ../libs/windows/media_kit_libs_windows_video + media_kit_libs_ohos: + path: ../libs/ohos/media_kit_libs_ohos media_kit_video: path: ../media_kit_video + +# Uncomment below to support ohos +# path_provider: +# git: +# url: https://gitcode.com/openharmony-tpc/flutter_packages.git +# path: packages/path_provider/path_provider diff --git a/media_kit_video/lib/media_kit_video_controls/src/controls/adaptive.dart b/media_kit_video/lib/media_kit_video_controls/src/controls/adaptive.dart index 61c317214..ceb4f9a5a 100644 --- a/media_kit_video/lib/media_kit_video_controls/src/controls/adaptive.dart +++ b/media_kit_video/lib/media_kit_video_controls/src/controls/adaptive.dart @@ -4,6 +4,7 @@ /// All rights reserved. /// Use of this source code is governed by MIT license that can be found in the LICENSE file. // ignore_for_file: non_constant_identifier_names +import 'dart:io'; import 'package:flutter/material.dart'; import 'package:media_kit_video/media_kit_video.dart'; @@ -22,6 +23,9 @@ Widget AdaptiveVideoControls(VideoState state) { case TargetPlatform.linux: return MaterialDesktopVideoControls(state); default: + if (Platform.operatingSystem == 'ohos') { + return MaterialVideoControls(state); + } return NoVideoControls(state); } } diff --git a/media_kit_video/lib/src/video/video_texture.dart b/media_kit_video/lib/src/video/video_texture.dart index d5ed54dde..4b47b2241 100644 --- a/media_kit_video/lib/src/video/video_texture.dart +++ b/media_kit_video/lib/src/video/video_texture.dart @@ -149,6 +149,7 @@ class VideoState extends State