feat(web): add libass-wasm support for ASS/SSA external subtitles#485
feat(web): add libass-wasm support for ASS/SSA external subtitles#485lulitao1997 wants to merge 1 commit into
Conversation
Add a web-specific libass bridge backed by SubtitlesOctopus so ASS/SSA external subtitles can render outside the native player subtitle pipeline. The Dart subtitle manager now routes ASS/SSA files through the bridge on web, disposes active libass instances when external subtitles are cleared, and persists the selected subtitle track like other external subtitle sources. Subtitle delay preference updates are forwarded to libass via timeOffset, and the web entrypoint now exposes the JavaScript helpers required to create, dispose, resize, and retime a SubtitlesOctopus instance. This commit also vendors the libass worker/wasm/font assets, adds a helper script for refreshing those assets, and updates generated dependency/plugin registration files required by the new web bridge.
|
@codex review |
|
@MCDFsteve sorry 还是draft, 有些ui的还没vibe出来。。 |
OK |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0638b4d531
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // 先释放旧实例(initWithUrl 内部也会释放,此处为了状态一致性先清理) | ||
| LibassWebBridge.dispose(); | ||
|
|
||
| unawaited(LibassWebBridge.initWithUrl(path).then((_) { |
There was a problem hiding this comment.
Reapply saved subtitle delay when initializing libass
When an ASS/SSA track is activated here, the current subtitle delay preference is never pushed to the new libass instance. setSubtitleDelaySeconds only calls LibassWebBridge.setTimeOffset when the user changes the slider, and that bridge method is a no-op while libass is inactive, so any delay configured before loading the subtitle is lost and playback starts with zero offset. This causes persistent subtitle-sync settings to be ignored until the user changes delay again.
Useful? React with 👍 / 👎.
| updateSubtitleTrackInfo('external_subtitle', { | ||
| 'path': path, | ||
| 'title': p.basename(path), | ||
| 'isActive': true, | ||
| 'isManualSet': isManualSetting, |
There was a problem hiding this comment.
Avoid marking external subtitle active before libass is ready
This updates external_subtitle as active unconditionally even though LibassWebBridge.initWithUrl can return early (for example when JS helpers are missing or no <video> element is found). In that failure path, UI/state says subtitles are active and the path is persisted, but nothing is actually rendering, which can leave users stuck in a false-active state until they manually toggle subtitles.
Useful? React with 👍 / 👎.
|
Welcome and thank you for your first contribution! The libass-wasm support for web ASS/SSA subtitles looks like a valuable addition. Let us know if you need any help. |
Summary
Why
The web player does not have native ASS/SSA subtitle rendering support equivalent to the desktop kernels. This adds a browser-side rendering path so styled subtitles can be displayed correctly for external subtitle files.
Changes
LibassWebBridgewith web and stub implementations.ass/.ssaexternal subtitles inSubtitleManagerand activate libass rendering on webtimeOffsetweb/index.htmlweb/scripts/download-libass-wasm.shfor asset refreshNotes