Keep poster visible for audio embeds and update track handling

Ensures the poster image remains visible during playback for audio files in embed players by updating both JavaScript logic and CSS. Also updates subtitle track handling to set the default track and adjusts Video.js player configuration for better control over native and emulated tracks.
This commit is contained in:
Yiannis Christodoulou 2025-10-17 14:05:38 +03:00
parent 55c701e055
commit 2a12fec89e
2 changed files with 40 additions and 10 deletions

View File

@ -1849,7 +1849,7 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
src: '/sample-subtitles.vtt', src: '/sample-subtitles.vtt',
srclang: 'en', srclang: 'en',
label: 'English Subtitles', label: 'English Subtitles',
default: false, default: true,
}, },
{ {
kind: 'subtitles', kind: 'subtitles',
@ -1870,7 +1870,7 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
src: track.src, src: track.src,
srclang: track.srclang, srclang: track.srclang,
label: track.label, label: track.label,
default: false, default: track.default || false,
})) }))
: []; : [];
@ -2150,16 +2150,17 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
nativeControlsForTouch: PlayerConfig.nativeControlsForTouch, nativeControlsForTouch: PlayerConfig.nativeControlsForTouch,
// Use native audio tracks instead of emulated - disabled for consistency // Use native audio tracks instead of emulated - disabled for consistency
nativeAudioTracks: true, nativeAudioTracks: false,
// Use native text tracks instead of emulated - disabled for consistency // Use Video.js text tracks for full positioning control on mobile
nativeTextTracks: true, // Native tracks don't allow CSS positioning control
nativeTextTracks: isTouchDevice,
// Use native video tracks instead of emulated - disabled for consistency // Use native video tracks instead of emulated - disabled for consistency
nativeVideoTracks: true, nativeVideoTracks: false,
// Preload text tracks // Preload text tracks
preloadTextTracks: true, preloadTextTracks: false,
// Play inline // Play inline
playsinline: true, playsinline: true,
@ -2189,9 +2190,28 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
userPreferences.current.setupAutoSave(playerRef.current); userPreferences.current.setupAutoSave(playerRef.current);
// Add class for audio files to enable audio-specific styling // Add class for audio files to enable audio-specific styling
console.log('mediaData.media_type', mediaData.data?.media_type);
if (mediaData.data?.media_type === 'audio') { if (mediaData.data?.media_type === 'audio') {
playerRef.current.addClass('vjs-audio-type'); playerRef.current.addClass('vjs-audio-type');
// For embed players, ensure poster stays visible during playback
if (isEmbedPlayer) {
const ensurePosterVisible = () => {
const posterEl = playerRef.current.el().querySelector('.vjs-poster');
if (posterEl) {
posterEl.style.display = 'block';
posterEl.style.opacity = '1';
posterEl.style.visibility = 'visible';
}
};
// Keep poster visible on all play events
playerRef.current.on('play', ensurePosterVisible);
playerRef.current.on('playing', ensurePosterVisible);
playerRef.current.on('timeupdate', ensurePosterVisible);
// Initial call
setTimeout(ensurePosterVisible, 200);
}
} }
// Enable tooltips for all standard VideoJS buttons // Enable tooltips for all standard VideoJS buttons
@ -3939,7 +3959,7 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
</p> </p>
{/* Add subtitle tracks */} {/* Add subtitle tracks */}
{/* {subtitleTracks && {subtitleTracks &&
subtitleTracks.map((track, index) => ( subtitleTracks.map((track, index) => (
<track <track
key={index} key={index}
@ -3950,7 +3970,7 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
default={track.default} default={track.default}
/> />
))} ))}
{/*
<track kind="chapters" src="/sample-chapters.vtt" /> */} <track kind="chapters" src="/sample-chapters.vtt" /> */}
{/* Add chapters track */} {/* Add chapters track */}
{/* {chaptersData && {/* {chaptersData &&

View File

@ -18,6 +18,16 @@
background-color: #000 !important; background-color: #000 !important;
} }
/* Keep poster visible even when playing for audio files */
#page-embed .video-js-root-embed .video-js.vjs-audio-type .vjs-poster,
#page-embed .video-js-root-embed .video-js.vjs-audio-poster-mode .vjs-poster,
#page-embed .video-js-root-embed .video-js.vjs-has-started.vjs-audio-type .vjs-poster,
#page-embed .video-js-root-embed .video-js.vjs-playing.vjs-audio-type .vjs-poster {
display: block !important;
opacity: 1 !important;
visibility: visible !important;
}
/* Fullscreen video element - maintain aspect ratio */ /* Fullscreen video element - maintain aspect ratio */
#page-embed .video-js-root-embed .video-js video { #page-embed .video-js-root-embed .video-js video {
position: absolute !important; position: absolute !important;