Add SRT/FLV/RTMP support and update documentation
Introduced Python scripts for SRT subtitle checking and fixing, and added comprehensive documentation covering advanced features such as protocol detection, subtitle/audio/quality management, keyboard shortcuts, and touch gestures. Updated local settings to allow new build and Python commands, added TypeScript definitions for FLV, and implemented RTMP/FLV protocol support in the player. Removed CHANGELOG.md and made various improvements to styles and example app.
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* Video protocol detection utility
|
||||
* Detects the streaming protocol from a video URL
|
||||
*/
|
||||
|
||||
export type VideoProtocol = 'native' | 'hls' | 'rtmp' | 'dash'
|
||||
|
||||
export interface ProtocolDetectionResult {
|
||||
protocol: VideoProtocol
|
||||
isLive: boolean
|
||||
needsSpecialPlayer: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects the video protocol from the source URL
|
||||
* @param src - The video source URL
|
||||
* @returns Protocol detection result
|
||||
*/
|
||||
export const detectVideoProtocol = (src: string): ProtocolDetectionResult => {
|
||||
if (!src) {
|
||||
return {
|
||||
protocol: 'native',
|
||||
isLive: false,
|
||||
needsSpecialPlayer: false,
|
||||
}
|
||||
}
|
||||
|
||||
const lowerSrc = src.toLowerCase()
|
||||
|
||||
// RTMP protocol detection
|
||||
// Supports: rtmp://, rtmps://, rtmpt://, rtmpe://
|
||||
if (
|
||||
lowerSrc.startsWith('rtmp://') ||
|
||||
lowerSrc.startsWith('rtmps://') ||
|
||||
lowerSrc.startsWith('rtmpt://') ||
|
||||
lowerSrc.startsWith('rtmpe://')
|
||||
) {
|
||||
return {
|
||||
protocol: 'rtmp',
|
||||
isLive: true, // RTMP is typically used for live streaming
|
||||
needsSpecialPlayer: true,
|
||||
}
|
||||
}
|
||||
|
||||
// HLS protocol detection
|
||||
// Check for .m3u8 extension or HLS URL patterns
|
||||
if (lowerSrc.includes('.m3u8')) {
|
||||
return {
|
||||
protocol: 'hls',
|
||||
isLive: lowerSrc.includes('/live/') || lowerSrc.includes('live.m3u8'),
|
||||
needsSpecialPlayer: true,
|
||||
}
|
||||
}
|
||||
|
||||
// DASH protocol detection
|
||||
// Check for .mpd extension
|
||||
if (lowerSrc.includes('.mpd')) {
|
||||
return {
|
||||
protocol: 'dash',
|
||||
isLive: lowerSrc.includes('/live/') || lowerSrc.includes('live.mpd'),
|
||||
needsSpecialPlayer: true,
|
||||
}
|
||||
}
|
||||
|
||||
// HTTP-FLV detection (alternative to RTMP)
|
||||
if (lowerSrc.includes('.flv') || lowerSrc.includes('flv?')) {
|
||||
return {
|
||||
protocol: 'rtmp', // Use RTMP player for FLV files
|
||||
isLive: lowerSrc.includes('/live/') || lowerSrc.includes('live.flv'),
|
||||
needsSpecialPlayer: true,
|
||||
}
|
||||
}
|
||||
|
||||
// Native HTML5 video formats (MP4, WebM, OGG, etc.)
|
||||
return {
|
||||
protocol: 'native',
|
||||
isLive: false,
|
||||
needsSpecialPlayer: false,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the URL is an RTMP stream
|
||||
* @param src - The video source URL
|
||||
* @returns True if RTMP stream
|
||||
*/
|
||||
export const isRtmpStream = (src: string): boolean => {
|
||||
const detection = detectVideoProtocol(src)
|
||||
return detection.protocol === 'rtmp'
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the URL is an HLS stream
|
||||
* @param src - The video source URL
|
||||
* @returns True if HLS stream
|
||||
*/
|
||||
export const isHlsStream = (src: string): boolean => {
|
||||
const detection = detectVideoProtocol(src)
|
||||
return detection.protocol === 'hls'
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the stream is live
|
||||
* @param src - The video source URL
|
||||
* @returns True if live stream
|
||||
*/
|
||||
export const isLiveStream = (src: string): boolean => {
|
||||
const detection = detectVideoProtocol(src)
|
||||
return detection.isLive
|
||||
}
|
||||
Reference in New Issue
Block a user