@playpilot/tpi 8.32.0 → 8.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editorial.mount.js +7 -7
- package/dist/link-injections.js +1 -1
- package/dist/mount.js +6 -6
- package/package.json +1 -1
- package/src/routes/components/Icons/IconFullscreen.svelte +3 -0
- package/src/routes/components/Rails/TitlesRail.svelte +1 -1
- package/src/routes/components/YouTubeEmbed.svelte +49 -14
- package/src/routes/components/YouTubeEmbedBackground.svelte +1 -1
- package/src/routes/elements/+page.svelte +1 -1
- package/src/tests/routes/components/YouTubeEmbed.test.js +8 -1
package/package.json
CHANGED
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
<div class="video-overlay" title="" {onclick}></div>
|
|
189
189
|
|
|
190
190
|
{#if !!title.embeddable_url}
|
|
191
|
-
<YouTubeEmbed bind:this={embed} embeddable_url={title.embeddable_url!} muted loop captions
|
|
191
|
+
<YouTubeEmbed bind:this={embed} embeddable_url={title.embeddable_url!} muted loop captions showActions />
|
|
192
192
|
{:else}
|
|
193
193
|
<img class="video-fallback" src={title.medium_poster} alt="" />
|
|
194
194
|
{/if}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { getVideoId } from '$lib/trailer'
|
|
3
3
|
import { onMount } from 'svelte'
|
|
4
4
|
import IconMute from './Icons/IconMute.svelte'
|
|
5
|
+
import IconFullscreen from './Icons/IconFullscreen.svelte'
|
|
5
6
|
|
|
6
7
|
interface Props {
|
|
7
8
|
embeddable_url: string
|
|
@@ -10,17 +11,18 @@
|
|
|
10
11
|
loop?: boolean
|
|
11
12
|
captions?: boolean
|
|
12
13
|
autoplay?: boolean
|
|
13
|
-
|
|
14
|
+
showActions?: boolean
|
|
14
15
|
fallbackStartTime?: number
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
let { embeddable_url = '', controls = [], muted = false, loop = false, captions = false, autoplay = true,
|
|
18
|
+
let { embeddable_url = '', controls = [], muted = false, loop = false, captions = false, autoplay = true, showActions = false, fallbackStartTime = 0 }: Props = $props()
|
|
18
19
|
|
|
19
20
|
const videoId = $derived(getVideoId(embeddable_url))
|
|
20
21
|
const startTime = $derived((window?.PlayPilotLinkInjections?.video_playtimes?.[videoId || ''] || (fallbackStartTime + 1)) - 1)
|
|
21
22
|
const color = window?.getComputedStyle(document.body).getPropertyValue('--playpilot-primary')?.replace('#', '') || 'fa548a'
|
|
22
23
|
|
|
23
24
|
let element: HTMLElement | null = $state(null)
|
|
25
|
+
let fullscreen: boolean = $state(false)
|
|
24
26
|
let player: any
|
|
25
27
|
|
|
26
28
|
onMount(() => {
|
|
@@ -45,11 +47,12 @@
|
|
|
45
47
|
element.style.setProperty('--plyr-color-main', '#' + color)
|
|
46
48
|
|
|
47
49
|
player = new window.Plyr(element, {
|
|
48
|
-
controls,
|
|
50
|
+
controls: controls.length === 0 ? ['play', 'mute', 'fullscreen', 'progress', 'current-time'] : controls,
|
|
49
51
|
playsinline: true,
|
|
50
52
|
autoplay,
|
|
51
53
|
muted,
|
|
52
54
|
clickToPlay: false,
|
|
55
|
+
storage: { enabled: false },
|
|
53
56
|
youtube: {
|
|
54
57
|
noCookie: true,
|
|
55
58
|
cc_load_policy: captions ? 1 : 0,
|
|
@@ -62,6 +65,16 @@
|
|
|
62
65
|
toggleMute(muted)
|
|
63
66
|
})
|
|
64
67
|
|
|
68
|
+
player.on('enterfullscreen', () => {
|
|
69
|
+
fullscreen = true
|
|
70
|
+
toggleMute(false)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
player.on('exitfullscreen', () => {
|
|
74
|
+
fullscreen = false
|
|
75
|
+
toggleMute(true)
|
|
76
|
+
})
|
|
77
|
+
|
|
65
78
|
if (!loop) return
|
|
66
79
|
|
|
67
80
|
player.on('statechange', (event: { detail: { code: number } }) => {
|
|
@@ -75,10 +88,9 @@
|
|
|
75
88
|
}
|
|
76
89
|
|
|
77
90
|
export function toggleMute(state = !muted): void {
|
|
78
|
-
player.muted = state
|
|
79
|
-
player.volume = muted ? 0 : 1
|
|
80
|
-
|
|
81
91
|
muted = state
|
|
92
|
+
player.muted = state
|
|
93
|
+
player.volume = state ? 0 : 1
|
|
82
94
|
}
|
|
83
95
|
|
|
84
96
|
export function play(event: CustomEvent): void {
|
|
@@ -100,13 +112,19 @@
|
|
|
100
112
|
</svelte:head>
|
|
101
113
|
|
|
102
114
|
{#if videoId}
|
|
103
|
-
<div
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
<
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
<div class:fullscreen class:hide-controls={controls.length === 0 && !fullscreen}>
|
|
116
|
+
<div bind:this={element} class="player" data-plyr-provider="youtube" data-plyr-embed-id data-testid={embeddable_url}></div>
|
|
117
|
+
|
|
118
|
+
{#if showActions}
|
|
119
|
+
<button class="action" onclick={() => toggleMute()} aria-label="Mute">
|
|
120
|
+
<IconMute {muted} />
|
|
121
|
+
</button>
|
|
122
|
+
|
|
123
|
+
<button class="action secondary" onclick={() => player.fullscreen.enter()} aria-label="Fullscreen">
|
|
124
|
+
<IconFullscreen />
|
|
125
|
+
</button>
|
|
126
|
+
{/if}
|
|
127
|
+
</div>
|
|
110
128
|
{:else}
|
|
111
129
|
Something went wrong
|
|
112
130
|
{/if}
|
|
@@ -123,7 +141,20 @@
|
|
|
123
141
|
height: 100%;
|
|
124
142
|
}
|
|
125
143
|
|
|
126
|
-
.
|
|
144
|
+
.fullscreen :global(iframe) {
|
|
145
|
+
height: 100%;
|
|
146
|
+
width: 100%;
|
|
147
|
+
top: 0;
|
|
148
|
+
left: 0;
|
|
149
|
+
transform: none;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.hide-controls :global(.plyr__controls) {
|
|
153
|
+
display: none;
|
|
154
|
+
opacity: 0;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.action {
|
|
127
158
|
z-index: 10;
|
|
128
159
|
display: flex;
|
|
129
160
|
align-items: center;
|
|
@@ -148,5 +179,9 @@
|
|
|
148
179
|
&:active {
|
|
149
180
|
transform: scale(0.95);
|
|
150
181
|
}
|
|
182
|
+
|
|
183
|
+
&.secondary {
|
|
184
|
+
top: calc(margin(3) + var(--mute-top, 0px));
|
|
185
|
+
}
|
|
151
186
|
}
|
|
152
187
|
</style>
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
</script>
|
|
16
16
|
|
|
17
17
|
<div class="video-background" style="--height: {height}px; --width: {clientWidth}px;" bind:clientWidth bind:clientHeight data-testid="video-background">
|
|
18
|
-
<YouTubeEmbed {embeddable_url} {autoplay} fallbackStartTime={5} muted loop
|
|
18
|
+
<YouTubeEmbed {embeddable_url} {autoplay} fallbackStartTime={5} muted loop showActions />
|
|
19
19
|
</div>
|
|
20
20
|
|
|
21
21
|
<style lang="scss">
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
<h2>Youtube Embed</h2>
|
|
49
49
|
|
|
50
50
|
<div class="video">
|
|
51
|
-
<YouTubeEmbed embeddable_url="https://www.youtube.com/watch?v=bBMajXwi6Cs" controls={['progress', 'play']} loop
|
|
51
|
+
<YouTubeEmbed embeddable_url="https://www.youtube.com/watch?v=bBMajXwi6Cs" controls={['progress', 'play']} loop showActions muted />
|
|
52
52
|
</div>
|
|
53
53
|
|
|
54
54
|
<h2>Title</h2>
|
|
@@ -54,7 +54,7 @@ describe('YouTubeEmbed.svelte', () => {
|
|
|
54
54
|
expect(Plyr).toHaveBeenCalledWith(
|
|
55
55
|
playerElement,
|
|
56
56
|
expect.objectContaining({
|
|
57
|
-
controls: [],
|
|
57
|
+
controls: ['play', 'mute', 'fullscreen', 'progress', 'current-time'],
|
|
58
58
|
autoplay: true,
|
|
59
59
|
muted: false,
|
|
60
60
|
clickToPlay: false,
|
|
@@ -145,4 +145,11 @@ describe('YouTubeEmbed.svelte', () => {
|
|
|
145
145
|
expect(container.querySelector('.player')).not.toBeTruthy()
|
|
146
146
|
expect(getByText('Something went wrong')).toBeTruthy()
|
|
147
147
|
})
|
|
148
|
+
|
|
149
|
+
it('Should render actions when showActions is true', () => {
|
|
150
|
+
const { getByLabelText } = render(YouTubeEmbed, { embeddable_url: 'youtube.com/watch?v=abc', showActions: true })
|
|
151
|
+
|
|
152
|
+
expect(getByLabelText('Mute')).toBeTruthy()
|
|
153
|
+
expect(getByLabelText('Fullscreen')).toBeTruthy()
|
|
154
|
+
})
|
|
148
155
|
})
|