Skip to content

Commit

Permalink
Merge pull request #12 from MathieuPOUX/dev
Browse files Browse the repository at this point in the history
docs(README): fix links and examples, shortened a TIP description
  • Loading branch information
thomasjammet authored Apr 26, 2024
2 parents 78102e8 + 60a9693 commit c864c44
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ Then [import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modu
import * as WebRTC from '@ceeblue/webrtc-client';
```
> 💡 **TIP**
> - If your project uses [TypeScript](https://www.typescriptlang.org/), it is recommended to set `"target": "ES6"` in your configuration. This setting aligns with our usage of ES6 features and ensures that your build will succeed. For those requiring a backwards-compatible UMD (Universal Module Definition) version, a [local build](#development) is advised.
> Defining the compiler option `"moduleResolution": "Node"` in **tsconfig.json** helps with import errors by ensuring that TypeScript uses the correct strategy for resolving imports based on the targeted Node.js version.
>
> If your project uses [TypeScript](https://www.typescriptlang.org/), it is recommended to set `"target": "ES6"` in your configuration to align with our usage of ES6 features and ensures that your build will succeed (for those requiring a backwards-compatible [UMD](https://github.com/umdjs/umd) version, a [local build](#building-locally) is advised).
> Then defining the compiler option `"moduleResolution": "Node"` in **tsconfig.json** helps with import errors by ensuring that TypeScript uses the correct strategy for resolving imports based on the targeted Node.js version.
> ```json
> {
> "compilerOptions": {
Expand All @@ -50,7 +51,7 @@ import * as WebRTC from '@ceeblue/webrtc-client';
To publish the stream `<streamName>` to `<endpoint>`, use the [Streamer](./src/Streamer.ts) class and the variables you saved while setting up the stream in the dashboard [Requirements](#requirements). For a full example, see push.html in [Examples](#examples).
```javascript
import Streamer as WebRTC from '@ceeblue/webrtc-client';
import { Streamer } from '@ceeblue/webrtc-client';
const streamer = new Streamer();
streamer.onStart = stream => {
Expand All @@ -59,16 +60,13 @@ streamer.onStart = stream => {
streamer.onStop = _ => {
console.log('stop streaming');
}
navigator.mediaDevices
.getUserMedia({ audio: true, video: true })
.then(stream => {
streamer.start(stream, {
host: <endpoint>,
streamName: <streamName>,
iceServer: {
urls: ['turn:' + <endPoint> + ':3478?transport=tcp', 'turn:' + <endPoint> + ':3478'],
username: 'csc_demo', credential: 'UtrAFClFFO'
}
const stream = await navigator.mediaDevices.getUserMedia({ audio: true, video: true });
streamer.start(stream, {
host: <endpoint>,
streamName: <streamName>,
iceServer: {
urls: ['turn:' + <endPoint> + ':3478?transport=tcp', 'turn:' + <endPoint> + ':3478'],
username: 'csc_demo', credential: 'UtrAFClFFO'
}
});
```
Expand All @@ -78,7 +76,7 @@ navigator.mediaDevices
To play the stream `<streamName>` from `<endPoint>`, use the [Player](./src/Player.ts) class and the variables you saved while setting up the stream in the dashboard [Requirements](#requirements). For a full example, see play.html in [Examples](#examples).

```javascript
import Player as WebRTC from '@ceeblue/webrtc-client';
import { Player } from '@ceeblue/webrtc-client';

const player = new Player();

Expand All @@ -89,14 +87,14 @@ player.onStart = stream => {
player.onStop = _ => {
console.log('stop playing');
}
streamer.start(stream, {
player.start({
host: <endPoint>,
streamName: <streamName>,
iceServer: {
streamName: <streamName>,
iceServer: {
urls: ['turn:' + <endPoint> + ':3478?transport=tcp', 'turn:' + <endPoint> + ':3478'],
username: 'csc_demo', credential: 'UtrAFClFFO'
}
}
});
```

## Examples
Expand All @@ -107,21 +105,21 @@ To understand how to use the library through examples, we provide three illustra
- [/examples/player.html](./examples/player.html) → Play a stream
- [/examples/player-with-timed-metadata.html](./examples/player-with-timed-metadata.html) → Play a stream with timed metadata

1. In your project directory, [if you have installed the simple-http package](/#requirements), execute the following command from the Terminal prompt by navigating to:
1. In your project directory, if you have installed the [http-server service](#requirements), execute the following command from the Terminal prompt by navigating to:

```shell
http-server . -p 8081
```

2. Navigate to the specified address in your browser, making sure to replace any placeholders in the URL with the variables you have copied during the [stream setup](/#requirements) in the dashboard.
2. Navigate to the specified address in your browser, making sure to replace any placeholders in the URL with the variables you have copied during the [stream setup](#requirements) in the dashboard.

```html
http://localhost:8081/examples/streamer.html?host=<endpoint>&stream=<streamName>
```

3. Click on **Start streaming**. Upon doing so, a live stream from your webcam will initiate. Should your browser request permission to access your camera, ensure to grant it.

4. In the address bar of a separate browser window, enter the following address, making sure to replace the placeholders in the URL with the variables you have copied while configuring the [stream setup](/#requirements) in the dashboard.
4. In the address bar of a separate browser window, enter the following address, making sure to replace the placeholders in the URL with the variables you have copied while configuring the [stream setup](#requirements) in the dashboard.

```html
http://localhost:8081/examples/player.html?host=<endpoint>&stream=<streamName>
Expand Down Expand Up @@ -169,7 +167,7 @@ This monorepo also contains built-in documentation about the APIs in the library
```
npm run build:docs
```
You can access the documentation by opening the index.html file in the docs folder with your browser (`./docs/index.html`), or, if you have [installed and started the http-server](/#requirements), by navigating to:
You can access the documentation by opening the index.html file in the docs folder with your browser (`./docs/index.html`), or if you have installed and started the [http-server service](#requirements) by navigating to:
```
http://localhost:8081/docs/
```
Expand Down

0 comments on commit c864c44

Please sign in to comment.