Add MPEG-TS support and related utilities

Introduces MPEG-TS streaming support by adding mpegts.js as an optional dependency, updating keywords, and implementing new utility modules for MPEG-TS loading and setup. Updates VideoElement and videoProtocol logic to handle MPEG-TS streams, adds corresponding tests and mocks, and improves local settings for npm install.
This commit is contained in:
hibna
2025-11-04 06:36:21 +03:00
parent db2e3a0722
commit b0e278afb5
10 changed files with 380 additions and 3594 deletions
+21
View File
@@ -5,6 +5,7 @@ import { validateVideoURL, getCORSErrorMessage, isCORSError } from '../utils/cor
import { setHlsAudioTrack, setHlsQualityLevel } from '../utils/hlsControl'
import { setupHlsInstance } from '../utils/hlsSetup'
import { setupRtmpInstance } from '../utils/rtmpSetup'
import { setupMpegtsInstance } from '../utils/mpegtsSetup'
import { detectVideoProtocol } from '../utils/videoProtocol'
import { createSubtitleBlobURL } from '../utils/subtitles'
import './VideoElement.css'
@@ -391,6 +392,19 @@ export const VideoElement: React.FC<VideoElementProps> = ({
break
}
case 'mpegts': {
// MPEG-TS/IPTV streaming setup
console.log('[VideoElement] Setting up MPEG-TS player...')
cleanupFn = await setupMpegtsInstance({
video,
src,
autoplay,
onError: handleError,
onLoadedMetadata,
})
break
}
case 'dash': {
// DASH streaming - not yet implemented
const error = new Error('DASH streaming is not yet supported')
@@ -451,6 +465,13 @@ export const VideoElement: React.FC<VideoElementProps> = ({
}
delete (video as any).__rtmpInstance
}
if ((video as any).__mpegtsInstance) {
const mpegts = (video as any).__mpegtsInstance
if (mpegts && typeof mpegts.destroy === 'function') {
mpegts.destroy()
}
delete (video as any).__mpegtsInstance
}
}
}, [
src,