mirror of
https://github.com/mediacms-io/mediacms.git
synced 2025-11-09 17:08:58 -05:00
feat: Check if this is an embed player (disable next video and autoplay features)
This commit is contained in:
parent
5066f60c00
commit
d702689a0c
@ -7,7 +7,12 @@
|
|||||||
<title>VideoJS</title>
|
<title>VideoJS</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<h1>Main Video Player</h1>
|
||||||
<div id="video-js-root-main"></div>
|
<div id="video-js-root-main"></div>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<h1>Embed Video Player</h1>
|
||||||
<div id="video-js-root-embed"></div>
|
<div id="video-js-root-embed"></div>
|
||||||
|
|
||||||
<script type="module" src="/src/main.jsx"></script>
|
<script type="module" src="/src/main.jsx"></script>
|
||||||
|
|||||||
@ -21,11 +21,11 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
|
|||||||
const userPreferences = useRef(new UserPreferences()); // User preferences instance
|
const userPreferences = useRef(new UserPreferences()); // User preferences instance
|
||||||
const customComponents = useRef({}); // Store custom components for cleanup
|
const customComponents = useRef({}); // Store custom components for cleanup
|
||||||
|
|
||||||
/* const isDevelopment =
|
// Check if this is an embed player (disable next video and autoplay features)
|
||||||
process.env.NODE_ENV === 'development' ||
|
const isEmbedPlayer = videoId === 'video-embed';
|
||||||
window.location.hostname === 'localhost' ||
|
|
||||||
window.location.hostname.includes('vercel.app'); */
|
const enableDevEnvironment = true;
|
||||||
const isDevelopment = false;
|
const isDevelopment = enableDevEnvironment || window.location.hostname.includes('vercel.app');
|
||||||
console.log('isDevelopment', isDevelopment);
|
console.log('isDevelopment', isDevelopment);
|
||||||
console.log('window.location.hostname', window.location.hostname);
|
console.log('window.location.hostname', window.location.hostname);
|
||||||
|
|
||||||
@ -1841,7 +1841,7 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
|
|||||||
// END: Implement custom time display component
|
// END: Implement custom time display component
|
||||||
|
|
||||||
// BEGIN: Implement custom next video button
|
// BEGIN: Implement custom next video button
|
||||||
if (mediaData?.nextLink || 1 === 1) {
|
if (!isEmbedPlayer && (mediaData?.nextLink || isDevelopment)) {
|
||||||
// it seems that the nextLink is not always available, and it is need the this.player().trigger('nextVideo'); from NextVideoButton.js // TODO: remove the 1===1 and the mediaData?.nextLink
|
// it seems that the nextLink is not always available, and it is need the this.player().trigger('nextVideo'); from NextVideoButton.js // TODO: remove the 1===1 and the mediaData?.nextLink
|
||||||
const nextVideoButton = new NextVideoButton(playerRef.current, {
|
const nextVideoButton = new NextVideoButton(playerRef.current, {
|
||||||
nextLink: mediaData.nextLink,
|
nextLink: mediaData.nextLink,
|
||||||
@ -1852,6 +1852,7 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
|
|||||||
// END: Implement custom next video button
|
// END: Implement custom next video button
|
||||||
|
|
||||||
// BEGIN: Implement autoplay toggle button - simplified
|
// BEGIN: Implement autoplay toggle button - simplified
|
||||||
|
if (!isEmbedPlayer) {
|
||||||
try {
|
try {
|
||||||
const autoplayToggleButton = new AutoplayToggleButton(playerRef.current, {
|
const autoplayToggleButton = new AutoplayToggleButton(playerRef.current, {
|
||||||
userPreferences: userPreferences.current,
|
userPreferences: userPreferences.current,
|
||||||
@ -1873,6 +1874,7 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('✗ Failed to add autoplay toggle button:', error);
|
console.error('✗ Failed to add autoplay toggle button:', error);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// END: Implement autoplay toggle button
|
// END: Implement autoplay toggle button
|
||||||
|
|
||||||
// Remove duplicate captions button and move chapters to end
|
// Remove duplicate captions button and move chapters to end
|
||||||
@ -2528,8 +2530,9 @@ function VideoJSPlayer({ videoId = 'default-video' }) {
|
|||||||
|
|
||||||
console.log('isAutoplayEnabled', isAutoplayEnabled);
|
console.log('isAutoplayEnabled', isAutoplayEnabled);
|
||||||
console.log('hasNextVideo', hasNextVideo);
|
console.log('hasNextVideo', hasNextVideo);
|
||||||
|
console.log('isEmbedPlayer', isEmbedPlayer);
|
||||||
|
|
||||||
if (isAutoplayEnabled && hasNextVideo) {
|
if (!isEmbedPlayer && isAutoplayEnabled && hasNextVideo) {
|
||||||
// Get next video data for countdown display - find the next video in related videos
|
// Get next video data for countdown display - find the next video in related videos
|
||||||
let nextVideoData = {
|
let nextVideoData = {
|
||||||
title: 'Next Video',
|
title: 'Next Video',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user