mirror of
https://github.com/mediacms-io/mediacms.git
synced 2026-01-20 15:22:58 -05:00
feat: add linkTitle options to embed player
- Added 'linkTitle' to toggle between clickable and
This commit is contained in:
@@ -17,6 +17,7 @@ class EmbedInfoOverlay extends Component {
|
||||
this.showTitle = options.showTitle !== undefined ? options.showTitle : true;
|
||||
this.showRelated = options.showRelated !== undefined ? options.showRelated : true;
|
||||
this.showUserAvatar = options.showUserAvatar !== undefined ? options.showUserAvatar : true;
|
||||
this.linkTitle = options.linkTitle !== undefined ? options.linkTitle : true;
|
||||
|
||||
// Initialize after player is ready
|
||||
this.player().ready(() => {
|
||||
@@ -136,7 +137,7 @@ class EmbedInfoOverlay extends Component {
|
||||
overflow: hidden;
|
||||
`;
|
||||
|
||||
if (this.videoUrl) {
|
||||
if (this.videoUrl && this.linkTitle) {
|
||||
const titleLink = document.createElement('a');
|
||||
titleLink.href = this.videoUrl;
|
||||
titleLink.target = '_blank';
|
||||
|
||||
@@ -170,7 +170,7 @@ const enableStandardButtonTooltips = (player) => {
|
||||
}, 500); // Delay to ensure all components are ready
|
||||
};
|
||||
|
||||
function VideoJSPlayer({ videoId = 'default-video', showTitle = true, showRelated = true, showUserAvatar = true }) {
|
||||
function VideoJSPlayer({ videoId = 'default-video', showTitle = true, showRelated = true, showUserAvatar = true, linkTitle = true }) {
|
||||
const videoRef = useRef(null);
|
||||
const playerRef = useRef(null); // Track the player instance
|
||||
const userPreferences = useRef(new UserPreferences()); // User preferences instance
|
||||
@@ -221,10 +221,23 @@ function VideoJSPlayer({ videoId = 'default-video', showTitle = true, showRelate
|
||||
return showUserAvatar;
|
||||
}, [isEmbedPlayer, showUserAvatar]);
|
||||
|
||||
// Read linkTitle from URL parameter if available (for embed players)
|
||||
const getLinkTitleFromURL = useMemo(() => {
|
||||
if (isEmbedPlayer && typeof window !== 'undefined') {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const urlLinkTitle = urlParams.get('linkTitle');
|
||||
if (urlLinkTitle !== null) {
|
||||
return urlLinkTitle === '1' || urlLinkTitle === 'true';
|
||||
}
|
||||
}
|
||||
return linkTitle;
|
||||
}, [isEmbedPlayer, linkTitle]);
|
||||
|
||||
// Use URL parameter value if available, otherwise use prop value
|
||||
const finalShowTitle = isEmbedPlayer ? getShowTitleFromURL : showTitle;
|
||||
const finalShowRelated = isEmbedPlayer ? getShowRelatedFromURL : showRelated;
|
||||
const finalShowUserAvatar = isEmbedPlayer ? getShowUserAvatarFromURL : showUserAvatar;
|
||||
const finalLinkTitle = isEmbedPlayer ? getLinkTitleFromURL : linkTitle;
|
||||
|
||||
// Utility function to detect touch devices
|
||||
const isTouchDevice = useMemo(() => {
|
||||
@@ -1332,6 +1345,7 @@ function VideoJSPlayer({ videoId = 'default-video', showTitle = true, showRelate
|
||||
goToNextVideo,
|
||||
showRelated: finalShowRelated,
|
||||
showUserAvatar: finalShowUserAvatar,
|
||||
linkTitle: finalLinkTitle,
|
||||
});
|
||||
customComponents.current.endScreenHandler = endScreenHandler; // Store for cleanup
|
||||
|
||||
@@ -2254,6 +2268,7 @@ function VideoJSPlayer({ videoId = 'default-video', showTitle = true, showRelate
|
||||
showTitle: finalShowTitle,
|
||||
showRelated: finalShowRelated,
|
||||
showUserAvatar: finalShowUserAvatar,
|
||||
linkTitle: finalLinkTitle,
|
||||
});
|
||||
}
|
||||
// END: Add Embed Info Overlay Component
|
||||
|
||||
@@ -72,6 +72,7 @@ export class EndScreenHandler {
|
||||
goToNextVideo,
|
||||
showRelated,
|
||||
showUserAvatar,
|
||||
linkTitle,
|
||||
} = this.options;
|
||||
|
||||
// For embed players, show big play button when video ends
|
||||
|
||||
Reference in New Issue
Block a user