mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-16 14:16:16 -08:00
Xtream Codes live streams with .ts format serve continuous raw MPEG-TS data over HTTP, not HLS playlists. All three embedded players failed to handle this: ArtPlayer had no handler, HTML5 player fed it to HLS.js, and Video.js tried to parse it as an HLS manifest. Add mpegts.js to handle raw MPEG-TS streams via Media Source Extensions in ArtPlayer, HTML5 player, and Video.js. Fix the MIME type for .ts sources from application/x-mpegURL to video/mp2t.
76 lines
2.0 KiB
TypeScript
76 lines
2.0 KiB
TypeScript
import {
|
|
Component,
|
|
EventEmitter,
|
|
Output,
|
|
Signal,
|
|
ViewEncapsulation,
|
|
effect,
|
|
inject,
|
|
input,
|
|
} from '@angular/core';
|
|
import { toSignal } from '@angular/core/rxjs-interop';
|
|
import { StorageMap } from '@ngx-pwa/local-storage';
|
|
import {
|
|
ArtPlayerComponent,
|
|
HtmlVideoPlayerComponent,
|
|
VjsPlayerComponent,
|
|
} from 'components';
|
|
import { getExtensionFromUrl } from 'm3u-utils';
|
|
import { STORE_KEY, Settings, VideoPlayer } from 'shared-interfaces';
|
|
|
|
@Component({
|
|
selector: 'app-web-player-view',
|
|
templateUrl: './web-player-view.component.html',
|
|
styleUrls: ['./web-player-view.component.scss'],
|
|
imports: [ArtPlayerComponent, HtmlVideoPlayerComponent, VjsPlayerComponent],
|
|
encapsulation: ViewEncapsulation.None,
|
|
})
|
|
export class WebPlayerViewComponent {
|
|
storage = inject(StorageMap);
|
|
|
|
streamUrl = input.required<string>();
|
|
startTime = input<number>(0);
|
|
@Output() timeUpdate = new EventEmitter<{
|
|
currentTime: number;
|
|
duration: number;
|
|
}>();
|
|
|
|
settings = toSignal(
|
|
this.storage.get(STORE_KEY.Settings)
|
|
) as Signal<Settings>;
|
|
|
|
channel!: { url: string };
|
|
player!: VideoPlayer;
|
|
vjsOptions!: { sources: { src: string; type: string }[] };
|
|
|
|
constructor() {
|
|
effect(() => {
|
|
this.player = this.settings()?.player;
|
|
|
|
this.setChannel(this.streamUrl());
|
|
if (this.player === VideoPlayer.VideoJs)
|
|
this.setVjsOptions(this.streamUrl());
|
|
});
|
|
}
|
|
|
|
setVjsOptions(streamUrl: string) {
|
|
const extension = getExtensionFromUrl(streamUrl);
|
|
const mimeType =
|
|
extension === 'm3u' || extension === 'm3u8'
|
|
? 'application/x-mpegURL'
|
|
: extension === 'ts'
|
|
? 'video/mp2t'
|
|
: 'video/mp4';
|
|
|
|
this.vjsOptions = {
|
|
sources: [{ src: streamUrl, type: mimeType }],
|
|
};
|
|
}
|
|
|
|
setChannel(streamUrl: string) {
|
|
this.channel = {
|
|
url: streamUrl,
|
|
};
|
|
}
|
|
}
|