Update MPEG-TS IPTV detection to use native playback
Changed protocol detection for .ts IPTV streams to prefer native playback instead of HLS.js, reflecting modern browser support for MPEG-TS. Updated related tests to match new behavior.
This commit is contained in:
@@ -5,16 +5,16 @@ describe('videoProtocol', () => {
|
|||||||
describe('detectVideoProtocol', () => {
|
describe('detectVideoProtocol', () => {
|
||||||
it('should detect MPEG-TS IPTV streams', () => {
|
it('should detect MPEG-TS IPTV streams', () => {
|
||||||
const result = detectVideoProtocol('http://favoritv65.xyz:8080/live/Apollon45/HpjWrDa6gWWd/98925.ts')
|
const result = detectVideoProtocol('http://favoritv65.xyz:8080/live/Apollon45/HpjWrDa6gWWd/98925.ts')
|
||||||
expect(result.protocol).toBe('hls')
|
expect(result.protocol).toBe('native')
|
||||||
expect(result.isLive).toBe(true)
|
expect(result.isLive).toBe(true)
|
||||||
expect(result.needsSpecialPlayer).toBe(true)
|
expect(result.needsSpecialPlayer).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should detect .ts files with query parameters', () => {
|
it('should detect .ts files with query parameters', () => {
|
||||||
const result = detectVideoProtocol('http://example.com/stream/video.ts?token=abc123')
|
const result = detectVideoProtocol('http://example.com/stream/video.ts?token=abc123')
|
||||||
expect(result.protocol).toBe('hls')
|
expect(result.protocol).toBe('native')
|
||||||
expect(result.isLive).toBe(true)
|
expect(result.isLive).toBe(true)
|
||||||
expect(result.needsSpecialPlayer).toBe(true)
|
expect(result.needsSpecialPlayer).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should detect HLS streams', () => {
|
it('should detect HLS streams', () => {
|
||||||
@@ -75,8 +75,8 @@ describe('videoProtocol', () => {
|
|||||||
expect(isHlsStream('http://example.com/stream.m3u8')).toBe(true)
|
expect(isHlsStream('http://example.com/stream.m3u8')).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return true for IPTV .ts streams (they use HLS.js for transmuxing)', () => {
|
it('should return false for IPTV .ts streams (they use native playback)', () => {
|
||||||
expect(isHlsStream('http://favoritv65.xyz:8080/live/user/pass/98925.ts')).toBe(true)
|
expect(isHlsStream('http://favoritv65.xyz:8080/live/user/pass/98925.ts')).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return false for non-HLS streams', () => {
|
it('should return false for non-HLS streams', () => {
|
||||||
|
|||||||
@@ -74,12 +74,12 @@ export const detectVideoProtocol = (src: string): ProtocolDetectionResult => {
|
|||||||
// MPEG-TS (IPTV) detection
|
// MPEG-TS (IPTV) detection
|
||||||
// Check for .ts extension (Transport Stream used in IPTV)
|
// Check for .ts extension (Transport Stream used in IPTV)
|
||||||
// Note: These are direct TS streams, not HLS playlists
|
// Note: These are direct TS streams, not HLS playlists
|
||||||
// We use HLS.js to transmux them as browsers don't support MPEG-TS natively
|
// Try native playback first as modern browsers support MPEG-TS
|
||||||
if (lowerSrc.includes('.ts') || lowerSrc.match(/\.ts(\?|$)/)) {
|
if (lowerSrc.includes('.ts') || lowerSrc.match(/\.ts(\?|$)/)) {
|
||||||
return {
|
return {
|
||||||
protocol: 'hls', // Use HLS.js which can handle MPEG-TS transmuxing
|
protocol: 'native', // Try native playback first
|
||||||
isLive: true, // IPTV streams are typically live
|
isLive: true, // IPTV streams are typically live
|
||||||
needsSpecialPlayer: true, // Requires HLS.js for MPEG-TS transmuxing
|
needsSpecialPlayer: false, // Modern browsers support MPEG-TS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user