|
| 1 | +# API Reference |
| 2 | + |
| 3 | +## Wrapper Functions |
| 4 | + |
| 5 | +| Factory Method | Parameters (? = optional)| Return Value | Reference |
| 6 | +| ----- | ---- | ---- | ---- | |
| 7 | +| createClient | [ClientConfig](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/clientconfig.html) | A hook that gives a [client object](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/iagorartcclient.html) | [AgoraRTC.createClient](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/iagorartc.html#createclient) | |
| 8 | +| createMicrophoneAndCameraTracks | [AudioConfig?](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/microphoneaudiotrackinitconfig.html), [VideoConfig?](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/cameravideotrackinitconfig.html) | A hook that gives an object containg tracks ([microphone](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/imicrophoneaudiotrack.html) and [camera](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/icameravideotrack.html)) and a state variable `ready` which is set to true when the feeds are initialised | [createMicrophoneAndCameraTracks](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/iagorartc.html#createmicrophoneandcameratracks) | |
| 9 | +| createBufferSourceAudioTrack | [BufferSourceAudioTrackInitConfig](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/buffersourceaudiotrackinitconfig.html) | A hook that gives an object containg the [audio track](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/ibuffersourceaudiotrack.html) and a state variable `ready` which is set to true when the feeds are initialised | [AgoraRTC.createBufferSourceAudioTrack](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/iagorartc.html#createbuffersourceaudiotrack) | |
| 10 | +| createCameraVideoTrack | [CameraVideoTrackInitConfig?](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/cameravideotrackinitconfig.html)| A hook that gives an object containg the [camera video track](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/icameravideotrack.html) and a state variable `ready` which is set to true when the feeds are initialised | [AgoraRTC.createCameraVideoTrack](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/iagorartc.html#createcameravideotrack) | |
| 11 | +| createCustomAudioTrack |[CustomAudioTrackInitConfig](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/customaudiotrackinitconfig.html)| A hook that gives an object containg the [custom audio track](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/ilocalaudiotrack.html) and a state variable `ready` which is set to true when the feeds are initialised | [AgoraRTC.createCustomAudioTrack](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/iagorartc.html#createcustomaudiotrack) | |
| 12 | +| createCustomVideoTrack |[CustomVideoTrackInitConfig](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/customvideotrackinitconfig.html)| A hook that gives an object containg the [custom video track](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/ilocalvideotrack.html) and a state variable `ready` which is set to true when the feeds are initialised | [AgoraRTC.createCustomVideoTrack](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/iagorartc.html#createcustomvideotrack) | |
| 13 | +| createMicrophoneAudioTrack |[MicrophoneAudioTrackInitConfig?](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/microphoneaudiotrackinitconfig.html)| A hook that gives an object containg the [microphone audio track](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/imicrophoneaudiotrack.html) and a state variable `ready` which is set to true when the feeds are initialised | [AgoraRTC.createMicrophoneAudioTrack](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/iagorartc.html#createmicrophoneaudiotrack) | |
| 14 | +| createScreenVideoTrack |[ScreenVideoTrackInitConfig?](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/screenvideotrackinitconfig.html), [withAudio?](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/iagorartc.html#createscreenvideotrack)| A hook that gives an object containg tracks ([audio](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/ilocalaudiotrack.html) and [video](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/ilocalvideotrack.html)) and a state variable `ready` which is set to true when the feeds are initialised | [AgoraRTC.createScreenVideoTrack](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/iagorartc.html#createscreenvideotrack) | |
| 15 | + |
| 16 | +All methods take in the same parameters as the NG SDK. You can visit the official docs for each methods to know more. |
| 17 | + |
| 18 | +## Components |
| 19 | + |
| 20 | +### AgoraVideoPlayer |
| 21 | +This component lets you display a video track in the DOM. |
| 22 | +You can pass in the `videoTrack` as prop along with other props that get passed to the rendered div containing your video. |
| 23 | +#### ***Required Prop*** |
| 24 | +videoTrack: [ILocalVideoTrack](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/ilocalvideotrack.html) | [IRemoteVideoTrack](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/iremotevideotrack.html) | [ICameraVideoTrack](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/icameravideotrack.html) |
| 25 | + |
| 26 | +Example: |
| 27 | +```tsx |
| 28 | +<AgoraVideoPlayer videoTrack={track} className="video" key={key} style={{height: '100px'}} /> |
| 29 | +``` |
| 30 | +## Wrapper Functions Examples |
| 31 | + |
| 32 | +### createClient |
| 33 | +```tsx |
| 34 | +import React from "react"; |
| 35 | +import { createClient } from "agora-rtc-react"; |
| 36 | + |
| 37 | +const config = {mode: "rtc", codec: "vp8"} |
| 38 | +const useClient = createClient(config); |
| 39 | + |
| 40 | +const App = () => { |
| 41 | + const client = useClient(); |
| 42 | + |
| 43 | + useEffect(() => { |
| 44 | + client.join(appId, name, token, null); |
| 45 | + }, []) |
| 46 | + |
| 47 | + return ( |
| 48 | + <p>{client.uid}</p> |
| 49 | + ) |
| 50 | +} |
| 51 | +``` |
| 52 | + |
| 53 | +### createMicrophoneAndCameraTracks |
| 54 | +```tsx |
| 55 | +import React from "react"; |
| 56 | +import { createMicrophoneAndCameraTracks, AgoraVideoPlayer } from "agora-rtc-react"; |
| 57 | + |
| 58 | +const useMicrophoneAndCameraTracks = createMicrophoneAndCameraTracks(); |
| 59 | + |
| 60 | +const App = () => { |
| 61 | + const { ready, tracks } = useMicrophoneAndCameraTracks(); |
| 62 | + |
| 63 | + return ( |
| 64 | + ready && <AgoraVideoPlayer videoTrack={tracks[1]} /> |
| 65 | + ) |
| 66 | +} |
| 67 | +``` |
| 68 | +All other create methods use a similar pattern. |
| 69 | + |
| 70 | +## Other AgoraRTC Methods |
| 71 | + |
| 72 | +For other RTC SDK methods you can directly use them from the [AgoraRTC](https://docs.agora.io/en/Video/API%20Reference/web_ng/interfaces/iagorartc.html) object. Look at the example using the wrapper for group videocall [here](example.md) to understand better. |
0 commit comments