Skip to content

Commit f239395

Browse files
committed
Update readme
1 parent 61c4a9c commit f239395

File tree

2 files changed

+48
-36
lines changed

2 files changed

+48
-36
lines changed

README.md

+47-35
Original file line numberDiff line numberDiff line change
@@ -20,59 +20,71 @@ Install the Web Player package using npm:
2020
npm i @antmedia/web_player
2121
```
2222

23-
## Configuration Parameters
24-
25-
The player accepts several configuration parameters, either through the URL or directly in the code:
26-
27-
1. `id` (String): The stream ID to play. This parameter is mandatory.
28-
2. `token` (String): The token for stream access. It's mandatory if token security is enabled on the server side.
29-
3. `autoplay` (Boolean): Autoplay the stream if available. Optional. Default value is `true`.
30-
4. `mute` (Boolean): Start playing in mute mode if the stream is available. Optional. Default value is `true`.
31-
5. `playOrder` (String): The order of technologies used for playing. Optional. Default value is `"webrtc,hls"`. Possible values include `"hls,webrtc"`, `"webrtc"`, `"hls"`, `"vod"`, `"dash"`.
32-
6. `playType` (String): The order of play types used for playing. Optional. Default value is `"mp4,webm"`. Possible values include `"webm,mp4"`, `"mp4"`, `"webm"`, `"mov"`.
33-
7. `targetLatency` (Number): The target latency for the DASH player. Optional. Default value is `3`.
34-
8. `is360` (Boolean): Enable playback in 360 mode. Optional. Default value is `false`.
35-
3623
## Usage
3724

3825
### Basic Usage
3926

40-
Import the `WebPlayer` and initialize it with the desired configuration:
27+
To use the Web Player, import it and initialize it with the parameters received from the URL. Refer to the Configuration Parameters section below for more details.
4128

42-
```javascript
43-
import { WebPlayer } from "@antmedia/web_player";
29+
1. In your web application, create a div with the id video_container. This will serve as the container for the player.
4430

45-
var embeddedPlayer = new WebPlayer(window, document.getElementById("video_container"), document.getElementById("video_info"));
31+
```
32+
<div id="video_container" ></div>
33+
````
34+
35+
2. Initialize the player as follows:
36+
```javascript
37+
import { WebPlayer } from "@antmedia/web_player";
4638
47-
embeddedPlayer.initialize().then(() => {
39+
var embeddedPlayer = new WebPlayer(window, document.getElementById("video_container"), null);
40+
41+
embeddedPlayer.initialize().then(() => {
4842
embeddedPlayer.play();
49-
});
50-
```
43+
});
44+
```
5145

5246
The sample for this usage is available in [play.html in StreamApp](https://github.com/ant-media/StreamApp/blob/master/src/main/webapp/play.html)
5347

5448
### Advanced Usage
55-
You can also pass the parameters as an object to the WebPlayer constructor:
56-
57-
```javascript
58-
var player = new WebPlayer({
59-
streamId: streamId,
60-
httpBaseURL: "http://example.antmedia.io:5080/WebRTCAppEE",
61-
token: tokenId,
62-
playOrder: ["webrtc", "hls", "dash"],
63-
videoHTMLContent: '<video id="video-player" class="video-js vjs-default-skin vjs-big-play-centered" controls playsinline style="width:100%;height:100%"></video>',
64-
}, document.getElementById("video_container"), null);
65-
66-
player.initialize().then(() => {
49+
Alternatively, you can pass the parameters as an object to the WebPlayer constructor.
50+
51+
52+
1. In your web application, create a div with the id video_container. This will serve as the container for the player.
53+
```
54+
<div id="video_container" ></div>
55+
````
56+
57+
2. Initialize the player as follows
58+
```javascript
59+
var player = new WebPlayer({
60+
streamId: "myStreamId",
61+
httpBaseURL: "http://example.antmedia.io:5080/WebRTCAppEE/", //Remember to add trailing slash(/)
62+
}, document.getElementById("video_container"), null);
63+
64+
player.initialize().then(() => {
6765
player.play();
68-
}).catch((error) => {
66+
}).catch((error) => {
6967
console.error("Error while initializing embedded player: " + error);
70-
});
71-
```
68+
});
69+
```
7270

7371
The sample for this usage is available in [app.page.component.ts in Ant-Media-Management-Console](https://github.com/ant-media/Ant-Media-Management-Console/blob/master/src/app/app.page/app.page.component.ts)
7472

7573

74+
## Configuration Parameters
75+
76+
The player accepts several configuration parameters, either through the URL or directly in the code:
77+
78+
1. `id` (String): The stream ID to play. This parameter is mandatory.
79+
2. `token` (String): The token for stream access. It's mandatory if token security is enabled on the server side.
80+
3. `autoplay` (Boolean): Autoplay the stream if available. Optional. Default value is `true`.
81+
4. `mute` (Boolean): Start playing in mute mode if the stream is available. Optional. Default value is `true`.
82+
5. `playOrder` (String): The order of technologies used for playing. Optional. Default value is `"webrtc,hls"`. Possible values include `"hls,webrtc"`, `"webrtc"`, `"hls"`, `"vod"`, `"dash"`.
83+
6. `playType` (String): The order of play types used for playing. Optional. Default value is `"mp4,webm"`. Possible values include `"webm,mp4"`, `"mp4"`, `"webm"`, `"mov"`.
84+
7. `targetLatency` (Number): The target latency for the DASH player. Optional. Default value is `3`.
85+
8. `is360` (Boolean): Enable playback in 360 mode. Optional. Default value is `false`.
86+
87+
7688
## Support
7789
For support and further inquiries, please visit [Ant Media Server's community](https://github.com/orgs/ant-media/discussions). If you are an enterprise user, you can receive support by sending an email to [email protected].
7890

src/web_player.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ export class WebPlayer {
545545
});
546546

547547
this.videojsPlayer.on('error', (e) => {
548-
Logger.warn("There is an error in playback: " + e);
548+
Logger.warn("There is an error in playback: ", e);
549549
// We need to add this kind of check. If we don't add this kind of checkpoint, it will create an infinite loop
550550
if (!this.errorCalled) {
551551
this.errorCalled = true;

0 commit comments

Comments
 (0)