Set start time on YouTube embeds (#2565)
* fix: set start time on yt embeds * fix: re-encode to be on the safe side * chore: fix embed testszio/stable
parent
0dfe740dd3
commit
4bd95b5ef2
|
@ -463,44 +463,44 @@ describe('parseEmbedPlayerFromUrl', () => {
|
|||
type: 'youtube_video',
|
||||
source: 'youtube',
|
||||
playerUri:
|
||||
'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1',
|
||||
'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0',
|
||||
},
|
||||
{
|
||||
type: 'youtube_video',
|
||||
source: 'youtube',
|
||||
playerUri:
|
||||
'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1',
|
||||
'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0',
|
||||
},
|
||||
{
|
||||
type: 'youtube_video',
|
||||
source: 'youtube',
|
||||
playerUri:
|
||||
'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1',
|
||||
'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0',
|
||||
},
|
||||
{
|
||||
type: 'youtube_video',
|
||||
source: 'youtube',
|
||||
playerUri:
|
||||
'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1',
|
||||
'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0',
|
||||
},
|
||||
{
|
||||
type: 'youtube_video',
|
||||
source: 'youtube',
|
||||
playerUri:
|
||||
'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1',
|
||||
'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0',
|
||||
},
|
||||
{
|
||||
type: 'youtube_short',
|
||||
source: 'youtubeShorts',
|
||||
hideDetails: true,
|
||||
playerUri:
|
||||
'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1',
|
||||
'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0',
|
||||
},
|
||||
{
|
||||
type: 'youtube_video',
|
||||
source: 'youtube',
|
||||
playerUri:
|
||||
'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1',
|
||||
'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0',
|
||||
},
|
||||
|
||||
undefined,
|
||||
|
|
|
@ -68,11 +68,12 @@ export function parseEmbedPlayerFromUrl(
|
|||
// youtube
|
||||
if (urlp.hostname === 'youtu.be') {
|
||||
const videoId = urlp.pathname.split('/')[1]
|
||||
const seek = encodeURIComponent(urlp.searchParams.get('t') ?? 0)
|
||||
if (videoId) {
|
||||
return {
|
||||
type: 'youtube_video',
|
||||
source: 'youtube',
|
||||
playerUri: `https://www.youtube.com/embed/${videoId}?autoplay=1&playsinline=1`,
|
||||
playerUri: `https://www.youtube.com/embed/${videoId}?autoplay=1&playsinline=1&start=${seek}`,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,13 +85,14 @@ export function parseEmbedPlayerFromUrl(
|
|||
const [_, page, shortVideoId] = urlp.pathname.split('/')
|
||||
const videoId =
|
||||
page === 'shorts' ? shortVideoId : (urlp.searchParams.get('v') as string)
|
||||
const seek = encodeURIComponent(urlp.searchParams.get('t') ?? 0)
|
||||
|
||||
if (videoId) {
|
||||
return {
|
||||
type: page === 'shorts' ? 'youtube_short' : 'youtube_video',
|
||||
source: page === 'shorts' ? 'youtubeShorts' : 'youtube',
|
||||
hideDetails: page === 'shorts' ? true : undefined,
|
||||
playerUri: `https://www.youtube.com/embed/${videoId}?autoplay=1&playsinline=1`,
|
||||
playerUri: `https://www.youtube.com/embed/${videoId}?autoplay=1&playsinline=1&start=${seek}`,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue