mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
feat(site): add util reference pipeline (#537)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
c11395ece1
commit
78112fbefd
@@ -0,0 +1,51 @@
|
||||
---
|
||||
title: selectPiP
|
||||
description: Select the picture-in-picture state slice from the player store
|
||||
---
|
||||
|
||||
import UtilReference from "@/components/docs/api-reference/UtilReference.astro";
|
||||
import DocsLink from "@/components/docs/DocsLink.astro";
|
||||
import FrameworkCase from "@/components/docs/FrameworkCase.astro";
|
||||
|
||||
<FrameworkCase frameworks={["react"]}>
|
||||
Pass `selectPiP` to <DocsLink slug="reference/use-player">`usePlayer`</DocsLink> to subscribe to picture-in-picture state. Returns `undefined` if the PiP feature is not configured.
|
||||
</FrameworkCase>
|
||||
|
||||
<FrameworkCase frameworks={["html"]}>
|
||||
Pass `selectPiP` to <DocsLink slug="reference/player-controller">`PlayerController`</DocsLink> to subscribe to picture-in-picture state. Returns `undefined` if the PiP feature is not configured.
|
||||
</FrameworkCase>
|
||||
|
||||
The returned state includes whether PiP is active and its availability on the current platform.
|
||||
|
||||
<FrameworkCase frameworks={["react"]}>
|
||||
```tsx
|
||||
import { usePlayer } from '@videojs/react';
|
||||
import { selectPiP } from '@videojs/core/dom';
|
||||
|
||||
function PiPButton() {
|
||||
const pip = usePlayer(selectPiP);
|
||||
if (!pip || pip.availability !== 'available') return null;
|
||||
|
||||
return (
|
||||
<button onClick={pip.toggle}>
|
||||
{pip.active ? 'Exit PiP' : 'Picture-in-Picture'}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
```
|
||||
</FrameworkCase>
|
||||
|
||||
<FrameworkCase frameworks={["html"]}>
|
||||
```ts
|
||||
import { createPlayer, features, MediaElement } from '@videojs/html';
|
||||
import { selectPiP } from '@videojs/core/dom';
|
||||
|
||||
const { PlayerController, context } = createPlayer({ features: features.video });
|
||||
|
||||
class PiPButton extends MediaElement {
|
||||
#pip = new PlayerController(this, context, selectPiP);
|
||||
}
|
||||
```
|
||||
</FrameworkCase>
|
||||
|
||||
<UtilReference util="selectPiP" />
|
||||
Reference in New Issue
Block a user