add vimeo embed
This commit is contained in:
@@ -418,6 +418,9 @@ describe('parseEmbedPlayerFromUrl', () => {
|
||||
'https://music.apple.com/us/playlist/playlistName/playlistId',
|
||||
'https://music.apple.com/us/album/albumName/albumId',
|
||||
'https://music.apple.com/us/album/albumName/albumId?i=songId',
|
||||
|
||||
'https://vimeo.com/videoId',
|
||||
'https://vimeo.com/videoId?autoplay=0',
|
||||
]
|
||||
|
||||
const outputs = [
|
||||
@@ -530,6 +533,17 @@ describe('parseEmbedPlayerFromUrl', () => {
|
||||
playerUri:
|
||||
'https://embed.music.apple.com/us/album/albumName/albumId?i=songId',
|
||||
},
|
||||
|
||||
{
|
||||
type: 'vimeo_video',
|
||||
videoId: 'videoId',
|
||||
playerUri: 'https://player.vimeo.com/video/videoId?autoplay=1',
|
||||
},
|
||||
{
|
||||
type: 'vimeo_video',
|
||||
videoId: 'videoId',
|
||||
playerUri: 'https://player.vimeo.com/video/videoId?autoplay=1',
|
||||
},
|
||||
]
|
||||
|
||||
it('correctly grabs the correct id from uri', () => {
|
||||
|
||||
@@ -15,6 +15,7 @@ export type EmbedPlayerParams =
|
||||
| {type: 'apple_music_playlist'; playlistId: string; playerUri: string}
|
||||
| {type: 'apple_music_album'; albumId: string; playerUri: string}
|
||||
| {type: 'apple_music_song'; songId: string; playerUri: string}
|
||||
| {type: 'vimeo_video'; videoId: string; playerUri: string}
|
||||
|
||||
export function parseEmbedPlayerFromUrl(
|
||||
url: string,
|
||||
@@ -158,6 +159,17 @@ export function parseEmbedPlayerFromUrl(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (urlp.hostname === 'vimeo.com' || urlp.hostname === 'www.vimeo.com') {
|
||||
const [_, videoId] = urlp.pathname.split('/')
|
||||
if (videoId) {
|
||||
return {
|
||||
type: 'vimeo_video',
|
||||
videoId,
|
||||
playerUri: `https://player.vimeo.com/video/${videoId}?autoplay=1`,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getPlayerHeight({
|
||||
@@ -174,6 +186,7 @@ export function getPlayerHeight({
|
||||
switch (type) {
|
||||
case 'youtube_video':
|
||||
case 'twitch_live':
|
||||
case 'vimeo_video':
|
||||
return (width / 16) * 9
|
||||
case 'spotify_album':
|
||||
return 380
|
||||
|
||||
Reference in New Issue
Block a user