react-ovenplayer
v0.1.3
Published
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/dygy/ReactOvenPlayer/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/react.svg?style=flat)](https://www.npmjs.com/package/react-ovenplayer) # ๐
Downloads
66
Readme
๐ Getting Started with ReactOvenPlayer
๐ช Setup
npm i react-ovenplayer
๐ Usage
import React, {useEffect, useState} from "react";
import ReactOvenPlayer, {ReactOvenPlayerState} from "react-ovenplayer"
export const Player = () => {
const [state, setState] = useState<ReactOvenPlayerState | null>(null)
useEffect(()=>{
state?.instance.pause()
}, [state])
return (
<div>
<ReactOvenPlayer
wrapperStyles={{
minWidth: 500
}}
setState={setState}
config={{
autoStart: true,
autoFallback: true,
controls: true,
showBigPlayButton: false,
mute: true,
webrtcConfig: {
timeoutMaxRetry: 5,
connectionTimeout: 10000,
},
sources: [
{
label: 'ap-webrtc',
type: 'webrtc',
file: `wss://url/webrtc`,
},
{
label: 'eu-webrtc',
type: 'webrtc',
file: `wss://url2/webrtc`,
},
],
}
}
/>
</div>
)
}
๐ Props
wrapperStyles?: React.CSSProperties;
styles of player wrapper
isAutoReconnect?: boolean;
enable feature to auto reconnect player
config: OvenPlayerConfig;
OvenPlayer configurator. Just as in OvenPlayer
state?: ReactOvenPlayerState | null;
setState?: React.Dispatch<React.SetStateAction<ReactOvenPlayerState>>;
properties to check and control state of the player
it will give you back
export type ReactOvenPlayerState = {
library: OvenPlayer;
instance: OvenPlayerInstance;
version: string;
stateObject?: OvenPlayerEvents["stateChanged"];
quality?: OvenPlayerQuality;
isAutoQuality?: boolean;
volume?: number;
};
- library of ovenplayer
- player instance (not reactive, from ovenplayer)
- version of ovenplayer
- state object, what is current state and what is last state
- current quality as object. Bitrate, label, index, etc.
- is current quality are auto
- volume level in number %
๐ License
React OvenPlayer is MIT licensed, as found in the LICENSE file.