Skip to content

Commit 5d5f0b2

Browse files
authored
Merge pull request #774 from 0gust1/feat/youtube_playlists
fix: (and improve) YouTube component behavior with playlist
2 parents c534e49 + 07e382f commit 5d5f0b2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/sveltekit-embed/src/lib/components/you-tube.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
interface Props {
66
youTubeId?: string;
77
listId?: string;
8+
index?: number;
89
autoPlay?: boolean;
910
aspectRatio?: string;
1011
skipTo?: any;
@@ -15,6 +16,7 @@
1516
let {
1617
youTubeId = '',
1718
listId = '',
19+
index = 0,
1820
autoPlay = false,
1921
aspectRatio = '16:9',
2022
skipTo = { h: 0, m: 0, s: 0 },
@@ -37,7 +39,7 @@
3739
const src = `${baseUrl}${
3840
youTubeId.length > 0
3941
? `${youTubeId}?autoplay=${autoPlay}&start=${startTime}`
40-
: `?videoseries?list=${listId}`
42+
: `?videoseries&list=${listId}&index=${index}&autoplay=${autoPlay}&start=${startTime}`
4143
}`;
4244
</script>
4345

packages/sveltekit-embed/src/lib/components/you-tube.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('YouTube', () => {
4545
disable_observer: true,
4646
});
4747
const iframe = getByTitle(`youTube-${listId}`);
48-
const expectedSrc = `https://www.youtube-nocookie.com/embed/?videoseries?list=${listId}`;
48+
const expectedSrc = `https://www.youtube-nocookie.com/embed/?videoseries&list=${listId}&index=0&autoplay=false&start=0`;
4949
expect(iframe.getAttribute('src')).toBe(expectedSrc);
5050
});
5151

0 commit comments

Comments
 (0)