Enable companion Cloud video picture-in-picture
This commit is contained in:
@@ -39,9 +39,11 @@
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTask"
|
||||
android:supportsPictureInPicture="true"
|
||||
android:resizeableActivity="true"
|
||||
android:theme="@style/Theme.Archipelago.Splash"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden">
|
||||
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|keyboardHidden">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
||||
@@ -2,6 +2,7 @@ import { describe, it, expect, afterEach, beforeEach, vi } from 'vitest'
|
||||
import { mount, flushPromises } from '@vue/test-utils'
|
||||
import MediaLightbox from '../cloud/MediaLightbox.vue'
|
||||
import { usePipSession } from '../../composables/usePipSession'
|
||||
import { togglePip } from '../../utils/pip'
|
||||
import type { FileBrowserItem } from '../../api/filebrowser-client'
|
||||
|
||||
// jsdom has no picture-in-picture implementation — stub the pieces the
|
||||
@@ -75,6 +76,18 @@ async function mountLightbox() {
|
||||
}
|
||||
|
||||
describe('MediaLightbox picture-in-picture handoff', () => {
|
||||
it('checks PiP support when the action is invoked in a WebView', async () => {
|
||||
const video = document.createElement('video')
|
||||
const request = vi.spyOn(video, 'requestPictureInPicture')
|
||||
Object.defineProperty(document, 'pictureInPictureEnabled', { value: false, configurable: true })
|
||||
await togglePip(video)
|
||||
expect(request).not.toHaveBeenCalled()
|
||||
|
||||
Object.defineProperty(document, 'pictureInPictureEnabled', { value: true, configurable: true })
|
||||
await togglePip(video)
|
||||
expect(request).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('entering PiP emits close exactly once and adopts the video before doing so', async () => {
|
||||
const wrapper = await mountLightbox()
|
||||
const video = findVideo()
|
||||
|
||||
@@ -20,7 +20,10 @@ export function isPipSupported(): boolean {
|
||||
}
|
||||
|
||||
export async function togglePip(video: HTMLVideoElement | null | undefined): Promise<void> {
|
||||
if (!video || !pipSupported) return
|
||||
// Check at call time. Embedded WebViews can expose the document capability
|
||||
// after the module has been evaluated, and companion navigation can restore
|
||||
// a page with a different media capability than its first load.
|
||||
if (!video || !isPipSupported()) return
|
||||
try {
|
||||
if (document.pictureInPictureElement === video) await document.exitPictureInPicture()
|
||||
else await video.requestPictureInPicture()
|
||||
|
||||
Reference in New Issue
Block a user