Fix TypeScript ref typings and lint errors
This commit is contained in:
@@ -32,8 +32,8 @@ export const ControlsLayer: React.FC<ControlsLayerProps> = ({
|
|||||||
usePlayerContext()
|
usePlayerContext()
|
||||||
const [isPointerOver, setIsPointerOver] = useState(false)
|
const [isPointerOver, setIsPointerOver] = useState(false)
|
||||||
const [lastInteraction, setLastInteraction] = useState<number>(0)
|
const [lastInteraction, setLastInteraction] = useState<number>(0)
|
||||||
const hideTimeoutRef = useRef<number>()
|
const hideTimeoutRef = useRef<number | undefined>(undefined)
|
||||||
const containerRef = useRef<HTMLDivElement>(null)
|
const containerRef = useRef<HTMLDivElement | null>(null)
|
||||||
const lastClickTimeRef = useRef<number>(0)
|
const lastClickTimeRef = useRef<number>(0)
|
||||||
const isMenuOpen =
|
const isMenuOpen =
|
||||||
uiState.settingsOpen ||
|
uiState.settingsOpen ||
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import './VolumeControl.css'
|
|||||||
export const VolumeControl: React.FC = () => {
|
export const VolumeControl: React.FC = () => {
|
||||||
const { videoState, setVolume, toggleMute } = usePlayerContext()
|
const { videoState, setVolume, toggleMute } = usePlayerContext()
|
||||||
const [showSlider, setShowSlider] = useState(false)
|
const [showSlider, setShowSlider] = useState(false)
|
||||||
const timeoutRef = useRef<number>()
|
const timeoutRef = useRef<number | undefined>(undefined)
|
||||||
|
|
||||||
const handleMouseEnter = useCallback(() => {
|
const handleMouseEnter = useCallback(() => {
|
||||||
if (timeoutRef.current) {
|
if (timeoutRef.current) {
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ export const PlayerProvider: React.FC<PlayerProviderProps> = ({
|
|||||||
initialMuted = false,
|
initialMuted = false,
|
||||||
initialPlaybackRate = 1,
|
initialPlaybackRate = 1,
|
||||||
}) => {
|
}) => {
|
||||||
const videoRef = useRef<HTMLVideoElement>(null)
|
const videoRef = useRef<HTMLVideoElement | null>(null)
|
||||||
const containerRef = useRef<HTMLDivElement>(null)
|
const containerRef = useRef<HTMLDivElement | null>(null)
|
||||||
|
|
||||||
const [videoState, setVideoState] = useState<VideoState>({
|
const [videoState, setVideoState] = useState<VideoState>({
|
||||||
playing: false,
|
playing: false,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, RefObject } from 'react'
|
import { useEffect, MutableRefObject } from 'react'
|
||||||
import { usePlayerContext } from '../contexts/PlayerContext'
|
import { usePlayerContext } from '../contexts/PlayerContext'
|
||||||
|
|
||||||
interface TouchData {
|
interface TouchData {
|
||||||
@@ -9,7 +9,7 @@ interface TouchData {
|
|||||||
tapCount: number
|
tapCount: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useTouchGestures = (containerRef: RefObject<HTMLDivElement>) => {
|
export const useTouchGestures = (containerRef: MutableRefObject<HTMLDivElement | null>) => {
|
||||||
const { videoState, togglePlay, seek, setVolume } = usePlayerContext()
|
const { videoState, togglePlay, seek, setVolume } = usePlayerContext()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
import type { CSSProperties, RefObject } from 'react'
|
import type { CSSProperties, MutableRefObject } from 'react'
|
||||||
|
|
||||||
export interface SubtitleTrack {
|
export interface SubtitleTrack {
|
||||||
src: string
|
src: string
|
||||||
@@ -87,8 +87,8 @@ export interface PlayerContextValue {
|
|||||||
videoState: VideoState
|
videoState: VideoState
|
||||||
uiState: UIState
|
uiState: UIState
|
||||||
settings: PlayerSettings
|
settings: PlayerSettings
|
||||||
videoRef: RefObject<HTMLVideoElement>
|
videoRef: MutableRefObject<HTMLVideoElement | null>
|
||||||
containerRef: RefObject<HTMLDivElement>
|
containerRef: MutableRefObject<HTMLDivElement | null>
|
||||||
|
|
||||||
// Video controls
|
// Video controls
|
||||||
play: () => void
|
play: () => void
|
||||||
@@ -109,7 +109,7 @@ export interface PlayerContextValue {
|
|||||||
toggleSettings: () => void
|
toggleSettings: () => void
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
setQuality: (quality: VideoQuality) => void
|
setQuality: (quality: VideoQuality | null) => void
|
||||||
setSubtitle: (subtitle: SubtitleTrack | null) => void
|
setSubtitle: (subtitle: SubtitleTrack | null) => void
|
||||||
setAudioTrack: (audioTrack: AudioTrack | null) => void
|
setAudioTrack: (audioTrack: AudioTrack | null) => void
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,12 +46,12 @@ export const loadHls = async (): Promise<any> => {
|
|||||||
// Try loading from npm package first
|
// Try loading from npm package first
|
||||||
const hlsModule = await import('hls.js')
|
const hlsModule = await import('hls.js')
|
||||||
return hlsModule.default
|
return hlsModule.default
|
||||||
} catch (npmError) {
|
} catch {
|
||||||
try {
|
try {
|
||||||
// Fallback to CDN
|
// Fallback to CDN
|
||||||
const Hls = await loadHlsFromCDN()
|
const Hls = await loadHlsFromCDN()
|
||||||
return Hls
|
return Hls
|
||||||
} catch (cdnError) {
|
} catch {
|
||||||
throw new Error('Unable to load HLS.js library. HLS streaming is not available.')
|
throw new Error('Unable to load HLS.js library. HLS streaming is not available.')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ export const getHlsAudioTracks = (hls: any): AudioTrack[] => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return audioTracks
|
return audioTracks
|
||||||
} catch (error) {
|
} catch {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user