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

Commit

Permalink
minor updates, re-exported modules from ng sdk to wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
EkaanshArora committed Mar 29, 2021
1 parent 89b689e commit 3fe3c80
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 56 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Agora RTC SDK React Wrapper

A react wrapper for [Agora RTC NG SDK](https://www.npmjs.com/package/agora-rtc-sdk-ng).
A react (react.js) wrapper for [Agora RTC NG SDK](https://www.npmjs.com/package/agora-rtc-sdk-ng).

This wrapper supports **React >= v16.8**

## Install
```bash
npm install git://github.com/AgoraIO-Community/agora-rtc-react#v1.0.0
npm install git://github.com/AgoraIO-Community/agora-rtc-react#v1.0.1
```

## Usage
Expand All @@ -23,14 +24,14 @@ const App = () => {
const { ready, tracks } = useMicrophoneAndCameraTracks();

return (
ready && <AgoraVideoPlayer videoTrack={tracks[1]} />
ready && <AgoraVideoPlayer videoTrack={tracks[1]} style={{height: '100%', width: '100%'}} />
)
}

```

## Example
A full videocall example using the wrapper can be found [here](example.md).
A full videocall example using the wrapper can be found [here](https://github.com/AgoraIO-Community/agora-rtc-react/wiki/Example).

## Reference
You can view the methods in the wrapper [here](api.md).
You can view the methods in the wrapper [here](https://github.com/AgoraIO-Community/agora-rtc-react/wiki/API).
8 changes: 5 additions & 3 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ All methods take in the same parameters as the NG SDK. You can visit the officia
### AgoraVideoPlayer
This component lets you display a video track in the DOM.
You can pass in the `videoTrack` as prop along with other props that get passed to the rendered div containing your video.

***Note***: You need to pass in the height & width for the video player using the style prop (or className/id) which is applied to the resultant div containig the video, otherwise the renderd div is of size 0px.
#### ***Required Prop***
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)

Example:
```tsx
<AgoraVideoPlayer videoTrack={track} className="video" key={key} style={{height: '100px'}} />
<AgoraVideoPlayer videoTrack={track} className="video" key={key} style={{height: '100%', width: '100%'}} />
```
## Wrapper Functions Examples

Expand Down Expand Up @@ -61,12 +63,12 @@ const App = () => {
const { ready, tracks } = useMicrophoneAndCameraTracks();

return (
ready && <AgoraVideoPlayer videoTrack={tracks[1]} />
ready && <AgoraVideoPlayer videoTrack={tracks[1]} style={{height: '100%', width: '100%'}} />
)
}
```
All other create methods use a similar pattern.

## Other AgoraRTC Methods

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.
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](https://github.com/AgoraIO-Community/agora-rtc-react/wiki/Example) to understand better.
4 changes: 3 additions & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';
import { BufferSourceAudioTrackInitConfig, CameraVideoTrackInitConfig, ClientConfig, CustomAudioTrackInitConfig, CustomVideoTrackInitConfig, IAgoraRTCClient, IBufferSourceAudioTrack, ICameraVideoTrack, ILocalAudioTrack, ILocalVideoTrack, IMicrophoneAudioTrack, IRemoteVideoTrack, MicrophoneAudioTrackInitConfig, ScreenVideoTrackInitConfig } from 'agora-rtc-sdk-ng';
import AgoraRTC, { BufferSourceAudioTrackInitConfig, CameraVideoTrackInitConfig, ClientConfig, CustomAudioTrackInitConfig, CustomVideoTrackInitConfig, IAgoraRTCClient, IBufferSourceAudioTrack, ICameraVideoTrack, ILocalAudioTrack, ILocalVideoTrack, IMicrophoneAudioTrack, IRemoteVideoTrack, MicrophoneAudioTrackInitConfig, ScreenVideoTrackInitConfig } from 'agora-rtc-sdk-ng';
export default AgoraRTC;
export * from 'agora-rtc-sdk-ng';
export declare const createClient: (config: ClientConfig) => () => IAgoraRTCClient;
export declare function createMicrophoneAndCameraTracks(audioConfig?: MicrophoneAudioTrackInitConfig | undefined, videoConfig?: CameraVideoTrackInitConfig | undefined): () => {
ready: boolean;
Expand Down
28 changes: 19 additions & 9 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3fe3c80

Please sign in to comment.