@growth-labs/video 0.3.12 → 0.3.14
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/package.json +1 -1
- package/src/components/Video.astro +30 -0
package/package.json
CHANGED
|
@@ -77,6 +77,7 @@ const playerBoolAttrs = buildPlayerBooleanAttrs({
|
|
|
77
77
|
preload={config.player.preload}
|
|
78
78
|
crossorigin="anonymous"
|
|
79
79
|
playsinline
|
|
80
|
+
autopictureinpicture
|
|
80
81
|
class={`gl-video ${className ?? ''}`.trim()}
|
|
81
82
|
{...playerBoolAttrs}
|
|
82
83
|
>
|
|
@@ -176,6 +177,35 @@ const playerBoolAttrs = buildPlayerBooleanAttrs({
|
|
|
176
177
|
}
|
|
177
178
|
})
|
|
178
179
|
})
|
|
180
|
+
|
|
181
|
+
// `autopictureinpicture` is an HTML attribute on the native <video>
|
|
182
|
+
// element (Apple/WICG; iOS Safari 13.4+). When set on a playing video,
|
|
183
|
+
// iOS auto-enters native PiP whenever the page is hidden — lock screen,
|
|
184
|
+
// tab switch, app switch — so audio + video continue from the system
|
|
185
|
+
// PiP overlay instead of pausing.
|
|
186
|
+
//
|
|
187
|
+
// Vidstack's <media-player> wrapper does not know about this attribute;
|
|
188
|
+
// `vidstack-html.js`'s only setAttribute-on-media call is for
|
|
189
|
+
// `playsinline`. The attribute on the wrapper therefore never reaches
|
|
190
|
+
// the inner <video> that iOS actually inspects, and the feature stays
|
|
191
|
+
// inert. We close the gap by propagating the attribute ourselves: when
|
|
192
|
+
// Vidstack mounts the inner <video> (asynchronously, after provider
|
|
193
|
+
// attach), copy `autopictureinpicture` to it.
|
|
194
|
+
for (const player of document.querySelectorAll<HTMLElement>('media-player[autopictureinpicture]')) {
|
|
195
|
+
const propagate = () => {
|
|
196
|
+
const v = player.querySelector('video')
|
|
197
|
+
if (v && !v.hasAttribute('autopictureinpicture')) {
|
|
198
|
+
v.setAttribute('autopictureinpicture', '')
|
|
199
|
+
return true
|
|
200
|
+
}
|
|
201
|
+
return false
|
|
202
|
+
}
|
|
203
|
+
if (propagate()) continue
|
|
204
|
+
const obs = new MutationObserver(() => {
|
|
205
|
+
if (propagate()) obs.disconnect()
|
|
206
|
+
})
|
|
207
|
+
obs.observe(player, { childList: true, subtree: true })
|
|
208
|
+
}
|
|
179
209
|
</script>
|
|
180
210
|
|
|
181
211
|
<style>
|