mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 17:06:15 -08:00
fix: address code review issues for mpegts.js integration
- ArtPlayer: use getExtensionFromUrl for query-string-aware URL parsing
instead of naive split('.').pop() and endsWith('.ts')
- VJS player: call player.reset() before initMpegTs() on non-TS to TS
channel switch to prevent playback conflicts
This commit is contained in:
1 parent
e3d1bf2048
commit
b0e1642e6c
2 files changed
+5
-3
No files matched your search
@@ -12,6 +12,7 @@ import {
|
||||
} from '@angular/core';
|
||||
import Artplayer from 'artplayer';
|
||||
import Hls from 'hls.js';
|
||||
import { getExtensionFromUrl } from 'm3u-utils';
|
||||
import mpegts from 'mpegts.js';
|
||||
import { Channel } from 'shared-interfaces';
|
||||
|
||||
@@ -87,8 +88,8 @@ export class ArtPlayerComponent implements OnInit, OnDestroy, OnChanges {
|
||||
const el = this.elementRef.nativeElement.querySelector(
|
||||
'.artplayer-container'
|
||||
);
|
||||
const url = this.channel?.url?.toLowerCase() ?? '';
|
||||
const isLive = url.includes('m3u8') || url.endsWith('.ts');
|
||||
const extension = getExtensionFromUrl(this.channel?.url ?? '');
|
||||
const isLive = extension === 'm3u8' || extension === 'ts';
|
||||
|
||||
this.player = new Artplayer({
|
||||
container: el,
|
||||
@@ -206,7 +207,7 @@ export class ArtPlayerComponent implements OnInit, OnDestroy, OnChanges {
|
||||
}
|
||||
|
||||
private getVideoType(url: string): string {
|
||||
const extension = url.split('.').pop()?.toLowerCase();
|
||||
const extension = getExtensionFromUrl(url);
|
||||
switch (extension) {
|
||||
case 'mkv':
|
||||
return 'video/matroska';
|
||||
|
||||
@@ -143,6 +143,7 @@ export class VjsPlayerComponent implements OnInit, OnChanges, OnDestroy {
|
||||
const newSource = changes['options'].currentValue.sources[0];
|
||||
if (this.isMpegTsSource(newSource?.src)) {
|
||||
this.destroyMpegTs();
|
||||
this.player.reset();
|
||||
this.initMpegTs(newSource.src);
|
||||
} else {
|
||||
this.destroyMpegTs();
|
||||
|
||||
Reference in new issue
Block a user