Skip to content

Commit ed41004

Browse files
authored
Merge pull request #264 from ahasnawi/default-youtube-controllers
Youtube Default Controllers
2 parents 7e903b1 + f6fa064 commit ed41004

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

widget/services.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,13 +608,21 @@
608608
title="${item.title}"
609609
></video>`;
610610

611-
vidPlayer = videojs(videoId, {
611+
// Detect if the video is a YouTube URL
612+
const isYouTube = /^(?:https?:\/\/)?(?:www\.)?(youtube\.com|youtu\.be)(\/|$)/i.test(item.videoUrl);
613+
const videoJsOptions = {
612614
muted: false,
613615
playsinline: true,
614-
controls: true,
616+
controls: !isYouTube,
615617
techOrder: ["html5", "youtube", "vimeo"],
616-
enableDocumentPictureInPicture: true,
617-
});
618+
enableDocumentPictureInPicture: true
619+
};
620+
if (isYouTube) {
621+
videoJsOptions.youtube = {
622+
ytControls: 1,
623+
};
624+
}
625+
vidPlayer = videojs(videoId, videoJsOptions);
618626

619627
addNextPreviousButtons();
620628
addOverlayPlayButton();

0 commit comments

Comments
 (0)