Skip to content

feat/embedded-player-improvements#716

Closed
4gray wants to merge 3 commits intonxfrom
feat/embedded-player-improvements
Closed

feat/embedded-player-improvements#716
4gray wants to merge 3 commits intonxfrom
feat/embedded-player-improvements

Conversation

@4gray
Copy link
Owner

@4gray 4gray commented Jan 7, 2026

Summary

  • Add DASH (dashjs), FLV (flv.js), and MPEG-TS (mpegts.js) libraries to support additional streaming formats.
  • Detect codec errors in the Video.js player, emit codecError events, and avoid duplicate/noisy reports.
  • Add support for raw MPEG-TS streams: detect mpegts URLs, prevent autoplay for them, and initialize a dedicated mpegts player instance.
  • Replace hardcoded HLS MIME type with runtime getMimeType(), swap to videojs-quality-selector-hls plugin, and safely initialize plugins.
  • Improve player robustness: safer destruction, handle fatal errors to prevent races, persist volume changes, and listen to video element errors to surface codec problems.
  • Increase initial bundle max error from 5MB to 6MB to avoid CI/build failures.
  • Add PLAYER i18n entries (UNSUPPORTED_CODEC, SWITCH_TO_VLC).

4gray added 3 commits January 7, 2026 23:52
Add dashjs, flv.js, and mpegts.js to dependencies to support additional
streaming formats (DASH, FLV and MPEG-TS) for broader playback
compatibility. Replace videojs-hls-quality-selector with
videojs-quality-selector-hls to use the updated/renamed HLS quality
selector package. Remove unused @types entry for the old HLS selector
to keep devDependencies accurate. These dependency updates prepare the
project for multi-format playback and reduce type-package drift.
Add codec error detection and reporting to the Video.js player component
and propagate codec error events to parent components. Introduce a
codecError event emitter with a CodecError interface and logic to avoid
duplicated or noisy error reporting. Improve player initialization to
handle raw MPEG-TS streams via mpegts.js: detect mpegts URLs, prevent
autoplay for those streams, and initialize a dedicated mpegts player
instance. Wire codec error output up in template so host components can
handle codec failures.

Also:
- Replace hardcoded HLS MIME type with runtime getMimeType() in templates.
- Swap to videojs-quality-selector-hls plugin and add safe init of plugins.
- Add safeguards for player destruction and more robust error handling
  (track fatal errors, prevent races).
- Persist volume changes and listen to video element errors to surface
  codec problems.

These changes enable better handling of unsupported audio/video codecs,
support raw .ts streams, and allow UI-level responses to codec failures.
Increase maximumError for initial budgets from 5mb to 6mb in the web
project configuration to accommodate a larger initial bundle size after
recent feature additions and avoid CI/build failures due to strict size
limits.

Add PLAYER translations to English i18n:
- UNSUPPORTED_CODEC: message informing users about unsupported codec
  and suggesting VLC or MPV.
- SWITCH_TO_VLC: label for action to switch to VLC.

These changes prevent spurious bundle-size errors and improve user
feedback when encountering unsupported media codecs.
@vercel
Copy link

vercel bot commented Jan 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
iptvnator Error Error Jan 7, 2026 10:53pm

@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Jan 7, 2026

View your CI Pipeline Execution ↗ for commit 07eace7

Command Status Duration Result
nx run electron-backend:make ✅ Succeeded 12m 17s View ↗
nx build electron-backend ✅ Succeeded 39s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-07 23:09:51 UTC

@greptile-apps
Copy link

greptile-apps bot commented Jan 7, 2026

Greptile Summary

