videojs-hls-boomstream 1.2.99 → 1.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,321 +1,321 @@
|
|
|
1
|
-
# videojs-hls-boomstream
|
|
2
|
-
|
|
3
|
-
This plugin was developed for integration of videojs player and online video platform [Boomstream]( https://boomstream.com/ "Boomstream").
|
|
4
|
-
Try it and hls delivery will be as easy as one, two, three.
|
|
5
|
-
|
|
6
|
-
## Table of Contents
|
|
7
|
-
|
|
8
|
-
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
9
|
-
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- [Installation](#installation)
|
|
13
|
-
- [Usage](#usage)
|
|
14
|
-
- [`<script>` Tag](#script-tag)
|
|
15
|
-
- [Browserify ES6](#browserify-es6)
|
|
16
|
-
- [License](#license)
|
|
17
|
-
|
|
18
|
-
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
19
|
-
## Installation
|
|
20
|
-
|
|
21
|
-
```sh
|
|
22
|
-
npm install --save videojs-hls-boomstream
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Usage
|
|
26
|
-
|
|
27
|
-
To include videojs-hls-boomstream on your website or web application, use any of the following methods.
|
|
28
|
-
|
|
29
|
-
### `<script>` Tag
|
|
30
|
-
|
|
31
|
-
This is the simplest case. Get the script in whatever way you prefer and include the plugin _after_ you include [video.js][videojs], so that the `videojs` global is available.
|
|
32
|
-
|
|
33
|
-
```html
|
|
34
|
-
<script src="//path/to/video.min.js"></script>
|
|
35
|
-
<script src="//path/to/videojs-hls-boomstream.min.js"></script>
|
|
36
|
-
<script>
|
|
37
|
-
var player = videojs('my-video', /*, <videojs options {}>, <ready callback ()>*/);
|
|
38
|
-
|
|
39
|
-
player.boomstreamHls();
|
|
40
|
-
player.src("<bms video source>");
|
|
41
|
-
</script>
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### Browserify ES6
|
|
45
|
-
|
|
46
|
-
When using with Browserify, install videojs-hls-boomstream via npm and import the plugin as you would any other module.
|
|
47
|
-
|
|
48
|
-
```js
|
|
49
|
-
import videojs from 'video.js';
|
|
50
|
-
import * as BoomstreamHlsPlugin from "videojs-hls-boomstream";
|
|
51
|
-
|
|
52
|
-
...
|
|
53
|
-
BoomstreamHlsPlugin.init(videojs);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var player = videojs("my-video" /*, <videojs options {}>, <ready callback ()>*/);
|
|
57
|
-
player.boomstreamHls();
|
|
58
|
-
player.src("<bms video source>");
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Catch errors
|
|
62
|
-
player.error() returns the most recent error. you can listen to the error event:
|
|
63
|
-
|
|
64
|
-
```js
|
|
65
|
-
player.on('error', function() {
|
|
66
|
-
console.log(player.error());
|
|
67
|
-
});
|
|
68
|
-
```
|
|
69
|
-
or
|
|
70
|
-
```js
|
|
71
|
-
import { BMSPluginError, BMSPluginErrorType } from 'videojs-hls-boomstream';
|
|
72
|
-
|
|
73
|
-
player.boomstreamHls({
|
|
74
|
-
onerror: (e: BMSPluginError) => {
|
|
75
|
-
switch(e.type) {
|
|
76
|
-
case BMSPluginErrorType.RESPONSE:
|
|
77
|
-
...
|
|
78
|
-
case BMSPluginErrorType.MEDIA:
|
|
79
|
-
...
|
|
80
|
-
case BMSPluginErrorType.CONFIG:
|
|
81
|
-
...
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Plugin error structure
|
|
88
|
-
```js
|
|
89
|
-
const enum BMSPluginErrorType {
|
|
90
|
-
RESPONSE = 'ResponseError',
|
|
91
|
-
MEDIA = 'MediaError',
|
|
92
|
-
CONFIG = 'ConfigParseException'
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
interface BMSPluginError {
|
|
96
|
-
type: BMSPluginErrorType;
|
|
97
|
-
code: number;
|
|
98
|
-
message: string;
|
|
99
|
-
data?: any;
|
|
100
|
-
}
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### Plugin error types
|
|
104
|
-
- BMSPluginErrorType.RESPONSE - standart HTTP status codes (200, 300, 400, 500, etc.)
|
|
105
|
-
```js
|
|
106
|
-
BMSPluginError {
|
|
107
|
-
code: 404, // response code
|
|
108
|
-
data: { // optional response error data
|
|
109
|
-
...
|
|
110
|
-
},
|
|
111
|
-
message: "Not found", // response message
|
|
112
|
-
name: "BMSPluginError", // class name
|
|
113
|
-
type: "ResponseError" // error type
|
|
114
|
-
}
|
|
115
|
-
```
|
|
116
|
-
- BMSPluginErrorType.MEDIA - bms plugin media errors (code, message):
|
|
117
|
-
- 204, branding_processing
|
|
118
|
-
- 403, branding_geo
|
|
119
|
-
- 403, branding_protection
|
|
120
|
-
|
|
121
|
-
- 404, branding_deleted
|
|
122
|
-
- 404, branding_empty_playlist
|
|
123
|
-
- 404, branding_not_found
|
|
124
|
-
|
|
125
|
-
- 423, branding_access_expire
|
|
126
|
-
- 423, branding_contacts
|
|
127
|
-
- 423, branding_blocked
|
|
128
|
-
- 423, branding_locked
|
|
129
|
-
- 423, branding_sales_not_allowed
|
|
130
|
-
- 423, branding_zero_balance
|
|
131
|
-
**(The "branding_" prefix in the message appears when the branding option is enabled)**
|
|
132
|
-
-------------
|
|
133
|
-
|
|
134
|
-
- 204, processing
|
|
135
|
-
- 403, geo
|
|
136
|
-
- 403, protection
|
|
137
|
-
|
|
138
|
-
- 404, deleted
|
|
139
|
-
- 404, empty_playlist
|
|
140
|
-
- 404, not_found
|
|
141
|
-
|
|
142
|
-
- 423, access_expire
|
|
143
|
-
- 423, contacts
|
|
144
|
-
- 423, blocked
|
|
145
|
-
- 423, locked
|
|
146
|
-
- 423, sales_not_allowed
|
|
147
|
-
- 423, zero_balance
|
|
148
|
-
|
|
149
|
-
-------------
|
|
150
|
-
- 500, application_error
|
|
151
|
-
- 500, application_maintenance
|
|
152
|
-
|
|
153
|
-
```js
|
|
154
|
-
BMSPluginError {
|
|
155
|
-
code: 403, // error code
|
|
156
|
-
data: { // optional error data
|
|
157
|
-
code: 403,
|
|
158
|
-
message: "protection",
|
|
159
|
-
translate: "Access denied.<br/>Online Videoplatform <a href='https://boomstream.com' target='_blank'>boomstream.com</a>"
|
|
160
|
-
},
|
|
161
|
-
message: "player.403_protection", // localized message for MediaError
|
|
162
|
-
name: "BMSPluginError", // class name
|
|
163
|
-
type: "MediaError" // error type
|
|
164
|
-
}
|
|
165
|
-
```
|
|
166
|
-
- BMSPluginErrorType.CONFIG - occurs when config parsing has failed
|
|
167
|
-
```js
|
|
168
|
-
BMSPluginError {
|
|
169
|
-
code: 0, // constant
|
|
170
|
-
data: { // optional exception data
|
|
171
|
-
...
|
|
172
|
-
},
|
|
173
|
-
message: "unknown", // exception message
|
|
174
|
-
name: "BMSPluginError", // class name
|
|
175
|
-
type: "ConfigParseException" // error type
|
|
176
|
-
}
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
## Default skin
|
|
180
|
-
To disable boomstream skin, use:
|
|
181
|
-
```js
|
|
182
|
-
player.boomstreamHls({ disableSkin: true });
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
## Plugins
|
|
186
|
-
Quality selection button:
|
|
187
|
-
```js
|
|
188
|
-
player.boomstreamHls({..., qualityPlugin: {disable: false, displayCurrentQuality: false, placementIndex: 0}});
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
## Custom playlist
|
|
192
|
-
videojs-hls-boomstream creates **bPlaylist** property on **player** object if you try to play playlist media content.
|
|
193
|
-
**bPlaylist** has the following interface:
|
|
194
|
-
```ts
|
|
195
|
-
interface bPlaylist {
|
|
196
|
-
setMediaByIndex(itemIndex: number): void;
|
|
197
|
-
setNextMedia(): void;
|
|
198
|
-
setPreviousMedia(): void;
|
|
199
|
-
enableAutoplay(delay: number): void;
|
|
200
|
-
disableAutoplay(): void;
|
|
201
|
-
getCurrentAutoplayConfig(): AutoplayConfig;
|
|
202
|
-
getCurrentPlaylist(): BMSPlaylistType;
|
|
203
|
-
getCurrentMedia(): BMSPlaylistItem;
|
|
204
|
-
}
|
|
205
|
-
```
|
|
206
|
-
**bPlaylist** uses the following types:
|
|
207
|
-
```ts
|
|
208
|
-
type AutoplayConfig = {
|
|
209
|
-
enabled: boolean;
|
|
210
|
-
delay: number;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
type BMSPlaylistType = [BMSPlaylistItem, ...BMSPlaylistItem[]]
|
|
214
|
-
|
|
215
|
-
type BMSPlaylistItem = {
|
|
216
|
-
sources: BMSPlaylistItemSources;
|
|
217
|
-
poster: string;
|
|
218
|
-
posters: Poster[];
|
|
219
|
-
duration: number;
|
|
220
|
-
name: string;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
type Poster = {
|
|
224
|
-
height: number;
|
|
225
|
-
link: string;
|
|
226
|
-
width: number;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
enum VideoMimeTypesEnum {
|
|
230
|
-
XMPEG = 'application/x-mpegURL',
|
|
231
|
-
VNDAPPLEMPEGURL = 'application/vnd.apple.mpegurl',
|
|
232
|
-
THREEGPG = 'video/3gpp',
|
|
233
|
-
THREEGPG2 = 'video/3gpp2',
|
|
234
|
-
THREEGP2 = 'video/3gp2',
|
|
235
|
-
MPEG = 'video/mpeg',
|
|
236
|
-
MP4 = 'video/mp4',
|
|
237
|
-
OGG = 'video/ogg',
|
|
238
|
-
QUICKTIME = 'video/quicktime',
|
|
239
|
-
WEBM = 'video/webm',
|
|
240
|
-
LIVE = 'live'
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
type VideoMimeTypesList = `${VideoMimeTypesEnum}`;
|
|
244
|
-
|
|
245
|
-
type BoomstreamLinks = {
|
|
246
|
-
hls: string;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
type Source = {
|
|
250
|
-
bms: boolean;
|
|
251
|
-
code: string;
|
|
252
|
-
duration: number;
|
|
253
|
-
encoded?: boolean;
|
|
254
|
-
entityCode: string;
|
|
255
|
-
isPublish?: boolean;
|
|
256
|
-
link?: string | null;
|
|
257
|
-
links?: BoomstreamLinks;
|
|
258
|
-
isLive: boolean;
|
|
259
|
-
name: string;
|
|
260
|
-
poster: string;
|
|
261
|
-
posters: Poster[];
|
|
262
|
-
recovery_id: string;
|
|
263
|
-
src: string;
|
|
264
|
-
state: string;
|
|
265
|
-
type: VideoMimeTypesList;
|
|
266
|
-
token?: string;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
type BoomstreamPlayerTech = videojs.Tech & {
|
|
270
|
-
currentSource_: Source;
|
|
271
|
-
session: null | number;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
type BMSPlaylistItemSources = [Source, ...Source[]];
|
|
275
|
-
```
|
|
276
|
-
Below will be a description of the playlist methods:
|
|
277
|
-
- ```setMediaByIndex(itemIndex: number): void;``` - allows you to set media from playlist by index. ```itemIndex``` can be a finite ```BigInt``` or integer ```number``` >= 0. If you pass invalid data to this method it will print corresponding error in console and do nothing.
|
|
278
|
-
- ```setNextMedia(): void;``` - set next media in playlist. If current media was the last in playlist print corresponding warning message.
|
|
279
|
-
- ```setPreviousMedia(): void;``` - set previous media in playlist. If current media was the first in playlist print corresponding warning message.
|
|
280
|
-
- ```enableAutoplay(delay: number): void;``` - enable autoplay functional for playlist. If autoplay is enabled and user interacted with DOM, playlist loader automaticaly plays the media in playlist by a row with ```delay``` in seconds between playing playlist items. ```delay``` must be finite ```number``` >= 0. If ```delay``` is invalid method will print error message in console and do nothing. **Autoplay is disabled by default**. If you play current video when autoplay timeout is running timeout will be cleared.
|
|
281
|
-
- ```disableAutoplay(): void;``` - disables autoplay if it was enabled or do nothing.
|
|
282
|
-
- ```getCurrentAutoplayConfig(): AutoplayConfig;``` - returns current autoplay config (type is described above).
|
|
283
|
-
- ```getCurrentPlaylist(): BMSPlaylistType;``` - returns **copy** of current playlist (type is described above).
|
|
284
|
-
- ```getCurrentMedia(): BMSPlaylistItem;``` - returns **copy** of current media (type is described above).
|
|
285
|
-
|
|
286
|
-
## Quality API
|
|
287
|
-
videojs-hls-boomstream creates **bQuality** property on **player** object if you enable quality plugin in options.
|
|
288
|
-
**bQuality** has the following interface:
|
|
289
|
-
```ts
|
|
290
|
-
interface IQualityApi {
|
|
291
|
-
getQualityList: () => UsersQuality[];
|
|
292
|
-
getQualityById: (qualityId: string) => UsersQuality | undefined;
|
|
293
|
-
getSelectedQualityId: () => string;
|
|
294
|
-
setQualityById: (qualityId: string) => void;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
interface UsersQuality {
|
|
298
|
-
id: string;
|
|
299
|
-
bandwidth: number;
|
|
300
|
-
width?: number;
|
|
301
|
-
height?: number;
|
|
302
|
-
name?: string;
|
|
303
|
-
};
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
This api triggers (```player.trigger```) 2 types of events:
|
|
307
|
-
- ```qualities_initialized``` - triggers when quality list has been initialized (once for one media); has ```UsersQuality[]``` as a payload
|
|
308
|
-
- ```new_quality_selected``` - triggers every time a new quality sets by ```setQualityById``` method (not triggers when adaptive bitrate algorithm selects new quality when auto quality is setted); has quality id as a payload
|
|
309
|
-
|
|
310
|
-
Below will be a description of the quality api methods:
|
|
311
|
-
- ```getQualityList: () => UsersQuality[]``` - returns a list of available qualities for current media
|
|
312
|
-
- ```getQualityById: (qualityId: string) => UsersQuality | undefined``` - if ```qualityId``` isn't string print warning in console and return ```undefined```; returns a quality object if found in quality list otherwise return ```undefined```
|
|
313
|
-
- ```getSelectedQualityId: () => string``` - if selected quality is auto returns ```'auto'``` otherwise returns quality id
|
|
314
|
-
- ```setQualityById: (qualityId: string) => void``` - if ```qualityId``` isn't string prints error in console and do nothing; if ```qualityId``` equals id which has already been selected prints warning in console and do nothing; otherwise set new quality and triggers ```new_quality_selected``` event with qualityId payload;
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
## License
|
|
318
|
-
|
|
319
|
-
MIT. Copyright (c) support@boomstream.com
|
|
320
|
-
|
|
321
|
-
[videojs]: http://videojs.com/
|
|
1
|
+
# videojs-hls-boomstream
|
|
2
|
+
|
|
3
|
+
This plugin was developed for integration of videojs player and online video platform [Boomstream]( https://boomstream.com/ "Boomstream").
|
|
4
|
+
Try it and hls delivery will be as easy as one, two, three.
|
|
5
|
+
|
|
6
|
+
## Table of Contents
|
|
7
|
+
|
|
8
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
9
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
- [Installation](#installation)
|
|
13
|
+
- [Usage](#usage)
|
|
14
|
+
- [`<script>` Tag](#script-tag)
|
|
15
|
+
- [Browserify ES6](#browserify-es6)
|
|
16
|
+
- [License](#license)
|
|
17
|
+
|
|
18
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm install --save videojs-hls-boomstream
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
To include videojs-hls-boomstream on your website or web application, use any of the following methods.
|
|
28
|
+
|
|
29
|
+
### `<script>` Tag
|
|
30
|
+
|
|
31
|
+
This is the simplest case. Get the script in whatever way you prefer and include the plugin _after_ you include [video.js][videojs], so that the `videojs` global is available.
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<script src="//path/to/video.min.js"></script>
|
|
35
|
+
<script src="//path/to/videojs-hls-boomstream.min.js"></script>
|
|
36
|
+
<script>
|
|
37
|
+
var player = videojs('my-video', /*, <videojs options {}>, <ready callback ()>*/);
|
|
38
|
+
|
|
39
|
+
player.boomstreamHls();
|
|
40
|
+
player.src("<bms video source>");
|
|
41
|
+
</script>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Browserify ES6
|
|
45
|
+
|
|
46
|
+
When using with Browserify, install videojs-hls-boomstream via npm and import the plugin as you would any other module.
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
import videojs from 'video.js';
|
|
50
|
+
import * as BoomstreamHlsPlugin from "videojs-hls-boomstream";
|
|
51
|
+
|
|
52
|
+
...
|
|
53
|
+
BoomstreamHlsPlugin.init(videojs);
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
var player = videojs("my-video" /*, <videojs options {}>, <ready callback ()>*/);
|
|
57
|
+
player.boomstreamHls();
|
|
58
|
+
player.src("<bms video source>");
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Catch errors
|
|
62
|
+
player.error() returns the most recent error. you can listen to the error event:
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
player.on('error', function() {
|
|
66
|
+
console.log(player.error());
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
or
|
|
70
|
+
```js
|
|
71
|
+
import { BMSPluginError, BMSPluginErrorType } from 'videojs-hls-boomstream';
|
|
72
|
+
|
|
73
|
+
player.boomstreamHls({
|
|
74
|
+
onerror: (e: BMSPluginError) => {
|
|
75
|
+
switch(e.type) {
|
|
76
|
+
case BMSPluginErrorType.RESPONSE:
|
|
77
|
+
...
|
|
78
|
+
case BMSPluginErrorType.MEDIA:
|
|
79
|
+
...
|
|
80
|
+
case BMSPluginErrorType.CONFIG:
|
|
81
|
+
...
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Plugin error structure
|
|
88
|
+
```js
|
|
89
|
+
const enum BMSPluginErrorType {
|
|
90
|
+
RESPONSE = 'ResponseError',
|
|
91
|
+
MEDIA = 'MediaError',
|
|
92
|
+
CONFIG = 'ConfigParseException'
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
interface BMSPluginError {
|
|
96
|
+
type: BMSPluginErrorType;
|
|
97
|
+
code: number;
|
|
98
|
+
message: string;
|
|
99
|
+
data?: any;
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Plugin error types
|
|
104
|
+
- BMSPluginErrorType.RESPONSE - standart HTTP status codes (200, 300, 400, 500, etc.)
|
|
105
|
+
```js
|
|
106
|
+
BMSPluginError {
|
|
107
|
+
code: 404, // response code
|
|
108
|
+
data: { // optional response error data
|
|
109
|
+
...
|
|
110
|
+
},
|
|
111
|
+
message: "Not found", // response message
|
|
112
|
+
name: "BMSPluginError", // class name
|
|
113
|
+
type: "ResponseError" // error type
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
- BMSPluginErrorType.MEDIA - bms plugin media errors (code, message):
|
|
117
|
+
- 204, branding_processing
|
|
118
|
+
- 403, branding_geo
|
|
119
|
+
- 403, branding_protection
|
|
120
|
+
|
|
121
|
+
- 404, branding_deleted
|
|
122
|
+
- 404, branding_empty_playlist
|
|
123
|
+
- 404, branding_not_found
|
|
124
|
+
|
|
125
|
+
- 423, branding_access_expire
|
|
126
|
+
- 423, branding_contacts
|
|
127
|
+
- 423, branding_blocked
|
|
128
|
+
- 423, branding_locked
|
|
129
|
+
- 423, branding_sales_not_allowed
|
|
130
|
+
- 423, branding_zero_balance
|
|
131
|
+
**(The "branding_" prefix in the message appears when the branding option is enabled)**
|
|
132
|
+
-------------
|
|
133
|
+
|
|
134
|
+
- 204, processing
|
|
135
|
+
- 403, geo
|
|
136
|
+
- 403, protection
|
|
137
|
+
|
|
138
|
+
- 404, deleted
|
|
139
|
+
- 404, empty_playlist
|
|
140
|
+
- 404, not_found
|
|
141
|
+
|
|
142
|
+
- 423, access_expire
|
|
143
|
+
- 423, contacts
|
|
144
|
+
- 423, blocked
|
|
145
|
+
- 423, locked
|
|
146
|
+
- 423, sales_not_allowed
|
|
147
|
+
- 423, zero_balance
|
|
148
|
+
|
|
149
|
+
-------------
|
|
150
|
+
- 500, application_error
|
|
151
|
+
- 500, application_maintenance
|
|
152
|
+
|
|
153
|
+
```js
|
|
154
|
+
BMSPluginError {
|
|
155
|
+
code: 403, // error code
|
|
156
|
+
data: { // optional error data
|
|
157
|
+
code: 403,
|
|
158
|
+
message: "protection",
|
|
159
|
+
translate: "Access denied.<br/>Online Videoplatform <a href='https://boomstream.com' target='_blank'>boomstream.com</a>"
|
|
160
|
+
},
|
|
161
|
+
message: "player.403_protection", // localized message for MediaError
|
|
162
|
+
name: "BMSPluginError", // class name
|
|
163
|
+
type: "MediaError" // error type
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
- BMSPluginErrorType.CONFIG - occurs when config parsing has failed
|
|
167
|
+
```js
|
|
168
|
+
BMSPluginError {
|
|
169
|
+
code: 0, // constant
|
|
170
|
+
data: { // optional exception data
|
|
171
|
+
...
|
|
172
|
+
},
|
|
173
|
+
message: "unknown", // exception message
|
|
174
|
+
name: "BMSPluginError", // class name
|
|
175
|
+
type: "ConfigParseException" // error type
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Default skin
|
|
180
|
+
To disable boomstream skin, use:
|
|
181
|
+
```js
|
|
182
|
+
player.boomstreamHls({ disableSkin: true });
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Plugins
|
|
186
|
+
Quality selection button:
|
|
187
|
+
```js
|
|
188
|
+
player.boomstreamHls({..., qualityPlugin: {disable: false, displayCurrentQuality: false, placementIndex: 0}});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Custom playlist
|
|
192
|
+
videojs-hls-boomstream creates **bPlaylist** property on **player** object if you try to play playlist media content.
|
|
193
|
+
**bPlaylist** has the following interface:
|
|
194
|
+
```ts
|
|
195
|
+
interface bPlaylist {
|
|
196
|
+
setMediaByIndex(itemIndex: number): void;
|
|
197
|
+
setNextMedia(): void;
|
|
198
|
+
setPreviousMedia(): void;
|
|
199
|
+
enableAutoplay(delay: number): void;
|
|
200
|
+
disableAutoplay(): void;
|
|
201
|
+
getCurrentAutoplayConfig(): AutoplayConfig;
|
|
202
|
+
getCurrentPlaylist(): BMSPlaylistType;
|
|
203
|
+
getCurrentMedia(): BMSPlaylistItem;
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
**bPlaylist** uses the following types:
|
|
207
|
+
```ts
|
|
208
|
+
type AutoplayConfig = {
|
|
209
|
+
enabled: boolean;
|
|
210
|
+
delay: number;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
type BMSPlaylistType = [BMSPlaylistItem, ...BMSPlaylistItem[]]
|
|
214
|
+
|
|
215
|
+
type BMSPlaylistItem = {
|
|
216
|
+
sources: BMSPlaylistItemSources;
|
|
217
|
+
poster: string;
|
|
218
|
+
posters: Poster[];
|
|
219
|
+
duration: number;
|
|
220
|
+
name: string;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
type Poster = {
|
|
224
|
+
height: number;
|
|
225
|
+
link: string;
|
|
226
|
+
width: number;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
enum VideoMimeTypesEnum {
|
|
230
|
+
XMPEG = 'application/x-mpegURL',
|
|
231
|
+
VNDAPPLEMPEGURL = 'application/vnd.apple.mpegurl',
|
|
232
|
+
THREEGPG = 'video/3gpp',
|
|
233
|
+
THREEGPG2 = 'video/3gpp2',
|
|
234
|
+
THREEGP2 = 'video/3gp2',
|
|
235
|
+
MPEG = 'video/mpeg',
|
|
236
|
+
MP4 = 'video/mp4',
|
|
237
|
+
OGG = 'video/ogg',
|
|
238
|
+
QUICKTIME = 'video/quicktime',
|
|
239
|
+
WEBM = 'video/webm',
|
|
240
|
+
LIVE = 'live'
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
type VideoMimeTypesList = `${VideoMimeTypesEnum}`;
|
|
244
|
+
|
|
245
|
+
type BoomstreamLinks = {
|
|
246
|
+
hls: string;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
type Source = {
|
|
250
|
+
bms: boolean;
|
|
251
|
+
code: string;
|
|
252
|
+
duration: number;
|
|
253
|
+
encoded?: boolean;
|
|
254
|
+
entityCode: string;
|
|
255
|
+
isPublish?: boolean;
|
|
256
|
+
link?: string | null;
|
|
257
|
+
links?: BoomstreamLinks;
|
|
258
|
+
isLive: boolean;
|
|
259
|
+
name: string;
|
|
260
|
+
poster: string;
|
|
261
|
+
posters: Poster[];
|
|
262
|
+
recovery_id: string;
|
|
263
|
+
src: string;
|
|
264
|
+
state: string;
|
|
265
|
+
type: VideoMimeTypesList;
|
|
266
|
+
token?: string;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
type BoomstreamPlayerTech = videojs.Tech & {
|
|
270
|
+
currentSource_: Source;
|
|
271
|
+
session: null | number;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
type BMSPlaylistItemSources = [Source, ...Source[]];
|
|
275
|
+
```
|
|
276
|
+
Below will be a description of the playlist methods:
|
|
277
|
+
- ```setMediaByIndex(itemIndex: number): void;``` - allows you to set media from playlist by index. ```itemIndex``` can be a finite ```BigInt``` or integer ```number``` >= 0. If you pass invalid data to this method it will print corresponding error in console and do nothing.
|
|
278
|
+
- ```setNextMedia(): void;``` - set next media in playlist. If current media was the last in playlist print corresponding warning message.
|
|
279
|
+
- ```setPreviousMedia(): void;``` - set previous media in playlist. If current media was the first in playlist print corresponding warning message.
|
|
280
|
+
- ```enableAutoplay(delay: number): void;``` - enable autoplay functional for playlist. If autoplay is enabled and user interacted with DOM, playlist loader automaticaly plays the media in playlist by a row with ```delay``` in seconds between playing playlist items. ```delay``` must be finite ```number``` >= 0. If ```delay``` is invalid method will print error message in console and do nothing. **Autoplay is disabled by default**. If you play current video when autoplay timeout is running timeout will be cleared.
|
|
281
|
+
- ```disableAutoplay(): void;``` - disables autoplay if it was enabled or do nothing.
|
|
282
|
+
- ```getCurrentAutoplayConfig(): AutoplayConfig;``` - returns current autoplay config (type is described above).
|
|
283
|
+
- ```getCurrentPlaylist(): BMSPlaylistType;``` - returns **copy** of current playlist (type is described above).
|
|
284
|
+
- ```getCurrentMedia(): BMSPlaylistItem;``` - returns **copy** of current media (type is described above).
|
|
285
|
+
|
|
286
|
+
## Quality API
|
|
287
|
+
videojs-hls-boomstream creates **bQuality** property on **player** object if you enable quality plugin in options.
|
|
288
|
+
**bQuality** has the following interface:
|
|
289
|
+
```ts
|
|
290
|
+
interface IQualityApi {
|
|
291
|
+
getQualityList: () => UsersQuality[];
|
|
292
|
+
getQualityById: (qualityId: string) => UsersQuality | undefined;
|
|
293
|
+
getSelectedQualityId: () => string;
|
|
294
|
+
setQualityById: (qualityId: string) => void;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
interface UsersQuality {
|
|
298
|
+
id: string;
|
|
299
|
+
bandwidth: number;
|
|
300
|
+
width?: number;
|
|
301
|
+
height?: number;
|
|
302
|
+
name?: string;
|
|
303
|
+
};
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
This api triggers (```player.trigger```) 2 types of events:
|
|
307
|
+
- ```qualities_initialized``` - triggers when quality list has been initialized (once for one media); has ```UsersQuality[]``` as a payload
|
|
308
|
+
- ```new_quality_selected``` - triggers every time a new quality sets by ```setQualityById``` method (not triggers when adaptive bitrate algorithm selects new quality when auto quality is setted); has quality id as a payload
|
|
309
|
+
|
|
310
|
+
Below will be a description of the quality api methods:
|
|
311
|
+
- ```getQualityList: () => UsersQuality[]``` - returns a list of available qualities for current media
|
|
312
|
+
- ```getQualityById: (qualityId: string) => UsersQuality | undefined``` - if ```qualityId``` isn't string print warning in console and return ```undefined```; returns a quality object if found in quality list otherwise return ```undefined```
|
|
313
|
+
- ```getSelectedQualityId: () => string``` - if selected quality is auto returns ```'auto'``` otherwise returns quality id
|
|
314
|
+
- ```setQualityById: (qualityId: string) => void``` - if ```qualityId``` isn't string prints error in console and do nothing; if ```qualityId``` equals id which has already been selected prints warning in console and do nothing; otherwise set new quality and triggers ```new_quality_selected``` event with qualityId payload;
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
## License
|
|
318
|
+
|
|
319
|
+
MIT. Copyright (c) support@boomstream.com
|
|
320
|
+
|
|
321
|
+
[videojs]: http://videojs.com/
|