@banou/media-player 0.10.6 → 0.10.7
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/README.md +24 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +532 -399
- package/dist/react/hooks/use-pass-through-picture-in-picture.d.ts +10 -0
- package/dist/react/media.d.ts +48 -0
- package/dist/react/player.d.ts +1 -0
- package/dist/react/source-feature.d.ts +53 -8
- package/dist/react/video-player.d.ts +7 -1
- package/package.json +1 -1
- package/src/lib/index.tsx +4 -1
- package/src/lib/react/components/chrome.tsx +31 -0
- package/src/lib/react/components/control-bar.tsx +79 -4
- package/src/lib/react/hooks/use-pass-through-picture-in-picture.ts +113 -0
- package/src/lib/react/media.ts +49 -0
- package/src/lib/react/source-feature.ts +47 -4
- package/src/lib/react/video-player.tsx +17 -1
package/README.md
CHANGED
|
@@ -208,6 +208,30 @@ play/pause button.
|
|
|
208
208
|
If anything in that path is unavailable the player falls back to handing the browser the bare video,
|
|
209
209
|
which plays without subtitles rather than not at all.
|
|
210
210
|
|
|
211
|
+
### Picture in picture for a media you do not own
|
|
212
|
+
|
|
213
|
+
A browser opens picture in picture only for a click in the document that owns the `<video>`, so a
|
|
214
|
+
remote media gets the control only when the host opts in to taking that click:
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
// `.frame` sets `pointer-events: none`, so clicks reach the chrome everywhere else
|
|
218
|
+
<MediaPlayer
|
|
219
|
+
media={media}
|
|
220
|
+
pictureInPicture={{ onArmedChange: (armed) => { frame.current!.style.pointerEvents = armed ? 'auto' : '' } }}
|
|
221
|
+
>
|
|
222
|
+
<iframe ref={frame} className='frame' />
|
|
223
|
+
</MediaPlayer>
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
While the pointer is over the control, the chrome lets a click through at the control's box and the
|
|
227
|
+
host is told it is armed, so its frame takes that click and enters picture in picture from inside.
|
|
228
|
+
The control follows the media's `enterpictureinpicture` and `leavepictureinpicture` events, and in
|
|
229
|
+
picture in picture a click on it calls the media's `exitPictureInPicture`.
|
|
230
|
+
|
|
231
|
+
A finger never rests on the control before it presses, so a tap cannot arm it. The control is offered
|
|
232
|
+
only where the primary pointer hovers (`(hover: hover) and (pointer: fine)`), and a touch hides it
|
|
233
|
+
until a pointer that hovers moves again.
|
|
234
|
+
|
|
211
235
|
## Layout
|
|
212
236
|
|
|
213
237
|
One package. `src/` is the demo app, `src/lib` is the library it publishes, and the app imports it by
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { MediaPlayer, default } from './react/video-player';
|
|
2
2
|
export type { MediaPlayerOptions, MediaPlayerLocalOptions, MediaPlayerRemoteOptions, MediaPlayerSource, } from './react/video-player';
|
|
3
3
|
export { isDelegatedTracks, isExternalThumbnails } from './react/media';
|
|
4
|
-
export type { DelegatedSelection, DelegatedTracks, ExternalThumbnails, PlayerMedia, TimeRangesLike, } from './react/media';
|
|
4
|
+
export type { DelegatedSelection, DelegatedTracks, ExternalThumbnails, PassThroughPictureInPicture, PlayerMedia, TimeRangesLike, } from './react/media';
|
|
5
5
|
export { Player, usePlayer } from './react/player';
|
|
6
6
|
export type { PlayerStore } from './react/player';
|
|
7
7
|
export { sourceFeature } from './react/source-feature';
|
|
8
|
-
export type { DownloadedRange, PlaybackErrorEntry, SourceState } from './react/source-feature';
|
|
8
|
+
export type { DownloadedRange, PassThroughControl, PlaybackErrorEntry, SourceState, ViewportBox, } from './react/source-feature';
|
|
9
9
|
export { useSeekThumbnails } from './react/hooks/use-thumbnails';
|
|
10
10
|
export { usePictureInPicture } from './react/hooks/use-picture-in-picture';
|
|
11
11
|
export { inputToRemuxerInput } from './utils/source';
|