Adds comprehensive streaming format support (DASH, FLV, MPEG-TS) with intelligent codec error detection and user-friendly fallback suggestions. The implementation properly handles player lifecycle, prevents error loops, and differentiates between live vs VOD streams for optimal buffering.

  • Added dashjs, flv.js, and mpegts.js libraries to support additional streaming formats beyond HLS
  • Implemented codec error detection that identifies unsupported audio (EC-3, AC-3) and video (HEVC) codecs
  • Added user-facing error notifications via snackbar with actionable "Switch to VLC" button on desktop
  • Enhanced Video.js player with mpegts.js integration, including VOD/live stream detection and fatal error prevention
  • Improved ArtPlayer with multi-format support (DASH, FLV, MPEG-TS, MKV) via custom type handlers
  • Replaced hardcoded HLS MIME type with runtime getMimeType() detection based on URL extensions
  • Switched to videojs-quality-selector-hls plugin (Video.js 8+ compatible fork) with safe initialization
  • Increased bundle size limit from 5MB to 6MB to accommodate new streaming libraries
  • Added i18n support for player error messages (PLAYER.UNSUPPORTED_CODEC, PLAYER.SWITCH_TO_VLC)

Confidence Score: 4/5

  • Safe to merge with one logic issue in event listener cleanup that should be addressed
  • The PR adds valuable features with generally solid implementation. There's one event listener cleanup bug in vjs-player that will prevent proper resource cleanup. The HTML5 player lacks codec error detection creating inconsistent UX. The changes are well-structured but would benefit from the fixes mentioned.
  • libs/ui/components/src/lib/vjs-player/vjs-player.component.ts - event listener cleanup bug at line 380

Important Files Changed

Filename Overview
libs/ui/components/src/lib/vjs-player/vjs-player.component.ts Adds mpegts.js support with codec error detection, fatal error handling, and VOD/live stream differentiation - solid implementation with proper cleanup
libs/ui/components/src/lib/art-player/art-player.component.ts Adds DASH, FLV, and MPEG-TS support with codec error detection - well-structured with proper player lifecycle management
apps/web/src/app/home/video-player/video-player.component.ts Adds codec error handling with user-friendly snackbar notification and VLC auto-switch option - clean implementation
libs/ui/components/src/lib/html-video-player/html-video-player.component.ts Adds mpegts.js support for raw .ts streams with proper cleanup - straightforward implementation without error emission

Sequence Diagram

sequenceDiagram
    participant User
    participant VideoPlayer
    participant VjsPlayer
    participant MpegtsLib as mpegts.js
    participant VideoElement as HTMLVideoElement
    participant SnackBar

    User->>VideoPlayer: Select channel with .ts stream
    VideoPlayer->>VjsPlayer: Load channel with getMimeType()
    VjsPlayer->>VjsPlayer: isMpegTsStream() detects .ts
    VjsPlayer->>VjsPlayer: isLikelyLiveStream() checks URL patterns
    VjsPlayer->>MpegtsLib: createPlayer({type: 'mpegts', isLive: true/false})
    MpegtsLib->>VideoElement: attachMediaElement()
    MpegtsLib->>MpegtsLib: load() and parse stream
    
    alt Stream has unsupported codec (EC-3, AC-3, HEVC)
        MpegtsLib->>VjsPlayer: Events.ERROR with codec details
        VjsPlayer->>VjsPlayer: handleMpegtsError() detects codec error
        VjsPlayer->>VjsPlayer: extractCodecFromError()
        VjsPlayer->>VjsPlayer: Set fatalErrorOccurred flag
        VjsPlayer->>VideoPlayer: Emit codecError event
        VjsPlayer->>VjsPlayer: destroyMpegTs() to prevent error loop
        VideoPlayer->>VideoPlayer: handleCodecError()
        VideoPlayer->>SnackBar: Show "Unsupported codec" with "Switch to VLC" action
        User->>SnackBar: Click "Switch to VLC"
        SnackBar->>VideoPlayer: Action triggered
        VideoPlayer->>VideoPlayer: settingsStore.updateSettings({player: VLC})
    else Stream plays successfully
        MpegtsLib->>VideoElement: Decode and render stream
        VideoElement->>User: Video playback
    end
    
    User->>VideoPlayer: Switch to different channel
    VideoPlayer->>VjsPlayer: ngOnChanges with new channel
    VjsPlayer->>VjsPlayer: Reset codecErrorShown flag
    VjsPlayer->>VjsPlayer: destroyMpegTs()
    VjsPlayer->>MpegtsLib: destroy() existing player
    Note over VjsPlayer,MpegtsLib: Cycle repeats for new channel
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

7 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

