{"id":51221421,"url":"https://github.com/wang-bin/libmdk-napi","last_synced_at":"2026-06-28T07:32:16.814Z","repository":{"id":356341446,"uuid":"1218262658","full_name":"wang-bin/libmdk-napi","owner":"wang-bin","description":"libmdk for ohos napi","archived":false,"fork":false,"pushed_at":"2026-05-19T16:14:21.000Z","size":87,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-19T19:47:10.227Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wang-bin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-22T17:42:04.000Z","updated_at":"2026-05-18T15:42:53.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/wang-bin/libmdk-napi","commit_stats":null,"previous_names":["wang-bin/libmdk-napi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wang-bin/libmdk-napi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wang-bin%2Flibmdk-napi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wang-bin%2Flibmdk-napi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wang-bin%2Flibmdk-napi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wang-bin%2Flibmdk-napi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wang-bin","download_url":"https://codeload.github.com/wang-bin/libmdk-napi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wang-bin%2Flibmdk-napi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34881384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-28T02:00:05.809Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-28T07:32:16.244Z","updated_at":"2026-06-28T07:32:16.806Z","avatar_url":"https://github.com/wang-bin.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @mediadevkit/libmdk-napi\n\nReusable OHOS HAR package for embedding an MDK-backed video surface in ArkTS apps.\n\nThis package is derived from the upstream MDK OHOS example app, but reshaped into a library developers can publish and consume via `ohpm install @mediadevkit/libmdk-napi`.\n\n## What the package provides\n\n- `MdkPlayerView`: an `XComponent` wrapper that loads the native `mdk_napi` library.\n- `MdkPlayerController`: an ArkTS controller for core playback operations.\n- A native N-API bridge keyed by `XComponent` id, so multiple player views can exist in the same app.\n- Escape hatches for MDK features via `setProperty`, `setDecoders`, `setActiveTracks`, `setMediaSource`, and `setAudioBackends`.\n\n## Package layout\n\n```text\nohos/\n├── libmdk_napi/          # HAR library package\n│   ├── src/main/cpp/\n│   │   ├── CMakeLists.txt\n│   │   ├── player_napi.cpp\n│   │   └── types/libmdk_napi/\n│   ├── src/main/ets/\n│   │   ├── components/MdkPlayerView.ets\n│   │   ├── controller/MdkPlayerController.ets\n│   │   └── index.ets\n│   ├── build-profile.json5\n│   ├── hvigorfile.ts\n│   └── oh-package.json5\n├── example/              # Standalone example app\n│   ├── AppScope/\n│   ├── entry/\n│   │   └── src/main/ets/pages/Index.ets\n│   ├── build-profile.json5\n│   ├── hvigorfile.ts\n│   └── oh-package.json5\n├── build-profile.json5\n├── hvigorfile.ts\n└── oh-package.json5\n```\n\n## MDK SDK prerequisite\n\nThis repository contains the package source, not the vendored MDK SDK binaries. Before building the HAR, place the OHOS MDK SDK under:\n\n```text\nohos/libmdk_napi/src/main/cpp/mdk-sdk/\n├── include/\n│   └── mdk/\n└── lib/\n    ├── cmake/FindMDK.cmake\n    └── ohos/\n        ├── arm64-v8a/libmdk.so\n        └── x86_64/libmdk.so\n```\n\nThe default lookup path is configured in [ohos/libmdk_napi/src/main/cpp/CMakeLists.txt](/Users/hr/develop/libmdk-napi/ohos/libmdk_napi/src/main/cpp/CMakeLists.txt). If you package MDK elsewhere, pass `-DMDK_SDK_DIR=/absolute/path/to/mdk-sdk` through your module build settings.\n\n## Build the HAR\n\n```bash\ncd ohos\nhvigorw assembleHar --mode module -p module=libmdk_napi@default\n```\n\nThe output HAR is written to `libmdk_napi/build/default/outputs/default/`.\n\n## Run the example app\n\nThe `example/` directory is a self-contained OHOS app that depends on the local HAR via a `file:` reference. It shows a video player with play/pause, stop, seek, and a URL input.\n\n```bash\ncd ohos/example\nohpm install\nhvigorw assembleHap --mode module -p module=entry@default\n```\n\nThen install and launch on a connected device or emulator:\n\n```bash\nhdc app install build/default/outputs/default/entry-default-signed.hap\nhdc shell aa start -b com.mediadevkit.mdkexample -a EntryAbility\n```\n\n\u003e The example page pre-loads an HLS stream on `aboutToAppear`. Change the URL in the text input at runtime or edit `Index.ets` to point at your own source.\n\n## Consumer setup\n\n1. Publish the generated HAR to your private registry or package feed under `@mediadevkit/libmdk-napi`.\n2. In an OHOS app, add the dependency with `ohpm install @mediadevkit/libmdk-napi`.\n3. Add app permissions as needed:\n   - `ohos.permission.INTERNET` for remote playback\n   - `ohos.permission.READ_MEDIA` if your app opens local files and passes `fd://` URLs\n\n## Example usage\n\n```ts\nimport { MdkPlayerController, MdkPlayerView } from '@mediadevkit/libmdk-napi';\n\n@Entry\n@Component\nstruct DemoPage {\n  private controller: MdkPlayerController = new MdkPlayerController();\n\n  aboutToAppear(): void {\n    this.controller.setDecoders(['OH', 'ohcodec:copy=1', 'FFmpeg', 'dav1d']);\n    this.controller.setMedia('https://example.com/video.mp4');\n    this.controller.play();\n  }\n\n  aboutToDisappear(): void {\n    this.controller.dispose();\n  }\n\n  build() {\n    Column({ space: 12 }) {\n      MdkPlayerView({ controller: this.controller, playerWidth: '100%', playerHeight: 240 })\n\n      Button('Pause').onClick(() =\u003e this.controller.pause())\n    }\n  }\n}\n```\n\n## Exposed MDK coverage\n\nThe wrapper intentionally focuses on the player features that map cleanly to a reusable UI package:\n\n- playback: `setMedia`, `setMediaSource`, `play`, `pause`, `stop`, `prepare`, `seek`\n- transport tuning: `setPlaybackRate`, `setLoop`, `setVolume`, `buffered`\n- decoder and track control: `setDecoders`, `setActiveTracks`, `setAudioBackends`\n- rendering options: `setColorSpace`\n- escape hatch: `setProperty` and `getProperty`\n\nAdvanced async callbacks from the C++ API are not wrapped yet. For features like `onMediaStatus`, `onEvent`, `snapshot`, or subtitle callbacks, extend the native bridge with either event emitters or typed async callbacks.\n\n## API notes from MDK\n\n- `setMedia(\"fd://N\")` is translated to `setProperty(\"avio\", \"N\")` plus `setMedia(\"fd:\")`, matching the upstream OHOS example.\n- `setDecoders(MediaType.Video, [\"OH\", \"ohcodec:copy=1\", \"FFmpeg\", \"dav1d\"])` is the recommended OHOS decoder order from the MDK Player APIs documentation.\n- `set(State::Stopped)` releases playback resources. If you re-open immediately after stop, the underlying MDK state transition is still async.\n\n## Current limits\n\n- This package scaffold was created on macOS without DevEco Studio or an OHOS SDK runtime, so build and device validation still need to be run in an OHOS environment.\n- Publishing as `@mediadevkit/libmdk-napi` is a registry step outside this repository; the package metadata and source layout are prepared for that flow.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwang-bin%2Flibmdk-napi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwang-bin%2Flibmdk-napi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwang-bin%2Flibmdk-napi/lists"}