Files
synctv-weihang/hbuilder_app/nativeplugins/SyncTV-VLC/README.md
2026-06-15 22:46:12 +08:00

58 lines
1.4 KiB
Markdown

# SyncTV VLC Native Plugin
HBuilder/uni-app cannot call VLC directly from Vue/JavaScript. The app needs a native plugin layer:
```text
uni-app UI
-> SyncTV-VLC plugin JS facade
-> Android native module: libVLC
-> iOS native module: MobileVLCKit / VLCKit
```
The Vue page should only call the facade API below. The plugin implementation can then be filled in per platform without changing room/sync UI code.
## JS Facade API
```js
const player = uni.requireNativePlugin('SyncTV-VLC')
player.open({
url,
headers,
username,
password,
isLive
})
player.play()
player.pause()
player.seek({ positionMs: 120000 })
player.getPosition((result) => {
console.log(result.positionMs)
})
player.release()
```
## Android Implementation Target
- Use `org.videolan.android:libvlc-all`.
- Expose methods through a uni-app native plugin module.
- Render into a native view component if possible.
- Support:
- HTTP/HTTPS URL.
- m3u8.
- WebDAV Basic Auth.
- Custom headers.
- Live stream.
- play/pause/seek/getPosition.
## iOS Implementation Target
- Use MobileVLCKit / VLCKit.
- Expose equivalent plugin methods.
- Render through native view component.
## Fallback
The current page keeps a `<video>` fallback for development preview. Production app playback should use this native plugin because the built-in video component still depends on system/WebView media support.