Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #12 from AgoraIO-Community/feat-addConfigToVideoPl…
Browse files Browse the repository at this point in the history
…ayer

add config to AgoraVideoPlayer - #9
  • Loading branch information
EkaanshArora authored Sep 15, 2021
2 parents e0f4b5c + 158b943 commit 5b5b841
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import AgoraRTC, {
IMicrophoneAudioTrack,
IRemoteVideoTrack,
MicrophoneAudioTrackInitConfig,
ScreenVideoTrackInitConfig
ScreenVideoTrackInitConfig,
VideoPlayerConfig
} from 'agora-rtc-sdk-ng'

export default AgoraRTC;
Expand Down Expand Up @@ -330,11 +331,11 @@ export function createScreenVideoTrack(
}


export const AgoraVideoPlayer = (props: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> & { videoTrack: ILocalVideoTrack | IRemoteVideoTrack | ICameraVideoTrack }) => {
export const AgoraVideoPlayer = (props: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> & { videoTrack: ILocalVideoTrack | IRemoteVideoTrack | ICameraVideoTrack } & {config?: VideoPlayerConfig}) => {
const vidDiv: RefObject<HTMLDivElement> = useRef(null)
const { videoTrack, ...other } = props;
const { videoTrack, config, ...other } = props;
useEffect(() => {
if (vidDiv.current !== null) videoTrack.play(vidDiv.current)
if (vidDiv.current !== null) videoTrack.play(vidDiv.current, config)
return () => {
videoTrack.stop()
}
Expand Down

0 comments on commit 5b5b841

Please sign in to comment.