@growth-labs/video 0.3.13 → 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 +29 -0
package/package.json
CHANGED
|
@@ -177,6 +177,35 @@ const playerBoolAttrs = buildPlayerBooleanAttrs({
|
|
|
177
177
|
}
|
|
178
178
|
})
|
|
179
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
|
+
}
|
|
180
209
|
</script>
|
|
181
210
|
|
|
182
211
|
<style>
|