mirror of
https://github.com/zoriya/react-native-video.git
synced 2026-06-05 11:49:45 +00:00
docs: update web docs
This commit is contained in:
@@ -52,16 +52,12 @@ function Player() {
|
|||||||
|
|
||||||
### Web-enhanced player
|
### Web-enhanced player
|
||||||
|
|
||||||
The web platform may offer additional features not available on native (such as audio and video track selection). To access them, cast the player to `WebVideoPlayer`:
|
The web platform may offer additional features not available on native. To access them, cast the player to [`WebVideoPlayer`](/docs/api-reference/interfaces/WebVideoPlayer):
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import { useVideoPlayer, type WebVideoPlayer } from 'react-native-video';
|
import { useVideoPlayer, type WebVideoPlayer } from 'react-native-video';
|
||||||
|
|
||||||
const player = useVideoPlayer(source) as WebVideoPlayer;
|
const player = useVideoPlayer(source) as WebVideoPlayer;
|
||||||
|
|
||||||
// Now you have access to web-specific methods like:
|
|
||||||
// player.getAvailableAudioTracks()
|
|
||||||
// player.selectAudioTrack(track)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This is optional - the standard `useVideoPlayer` works perfectly on web. The cast simply gives you typed access to extra capabilities when building web-specific features.
|
This is optional - the standard `useVideoPlayer` works perfectly on web. The cast simply gives you typed access to extra capabilities when building web-specific features.
|
||||||
@@ -94,31 +90,9 @@ Web support uses the same API as native - `useVideoPlayer` for creating a player
|
|||||||
| DRM | ❌ | Not yet available |
|
| DRM | ❌ | Not yet available |
|
||||||
| Ads | ❌ |
|
| Ads | ❌ |
|
||||||
|
|
||||||
## Audio & Video tracks (experimental)
|
## Web-only features
|
||||||
|
|
||||||
:::warning Limited Browser Support
|
See the [WebVideoPlayer](/docs/api-reference/interfaces/WebVideoPlayer) API reference for web-specific methods.
|
||||||
Audio and video track selection works out of the box in **Safari**. Chrome and Firefox support this API experimentally - users need to enable it manually in browser settings (e.g. `chrome://flags`)
|
|
||||||
:::
|
|
||||||
|
|
||||||
To access audio/video track methods, use the `WebVideoPlayer` type:
|
|
||||||
|
|
||||||
```tsx
|
|
||||||
import { useVideoPlayer, type WebVideoPlayer } from 'react-native-video';
|
|
||||||
|
|
||||||
const player = useVideoPlayer(source) as WebVideoPlayer;
|
|
||||||
|
|
||||||
// List available audio tracks
|
|
||||||
const audioTracks = player.getAvailableAudioTracks();
|
|
||||||
|
|
||||||
// Select a specific audio track
|
|
||||||
player.selectAudioTrack(audioTracks[0]);
|
|
||||||
|
|
||||||
// Same for video tracks
|
|
||||||
const videoTracks = player.getAvailableVideoTracks();
|
|
||||||
player.selectVideoTrack(videoTracks[0]);
|
|
||||||
```
|
|
||||||
|
|
||||||
These methods return empty arrays on browsers that don't support the API.
|
|
||||||
|
|
||||||
## Known limitations
|
## Known limitations
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user