Skip to content

feat(web): add libass-wasm support for ASS/SSA external subtitles#485

Draft
lulitao1997 wants to merge 1 commit into
AimesSoft:mainfrom
lulitao1997:feat/web-libass-ass-ssa-subtitles
Draft

feat(web): add libass-wasm support for ASS/SSA external subtitles#485
lulitao1997 wants to merge 1 commit into
AimesSoft:mainfrom
lulitao1997:feat/web-libass-ass-ssa-subtitles

Conversation

@lulitao1997

Copy link
Copy Markdown
Contributor

Summary

  • add web ASS/SSA external subtitle rendering through libass-wasm / SubtitlesOctopus
  • route supported external subtitle files through a dedicated JS interop bridge on web
  • vendor the required worker, wasm, and font assets and add a refresh script

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

  • add LibassWebBridge with web and stub implementations
  • detect .ass / .ssa external subtitles in SubtitleManager and activate libass rendering on web
  • dispose active libass instances when external subtitles are cleared
  • forward subtitle delay changes to libass via timeOffset
  • inject the JavaScript helper functions required by SubtitlesOctopus into web/index.html
  • add the SubtitlesOctopus runtime assets under web/
  • add scripts/download-libass-wasm.sh for asset refresh
  • update dependency and generated plugin registration files required by the bridge

Notes

  • this path only handles ASS/SSA external subtitles on web
  • desktop and mobile subtitle behavior is unchanged

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.
@MCDFsteve

Copy link
Copy Markdown
Collaborator

@codex review

@lulitao1997

Copy link
Copy Markdown
Contributor Author

@MCDFsteve sorry 还是draft, 有些ui的还没vibe出来。。

@MCDFsteve

Copy link
Copy Markdown
Collaborator

@MCDFsteve sorry 还是draft, 有些ui的还没vibe出来。。

OK

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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((_) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +470 to +474
updateSubtitleTrackInfo('external_subtitle', {
'path': path,
'title': p.basename(path),
'isActive': true,
'isManualSet': isManualSetting,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@FurudeRika123

Copy link
Copy Markdown
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants