@@ -170,7 +170,7 @@ const enableStandardButtonTooltips = (player) => {
170170 } , 500 ) ; // Delay to ensure all components are ready
171171} ;
172172
173- function VideoJSPlayer ( { videoId = 'default-video' , showTitle = true , showRelated = true , showUserAvatar = true , linkTitle = true } ) {
173+ function VideoJSPlayer ( { videoId = 'default-video' , showTitle = true , showRelated = true , showUserAvatar = true , linkTitle = true , urlTimestamp = null } ) {
174174 const videoRef = useRef ( null ) ;
175175 const playerRef = useRef ( null ) ; // Track the player instance
176176 const userPreferences = useRef ( new UserPreferences ( ) ) ; // User preferences instance
@@ -185,76 +185,10 @@ function VideoJSPlayer({ videoId = 'default-video', showTitle = true, showRelate
185185 // Check if this is an embed player (disable next video and autoplay features)
186186 const isEmbedPlayer = videoId === 'video-embed' ;
187187
188- // Read showTitle from URL parameter if available (for embed players)
189- const getShowTitleFromURL = useMemo ( ( ) => {
190- if ( isEmbedPlayer && typeof window !== 'undefined' ) {
191- const urlParams = new URLSearchParams ( window . location . search ) ;
192- const urlShowTitle = urlParams . get ( 'showTitle' ) ;
193- if ( urlShowTitle !== null ) {
194- return urlShowTitle === '1' || urlShowTitle === 'true' ;
195- }
196- }
197- return showTitle ;
198- } , [ isEmbedPlayer , showTitle ] ) ;
199-
200- // Read showRelated from URL parameter if available (for embed players)
201- const getShowRelatedFromURL = useMemo ( ( ) => {
202- if ( isEmbedPlayer && typeof window !== 'undefined' ) {
203- const urlParams = new URLSearchParams ( window . location . search ) ;
204- const urlShowRelated = urlParams . get ( 'showRelated' ) ;
205- if ( urlShowRelated !== null ) {
206- return urlShowRelated === '1' || urlShowRelated === 'true' ;
207- }
208- }
209- return showRelated ;
210- } , [ isEmbedPlayer , showRelated ] ) ;
211-
212- // Read showUserAvatar from URL parameter if available (for embed players)
213- const getShowUserAvatarFromURL = useMemo ( ( ) => {
214- if ( isEmbedPlayer && typeof window !== 'undefined' ) {
215- const urlParams = new URLSearchParams ( window . location . search ) ;
216- const urlShowUserAvatar = urlParams . get ( 'showUserAvatar' ) ;
217- if ( urlShowUserAvatar !== null ) {
218- return urlShowUserAvatar === '1' || urlShowUserAvatar === 'true' ;
219- }
220- }
221- return showUserAvatar ;
222- } , [ isEmbedPlayer , showUserAvatar ] ) ;
223-
224- // Read linkTitle from URL parameter if available (for embed players)
225- const getLinkTitleFromURL = useMemo ( ( ) => {
226- if ( isEmbedPlayer && typeof window !== 'undefined' ) {
227- const urlParams = new URLSearchParams ( window . location . search ) ;
228- const urlLinkTitle = urlParams . get ( 'linkTitle' ) ;
229- if ( urlLinkTitle !== null ) {
230- return urlLinkTitle === '1' || urlLinkTitle === 'true' ;
231- }
232- }
233- return linkTitle ;
234- } , [ isEmbedPlayer , linkTitle ] ) ;
235-
236- // Use URL parameter value if available, otherwise use prop value
237- const finalShowTitle = isEmbedPlayer ? getShowTitleFromURL : showTitle ;
238- const finalShowRelated = isEmbedPlayer ? getShowRelatedFromURL : showRelated ;
239- const finalShowUserAvatar = isEmbedPlayer ? getShowUserAvatarFromURL : showUserAvatar ;
240- const finalLinkTitle = isEmbedPlayer ? getLinkTitleFromURL : linkTitle ;
241-
242- // Utility function to detect touch devices
243- const isTouchDevice = useMemo ( ( ) => {
244- return 'ontouchstart' in window || navigator . maxTouchPoints > 0 || navigator . msMaxTouchPoints > 0 ;
245- } , [ ] ) ;
246-
247- // Utility function to detect iOS devices
248- const isIOS = useMemo ( ( ) => {
249- return (
250- / i P a d | i P h o n e | i P o d / . test ( navigator . userAgent ) ||
251- ( navigator . platform === 'MacIntel' && navigator . maxTouchPoints > 1 )
252- ) ;
253- } , [ ] ) ;
254-
255188 // Environment-based development mode configuration
256189 const isDevMode = import . meta. env . VITE_DEV_MODE === 'true' || window . location . hostname . includes ( 'vercel.app' ) ;
257- // Safely access window.MEDIA_DATA with fallback using useMemo
190+
191+ // Read options from window.MEDIA_DATA if available (for consistency with embed logic)
258192 const mediaData = useMemo (
259193 ( ) =>
260194 typeof window !== 'undefined' && window . MEDIA_DATA
@@ -273,12 +207,37 @@ function VideoJSPlayer({ videoId = 'default-video', showTitle = true, showRelate
273207 } ,
274208 siteUrl : 'https://deic.mediacms.io' ,
275209 nextLink : 'https://deic.mediacms.io/view?m=elygiagorgechania' ,
276- urlAutoplay : true ,
277- urlMuted : false ,
278210 } ,
279211 [ ]
280212 ) ;
281213
214+ // Helper to get effective value (prop or MEDIA_DATA or default)
215+ const getOption = ( propKey , mediaDataKey , defaultValue ) => {
216+ if ( isEmbedPlayer ) {
217+ if ( mediaData [ mediaDataKey ] !== undefined ) return mediaData [ mediaDataKey ] ;
218+ }
219+ return propKey !== undefined ? propKey : defaultValue ;
220+ } ;
221+
222+ const finalShowTitle = getOption ( showTitle , 'showTitle' , true ) ;
223+ const finalShowRelated = getOption ( showRelated , 'showRelated' , true ) ;
224+ const finalShowUserAvatar = getOption ( showUserAvatar , 'showUserAvatar' , true ) ;
225+ const finalLinkTitle = getOption ( linkTitle , 'linkTitle' , true ) ;
226+ const finalTimestamp = getOption ( urlTimestamp , 'urlTimestamp' , null ) ;
227+
228+ // Utility function to detect touch devices
229+ const isTouchDevice = useMemo ( ( ) => {
230+ return 'ontouchstart' in window || navigator . maxTouchPoints > 0 || navigator . msMaxTouchPoints > 0 ;
231+ } , [ ] ) ;
232+
233+ // Utility function to detect iOS devices
234+ const isIOS = useMemo ( ( ) => {
235+ return (
236+ / i P a d | i P h o n e | i P o d / . test ( navigator . userAgent ) ||
237+ ( navigator . platform === 'MacIntel' && navigator . maxTouchPoints > 1 )
238+ ) ;
239+ } , [ ] ) ;
240+
282241 // Define chapters as JSON object
283242 // Note: The sample-chapters.vtt file is no longer needed as chapters are now loaded from this JSON
284243 // CONDITIONAL LOGIC:
@@ -590,8 +549,6 @@ function VideoJSPlayer({ videoId = 'default-video', showTitle = true, showRelate
590549 isPlayList : mediaData ?. isPlayList ,
591550 related_media : mediaData . data ?. related_media || [ ] ,
592551 nextLink : mediaData ?. nextLink || null ,
593- urlAutoplay : mediaData ?. urlAutoplay || true ,
594- urlMuted : mediaData ?. urlMuted || false ,
595552 sources : getVideoSources ( ) ,
596553 } ;
597554
@@ -1366,8 +1323,8 @@ function VideoJSPlayer({ videoId = 'default-video', showTitle = true, showRelate
13661323 }
13671324
13681325 // Handle URL timestamp parameter
1369- if ( mediaData . urlTimestamp !== null && mediaData . urlTimestamp >= 0 ) {
1370- const timestamp = mediaData . urlTimestamp ;
1326+ if ( finalTimestamp !== null && finalTimestamp >= 0 ) {
1327+ const timestamp = finalTimestamp ;
13711328
13721329 // Wait for video metadata to be loaded before seeking
13731330 if ( playerRef . current . readyState ( ) >= 1 ) {
@@ -2417,7 +2374,7 @@ function VideoJSPlayer({ videoId = 'default-video', showTitle = true, showRelate
24172374 ref = { videoRef }
24182375 id = { videoId }
24192376 controls = { true }
2420- className = { `video-js vjs-fluid vjs-default-skin${ currentVideo . useRoundedCorners ? ' video-js-rounded-corners' : '' } ` }
2377+ className = { `video-js ${ isEmbedPlayer ? ' vjs-fill' : 'vjs- fluid' } vjs-default-skin${ currentVideo . useRoundedCorners ? ' video-js-rounded-corners' : '' } ` }
24212378 preload = "auto"
24222379 poster = { currentVideo . poster }
24232380 tabIndex = "0"
0 commit comments