this.isDestroying = true;
try {
// Remove all event listeners first
this.mpegtsPlayer.off(mpegts.Events.ERROR, this.handleMpegtsError);
Copy link

Choose a reason for hiding this comment

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

logic: Event listener not properly removed before destroying. The handleMpegtsError method is bound as an arrow function (line 273), so the reference passed to off() won't match the reference passed to on() (line 211), meaning the listener won't be removed.

Suggested change
this.mpegtsPlayer.off(mpegts.Events.ERROR, this.handleMpegtsError);
// Event handlers are cleaned up automatically by destroy()
Prompt To Fix With AI
This is a comment left during a code review.
Path: libs/ui/components/src/lib/vjs-player/vjs-player.component.ts
Line: 380:380

Comment:
**logic:** Event listener not properly removed before destroying. The `handleMpegtsError` method is bound as an arrow function (line 273), so the reference passed to `off()` won't match the reference passed to `on()` (line 211), meaning the listener won't be removed.

```suggestion
                // Event handlers are cleaned up automatically by destroy()
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +122 to +126
const mpegtsPlayer = mpegts.createPlayer({
type: 'mpegts',
isLive: true,
url: url,
});
Copy link

Choose a reason for hiding this comment

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

style: Always assumes MPEG-TS streams are live (isLive: true), but the URL might be a VOD file. Consider detecting VOD patterns like the vjs-player does (lines 140-159 in vjs-player.component.ts), which checks for /movie/, /series/, /vod/, /films/ paths.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: libs/ui/components/src/lib/art-player/art-player.component.ts
Line: 122:126

Comment:
**style:** Always assumes MPEG-TS streams are live (`isLive: true`), but the URL might be a VOD file. Consider detecting VOD patterns like the vjs-player does (lines 140-159 in vjs-player.component.ts), which checks for `/movie/`, `/series/`, `/vod/`, `/films/` paths.

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +102 to +106
this.mpegtsPlayer = mpegts.createPlayer({
type: 'mpegts',
isLive: true,
url: url,
});
Copy link

Choose a reason for hiding this comment

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

style: Missing codec error detection for mpegts.js. The vjs-player and art-player components emit codecError events when mpegts.js encounters unsupported codecs, but this component doesn't. This creates inconsistent UX - users won't get the helpful VLC/MPV suggestion when using the HTML5 player.

Prompt To Fix With AI
This is a comment left during a code review.
Path: libs/ui/components/src/lib/html-video-player/html-video-player.component.ts
Line: 102:106

Comment:
**style:** Missing codec error detection for mpegts.js. The vjs-player and art-player components emit `codecError` events when mpegts.js encounters unsupported codecs, but this component doesn't. This creates inconsistent UX - users won't get the helpful VLC/MPV suggestion when using the HTML5 player.

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +102 to +106
this.mpegtsPlayer = mpegts.createPlayer({
type: 'mpegts',
isLive: true,
url: url,
});
Copy link

Choose a reason for hiding this comment

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

style: Always assumes MPEG-TS streams are live (isLive: true). Same issue as in art-player - should detect VOD patterns to optimize buffering and seeking behavior for video-on-demand content.

Prompt To Fix With AI
This is a comment left during a code review.
Path: libs/ui/components/src/lib/html-video-player/html-video-player.component.ts
Line: 102:106

Comment:
**style:** Always assumes MPEG-TS streams are live (`isLive: true`). Same issue as in art-player - should detect VOD patterns to optimize buffering and seeking behavior for video-on-demand content.

How can I resolve this? If you propose a fix, please make it concise.

@s1sw4nto
Copy link

s1sw4nto commented Jan 8, 2026

IPTVnaptor [v0.17.1] ArtPlayer not working to play stream DRM with ClearKey
please see bellow, i try install working fine
https://github.com/Mikoshi-nyudo/iptvnator-electron/tree/main/src/app/player/components/art-player

@4gray 4gray deleted the branch nx January 12, 2026 20:48
@4gray 4gray closed this Jan 12, 2026
@4gray 4gray deleted the feat/embedded-player-improvements branch January 12, 2026 20:52
@4gray 4gray restored the feat/embedded-player-improvements branch January 12, 2026 20:52
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.

2 participants