js/utils.js
Utility functions for video playback, UI toggles, loader management, and video player enhancements.
Methods
(static) closeVideo()
Closes the video overlay and stops playback.
(static) hardenPlayerControls()
Enhances video player controls to prevent downloading and remote playback.
(static) hideLoader()
Hides the loading spinner with a fade-out effect.
(static) initPlayerPersistence()
Initializes video player progress persistence.
(static) playVideo(src, context)
Plays a video in the overlay player with optional watch context.
Parameters:
| Name | Type | Description |
|---|---|---|
src |
string | The video source URL. |
context |
Object | null | Optional playback context {type, title, season, episodeIndex}. |
(static) showLoader()
Shows the loading spinner.
(static) toggleMobileMenu()
Toggles the mobile menu visibility.
(static) toggleMobileSearch()
Toggles the mobile search panel visibility.
(static) toggleNotifs()
Toggles the notifications dropdown visibility.
(inner) applyStartTime(player, startTime)
Applies a saved start time (resume) when metadata is available.
Parameters:
| Name | Type | Description |
|---|---|---|
player |
HTMLVideoElement | The video player element. |
startTime |
number | Time in seconds to seek to. |
(inner) cleanupCustomVideoControls()
Cleans up custom video controls event listeners
(inner) formatTime(seconds) → {string}
Formats time in seconds to MM:SS or HH:MM:SS
Parameters:
| Name | Type | Description |
|---|---|---|
seconds |
number | Time in seconds |
Returns:
Formatted time string
- Type
- string
(inner) handleKeyboardControls(e)
Handles keyboard controls
Parameters:
| Name | Type | Description |
|---|---|---|
e |
KeyboardEvent | Keyboard event |
(inner) hideControls()
Hides video controls
(inner) initCustomVideoControls()
Initializes all custom video player controls
(inner) persistGenericProgress(player)
Persists video playback progress to localStorage (fallback when no context is provided).
Parameters:
| Name | Type | Description |
|---|---|---|
player |
HTMLVideoElement | The video player element. |
(inner) progressKey(src) → {string}
Generates a unique key for storing video progress in localStorage.
Parameters:
| Name | Type | Description |
|---|---|---|
src |
string | The video source URL. |
Returns:
The generated storage key.
- Type
- string
(inner) resetControlsTimeout()
Resets the auto-hide timeout for controls
(inner) seekToPosition(e)
Seeks to clicked position on progress bar
Parameters:
| Name | Type | Description |
|---|---|---|
e |
MouseEvent | Click event |
(inner) showControls()
Shows video controls
(inner) showTimeTooltip(e)
Shows time tooltip on progress bar hover
Parameters:
| Name | Type | Description |
|---|---|---|
e |
MouseEvent | Mouse event |
(inner) toggleFullscreen()
Toggles fullscreen mode
(inner) toggleMute()
Toggles mute state
(inner) togglePlayPause()
Toggles play/pause state
(inner) updateBufferedProgress()
Updates buffered progress bar
(inner) updatePlayPauseIcon(isPaused)
Updates play/pause button icon
Parameters:
| Name | Type | Description |
|---|---|---|
isPaused |
boolean | Whether video is paused |
(inner) updateProgress()
Updates progress bar and time display
(inner) updateVideoTitle(context)
Updates the video title overlay based on context
Parameters:
| Name | Type | Description |
|---|---|---|
context |
Object | null | Video context {type, title, season, episodeIndex, episodeTitle} |
(inner) updateVolumeIcon(volume)
Updates volume icon based on volume level
Parameters:
| Name | Type | Description |
|---|---|---|
volume |
number | Volume level (0-1) |
(inner) updateVolumeSliderBackground(value)
Updates volume slider background gradient
Parameters:
| Name | Type | Description |
|---|---|---|
value |
number | Slider value (0-100) |