Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match params for unlisted videos #43

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/vimeo-video-element/vimeo-video-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import VimeoPlayerAPI from '@vimeo/player/dist/player.es.js';

const EMBED_BASE = 'https://player.vimeo.com/video';
const MATCH_SRC = /vimeo\.com\/(?:video\/)?(\d+)/;
const MATCH_SRC = /vimeo\.com\/(?:video\/)?(\d+)(?:\/([\w-]+))?/;

function getTemplateHTML(attrs) {
const iframeAttrs = {
Expand Down Expand Up @@ -39,6 +39,7 @@ function serializeIframeUrl(attrs) {

const matches = attrs.src.match(MATCH_SRC);
const srcId = matches && matches[1];
const hParam = matches && matches[2];

const params = {
// ?controls=true is enabled by default in the iframe
Expand All @@ -50,6 +51,7 @@ function serializeIframeUrl(attrs) {
preload: attrs.preload ?? 'metadata',
transparent: false,
autopause: attrs.autopause,
h: hParam, // This param is required when the video is Unlisted.
};

return `${EMBED_BASE}/${srcId}?${serialize(params)}`;
Expand Down