mirror of
https://github.com/mediacms-io/mediacms.git
synced 2025-11-09 17:08:58 -05:00
Refactor control and progress bar styling logic
Removed unnecessary setTimeouts for applying control bar and progress bar styles, applying them synchronously instead. Updated playerConfig to set nonTouchPosition to 'top' and touchPosition to 'bottom'. Added initial sync for progress bar visibility.
This commit is contained in:
parent
657bd190db
commit
9896eb0376
@ -2491,7 +2491,6 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
|
|||||||
const seekBar = progressControl?.getChild('seekBar');
|
const seekBar = progressControl?.getChild('seekBar');
|
||||||
|
|
||||||
// BEGIN: Apply control bar styling from config (always applied)
|
// BEGIN: Apply control bar styling from config (always applied)
|
||||||
setTimeout(() => {
|
|
||||||
const controlBarEl = controlBar?.el();
|
const controlBarEl = controlBar?.el();
|
||||||
if (controlBarEl) {
|
if (controlBarEl) {
|
||||||
// Style control bar using config values
|
// Style control bar using config values
|
||||||
@ -2505,14 +2504,11 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
|
|||||||
timeControl.style.lineHeight = `${PlayerConfig.controlBar.height}em`;
|
timeControl.style.lineHeight = `${PlayerConfig.controlBar.height}em`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, 100);
|
|
||||||
// END: Apply control bar styling from config
|
// END: Apply control bar styling from config
|
||||||
|
|
||||||
// BEGIN: Apply progress bar colors from config (always applied)
|
// BEGIN: Apply progress bar colors from config (always applied)
|
||||||
setTimeout(() => {
|
|
||||||
const progressControl = playerRef.current.getChild('controlBar')?.getChild('progressControl');
|
|
||||||
const progressEl = progressControl?.el();
|
const progressEl = progressControl?.el();
|
||||||
|
console.log('progressEl', progressEl);
|
||||||
if (progressEl) {
|
if (progressEl) {
|
||||||
// Style the progress holder and bars with config colors
|
// Style the progress holder and bars with config colors
|
||||||
const progressHolder = progressEl.querySelector('.vjs-progress-holder');
|
const progressHolder = progressEl.querySelector('.vjs-progress-holder');
|
||||||
@ -2523,6 +2519,7 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
|
|||||||
// Style the play progress bar (the filled part)
|
// Style the play progress bar (the filled part)
|
||||||
const playProgress = progressEl.querySelector('.vjs-play-progress');
|
const playProgress = progressEl.querySelector('.vjs-play-progress');
|
||||||
if (playProgress) {
|
if (playProgress) {
|
||||||
|
console.log('playProgress', playProgress);
|
||||||
playProgress.style.backgroundColor = PlayerConfig.progressBar.color;
|
playProgress.style.backgroundColor = PlayerConfig.progressBar.color;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2532,7 +2529,6 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
|
|||||||
loadProgress.style.backgroundColor = PlayerConfig.progressBar.bufferColor;
|
loadProgress.style.backgroundColor = PlayerConfig.progressBar.bufferColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 150);
|
|
||||||
// END: Apply progress bar colors from config
|
// END: Apply progress bar colors from config
|
||||||
|
|
||||||
// Determine the actual position based on device type and config
|
// Determine the actual position based on device type and config
|
||||||
@ -2549,8 +2545,8 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
|
|||||||
const actualPosition = getActualPosition();
|
const actualPosition = getActualPosition();
|
||||||
|
|
||||||
// BEGIN: Move progress bar below control bar (native touch style)
|
// BEGIN: Move progress bar below control bar (native touch style)
|
||||||
if (actualPosition === 'bottom' || actualPosition === 'top') {
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
if (actualPosition === 'bottom' || actualPosition === 'top') {
|
||||||
if (progressControl && progressControl.el() && controlBar && controlBar.el()) {
|
if (progressControl && progressControl.el() && controlBar && controlBar.el()) {
|
||||||
const progressEl = progressControl.el();
|
const progressEl = progressControl.el();
|
||||||
const controlBarEl = controlBar.el();
|
const controlBarEl = controlBar.el();
|
||||||
@ -2619,6 +2615,8 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
|
|||||||
playerRef.current.on('useractive', syncProgressVisibility);
|
playerRef.current.on('useractive', syncProgressVisibility);
|
||||||
playerRef.current.on('userinactive', syncProgressVisibility);
|
playerRef.current.on('userinactive', syncProgressVisibility);
|
||||||
|
|
||||||
|
// Initial sync
|
||||||
|
syncProgressVisibility();
|
||||||
// Initial sync - hide until video starts
|
// Initial sync - hide until video starts
|
||||||
progressEl.style.opacity = '0';
|
progressEl.style.opacity = '0';
|
||||||
progressEl.style.visibility = 'hidden';
|
progressEl.style.visibility = 'hidden';
|
||||||
@ -2638,8 +2636,8 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
|
|||||||
playerRef.current.off('userinactive', syncProgressVisibility);
|
playerRef.current.off('userinactive', syncProgressVisibility);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}, 100);
|
|
||||||
}
|
}
|
||||||
|
}, 100);
|
||||||
|
|
||||||
// END: Move progress bar below control bar
|
// END: Move progress bar below control bar
|
||||||
|
|
||||||
|
|||||||
@ -12,12 +12,12 @@ const PlayerConfig = {
|
|||||||
// 'default' - use Video.js default positioning (inside control bar)
|
// 'default' - use Video.js default positioning (inside control bar)
|
||||||
// 'top' - progress bar above control bar
|
// 'top' - progress bar above control bar
|
||||||
// 'bottom' - progress bar below control bar
|
// 'bottom' - progress bar below control bar
|
||||||
nonTouchPosition: 'default',
|
nonTouchPosition: 'top',
|
||||||
|
|
||||||
// Position for touch devices: 'top' or 'bottom' (no 'default' option)
|
// Position for touch devices: 'top' or 'bottom' (no 'default' option)
|
||||||
// 'top' - progress bar above control bar
|
// 'top' - progress bar above control bar
|
||||||
// 'bottom' - progress bar below control bar (native touch style)
|
// 'bottom' - progress bar below control bar (native touch style)
|
||||||
touchPosition: 'top',
|
touchPosition: 'bottom',
|
||||||
|
|
||||||
// Progress bar color (hex, rgb, or CSS color name)
|
// Progress bar color (hex, rgb, or CSS color name)
|
||||||
color: '#019932',
|
color: '#019932',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user