@gcorevideo/player 2.1.13 → 2.3.0
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/dist/index.js +208 -218
- package/lib/Player.d.ts +2 -1
- package/lib/Player.d.ts.map +1 -1
- package/lib/Player.js +28 -7
- package/lib/version.d.ts +2 -0
- package/lib/version.d.ts.map +1 -1
- package/lib/version.js +2 -0
- package/package.json +1 -1
- package/src/Player.ts +32 -7
- package/src/version.ts +2 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/assets/icons/new/arrow-left.svg +0 -5
- package/assets/icons/new/arrow-right.svg +0 -5
- package/assets/icons/new/check.svg +0 -5
- package/assets/icons/new/close.svg +0 -12
- package/assets/icons/new/full.svg +0 -8
- package/assets/icons/new/fullscreen-off.svg +0 -14
- package/assets/icons/new/fullscreen-on.svg +0 -14
- package/assets/icons/new/gear-hd.svg +0 -16
- package/assets/icons/new/gear.svg +0 -12
- package/assets/icons/new/hd.svg +0 -8
- package/assets/icons/new/pause.svg +0 -5
- package/assets/icons/new/pip.svg +0 -5
- package/assets/icons/new/play.svg +0 -10
- package/assets/icons/new/replayleft.svg +0 -5
- package/assets/icons/new/replayright.svg +0 -5
- package/assets/icons/new/speed.svg +0 -5
- package/assets/icons/new/stats.svg +0 -3
- package/assets/icons/new/stop.svg +0 -3
- package/assets/icons/new/subtitles-off.svg +0 -5
- package/assets/icons/new/subtitles-on.svg +0 -6
- package/assets/icons/new/volume-max.svg +0 -5
- package/assets/icons/new/volume-min.svg +0 -5
- package/assets/icons/new/volume-off.svg +0 -5
- package/assets/icons/old/cardboard.svg +0 -4
- package/assets/icons/old/close-share.svg +0 -13
- package/assets/icons/old/close.svg +0 -13
- package/assets/icons/old/fb.svg +0 -13
- package/assets/icons/old/fullscreen.svg +0 -12
- package/assets/icons/old/language.svg +0 -1
- package/assets/icons/old/pause.svg +0 -12
- package/assets/icons/old/play.svg +0 -12
- package/assets/icons/old/quality-arrow.svg +0 -13
- package/assets/icons/old/reload.svg +0 -4
- package/assets/icons/old/share.svg +0 -13
- package/assets/icons/old/sound-off.svg +0 -15
- package/assets/icons/old/sound-on.svg +0 -15
- package/assets/icons/old/streams.svg +0 -3
- package/assets/icons/old/twitter.svg +0 -13
- package/assets/icons/old/wn.svg +0 -15
- package/assets/icons/standard/01-play.svg +0 -3
- package/assets/icons/standard/02-pause.svg +0 -3
- package/assets/icons/standard/03-stop.svg +0 -3
- package/assets/icons/standard/04-volume.svg +0 -3
- package/assets/icons/standard/05-mute.svg +0 -3
- package/assets/icons/standard/06-expand.svg +0 -3
- package/assets/icons/standard/07-shrink.svg +0 -3
- package/assets/icons/standard/08-hd.svg +0 -3
- package/assets/icons/standard/09-cc.svg +0 -8
- package/assets/icons/standard/10-reload.svg +0 -4
- package/assets/style/main.scss +0 -50
- package/assets/style/theme.scss +0 -42
- package/assets/style/variables.scss +0 -7
- package/dist/index.css +0 -125
package/lib/Player.js
CHANGED
|
@@ -5,7 +5,6 @@ import { reportError, trace } from './trace/index.js';
|
|
|
5
5
|
import { PlayerEvent } from './types.js';
|
|
6
6
|
import DashPlayback from './plugins/dash-playback/DashPlayback.js';
|
|
7
7
|
import HlsPlayback from './plugins/hls-playback/HlsPlayback.js';
|
|
8
|
-
import '../assets/style/main.scss'; // TODO check if needed
|
|
9
8
|
const T = 'GPlayer';
|
|
10
9
|
const DEFAULT_OPTIONS = {
|
|
11
10
|
autoPlay: false,
|
|
@@ -28,6 +27,7 @@ export class Player {
|
|
|
28
27
|
emitter = new EventLite();
|
|
29
28
|
player = null;
|
|
30
29
|
ready = false;
|
|
30
|
+
rootNode = null;
|
|
31
31
|
tuneInTimerId = null;
|
|
32
32
|
tunedIn = false;
|
|
33
33
|
get activePlayback() {
|
|
@@ -43,6 +43,12 @@ export class Player {
|
|
|
43
43
|
return 'native';
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
+
get activeSource() {
|
|
47
|
+
if (!this.player?.core.activePlayback) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return this.player.core.activePlayback.options.src;
|
|
51
|
+
}
|
|
46
52
|
get bitrate() {
|
|
47
53
|
return this.bitrateInfo;
|
|
48
54
|
}
|
|
@@ -165,6 +171,7 @@ export class Player {
|
|
|
165
171
|
this.bindBitrateChangeHandler();
|
|
166
172
|
}
|
|
167
173
|
player.core.on(ClapprEvents.CORE_ACTIVE_CONTAINER_CHANGED, () => {
|
|
174
|
+
// this.trigger(Events.ContainerChanged)
|
|
168
175
|
this.bindBitrateChangeHandler();
|
|
169
176
|
}, null);
|
|
170
177
|
if (Browser.isiOS && player.core.activePlayback) {
|
|
@@ -178,7 +185,19 @@ export class Player {
|
|
|
178
185
|
});
|
|
179
186
|
}
|
|
180
187
|
player.core.on(ClapprEvents.CORE_SCREEN_ORIENTATION_CHANGED, ({ orientation }) => {
|
|
181
|
-
trace(`${T} CORE_SCREEN_ORIENTATION_CHANGED`, {
|
|
188
|
+
trace(`${T} CORE_SCREEN_ORIENTATION_CHANGED`, {
|
|
189
|
+
orientation,
|
|
190
|
+
rootNode: {
|
|
191
|
+
width: this.rootNode?.clientWidth,
|
|
192
|
+
height: this.rootNode?.clientHeight,
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
if (Browser.isiOS && this.rootNode) {
|
|
196
|
+
player.core.resize({
|
|
197
|
+
width: this.rootNode.clientWidth,
|
|
198
|
+
height: this.rootNode.clientHeight,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
182
201
|
}, null);
|
|
183
202
|
player.core.on(ClapprEvents.CORE_RESIZE, ({ width, height }) => {
|
|
184
203
|
trace(`${T} CORE_RESIZE`, {
|
|
@@ -216,7 +235,7 @@ export class Player {
|
|
|
216
235
|
setTimeout(() => this.tuneIn(), 0);
|
|
217
236
|
},
|
|
218
237
|
onResize: (newSize) => {
|
|
219
|
-
trace(`${T}
|
|
238
|
+
trace(`${T} onResize`, {
|
|
220
239
|
newSize,
|
|
221
240
|
});
|
|
222
241
|
},
|
|
@@ -253,7 +272,7 @@ export class Player {
|
|
|
253
272
|
}
|
|
254
273
|
},
|
|
255
274
|
};
|
|
256
|
-
buildCoreOptions(
|
|
275
|
+
buildCoreOptions(rootNode) {
|
|
257
276
|
const multisources = this.config.multisources;
|
|
258
277
|
const mainSource = this.config.playbackType === 'live'
|
|
259
278
|
? multisources.find((ms) => ms.live !== false)
|
|
@@ -263,13 +282,14 @@ export class Player {
|
|
|
263
282
|
: [];
|
|
264
283
|
// const mainSourceUrl = mediaSources[0];
|
|
265
284
|
const poster = mainSource?.poster ?? this.config.poster;
|
|
285
|
+
this.rootNode = rootNode;
|
|
266
286
|
const coreOptions = {
|
|
267
287
|
...this.config.pluginSettings,
|
|
268
288
|
allowUserInteraction: true,
|
|
269
289
|
autoPlay: false,
|
|
270
290
|
debug: this.config.debug || 'none',
|
|
271
291
|
events: this.events,
|
|
272
|
-
height:
|
|
292
|
+
height: rootNode.clientHeight,
|
|
273
293
|
loop: this.config.loop,
|
|
274
294
|
multisources,
|
|
275
295
|
mute: this.config.mute,
|
|
@@ -283,10 +303,10 @@ export class Player {
|
|
|
283
303
|
debug: this.config.debug === 'all' || this.config.debug === 'hls',
|
|
284
304
|
},
|
|
285
305
|
},
|
|
286
|
-
parent:
|
|
306
|
+
parent: rootNode,
|
|
287
307
|
playbackType: this.config.playbackType,
|
|
288
308
|
poster,
|
|
289
|
-
width:
|
|
309
|
+
width: rootNode.clientWidth,
|
|
290
310
|
// source: mainSourceUrl,
|
|
291
311
|
sources: mediaSources,
|
|
292
312
|
strings: this.config.strings,
|
|
@@ -294,6 +314,7 @@ export class Player {
|
|
|
294
314
|
return coreOptions;
|
|
295
315
|
}
|
|
296
316
|
configurePlaybacks() {
|
|
317
|
+
// TODO check if there are DASH and HLS sources and don't register the respective playbacks if not
|
|
297
318
|
Loader.registerPlayback(DashPlayback);
|
|
298
319
|
Loader.registerPlayback(HlsPlayback);
|
|
299
320
|
}
|
package/lib/version.d.ts
CHANGED
package/lib/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAGA,wBAAgB,OAAO
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAGA,wBAAgB,OAAO;;;;;EAOtB"}
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
package/src/Player.ts
CHANGED
|
@@ -25,7 +25,7 @@ import { PlayerConfig, PlayerEvent } from './types.js'
|
|
|
25
25
|
import DashPlayback from './plugins/dash-playback/DashPlayback.js'
|
|
26
26
|
import HlsPlayback from './plugins/hls-playback/HlsPlayback.js'
|
|
27
27
|
|
|
28
|
-
import '../assets/style/main.scss' // TODO check if needed
|
|
28
|
+
// import '../assets/style/main.scss' // TODO check if needed
|
|
29
29
|
|
|
30
30
|
// TODO implement transport retry/failover and fallback logic
|
|
31
31
|
|
|
@@ -64,6 +64,8 @@ export class Player {
|
|
|
64
64
|
|
|
65
65
|
private ready = false
|
|
66
66
|
|
|
67
|
+
private rootNode: HTMLElement | null = null
|
|
68
|
+
|
|
67
69
|
private tuneInTimerId: ReturnType<typeof setTimeout> | null = null
|
|
68
70
|
|
|
69
71
|
private tunedIn = false
|
|
@@ -82,6 +84,13 @@ export class Player {
|
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
86
|
|
|
87
|
+
get activeSource(): string | null {
|
|
88
|
+
if (!this.player?.core.activePlayback) {
|
|
89
|
+
return null
|
|
90
|
+
}
|
|
91
|
+
return this.player.core.activePlayback.options.src
|
|
92
|
+
}
|
|
93
|
+
|
|
85
94
|
get bitrate(): BitrateInfo | null {
|
|
86
95
|
return this.bitrateInfo
|
|
87
96
|
}
|
|
@@ -227,6 +236,7 @@ export class Player {
|
|
|
227
236
|
player.core.on(
|
|
228
237
|
ClapprEvents.CORE_ACTIVE_CONTAINER_CHANGED,
|
|
229
238
|
() => {
|
|
239
|
+
// this.trigger(Events.ContainerChanged)
|
|
230
240
|
this.bindBitrateChangeHandler()
|
|
231
241
|
},
|
|
232
242
|
null,
|
|
@@ -243,7 +253,19 @@ export class Player {
|
|
|
243
253
|
player.core.on(
|
|
244
254
|
ClapprEvents.CORE_SCREEN_ORIENTATION_CHANGED,
|
|
245
255
|
({ orientation }: { orientation: 'landscape' | 'portrait' }) => {
|
|
246
|
-
trace(`${T} CORE_SCREEN_ORIENTATION_CHANGED`, {
|
|
256
|
+
trace(`${T} CORE_SCREEN_ORIENTATION_CHANGED`, {
|
|
257
|
+
orientation,
|
|
258
|
+
rootNode: {
|
|
259
|
+
width: this.rootNode?.clientWidth,
|
|
260
|
+
height: this.rootNode?.clientHeight,
|
|
261
|
+
},
|
|
262
|
+
})
|
|
263
|
+
if (Browser.isiOS && this.rootNode) {
|
|
264
|
+
player.core.resize({
|
|
265
|
+
width: this.rootNode.clientWidth,
|
|
266
|
+
height: this.rootNode.clientHeight,
|
|
267
|
+
})
|
|
268
|
+
}
|
|
247
269
|
},
|
|
248
270
|
null,
|
|
249
271
|
)
|
|
@@ -288,7 +310,7 @@ export class Player {
|
|
|
288
310
|
setTimeout(() => this.tuneIn(), 0)
|
|
289
311
|
},
|
|
290
312
|
onResize: (newSize: { width: number; height: number }) => {
|
|
291
|
-
trace(`${T}
|
|
313
|
+
trace(`${T} onResize`, {
|
|
292
314
|
newSize,
|
|
293
315
|
})
|
|
294
316
|
},
|
|
@@ -322,7 +344,7 @@ export class Player {
|
|
|
322
344
|
},
|
|
323
345
|
}
|
|
324
346
|
|
|
325
|
-
private buildCoreOptions(
|
|
347
|
+
private buildCoreOptions(rootNode: HTMLElement): CoreOptions {
|
|
326
348
|
const multisources = this.config.multisources
|
|
327
349
|
const mainSource =
|
|
328
350
|
this.config.playbackType === 'live'
|
|
@@ -334,13 +356,15 @@ export class Player {
|
|
|
334
356
|
// const mainSourceUrl = mediaSources[0];
|
|
335
357
|
const poster = mainSource?.poster ?? this.config.poster
|
|
336
358
|
|
|
359
|
+
this.rootNode = rootNode
|
|
360
|
+
|
|
337
361
|
const coreOptions: CoreOptions & PluginOptions = {
|
|
338
362
|
...this.config.pluginSettings,
|
|
339
363
|
allowUserInteraction: true,
|
|
340
364
|
autoPlay: false,
|
|
341
365
|
debug: this.config.debug || 'none',
|
|
342
366
|
events: this.events,
|
|
343
|
-
height:
|
|
367
|
+
height: rootNode.clientHeight,
|
|
344
368
|
loop: this.config.loop,
|
|
345
369
|
multisources,
|
|
346
370
|
mute: this.config.mute,
|
|
@@ -354,10 +378,10 @@ export class Player {
|
|
|
354
378
|
debug: this.config.debug === 'all' || this.config.debug === 'hls',
|
|
355
379
|
},
|
|
356
380
|
},
|
|
357
|
-
parent:
|
|
381
|
+
parent: rootNode,
|
|
358
382
|
playbackType: this.config.playbackType,
|
|
359
383
|
poster,
|
|
360
|
-
width:
|
|
384
|
+
width: rootNode.clientWidth,
|
|
361
385
|
// source: mainSourceUrl,
|
|
362
386
|
sources: mediaSources,
|
|
363
387
|
strings: this.config.strings,
|
|
@@ -366,6 +390,7 @@ export class Player {
|
|
|
366
390
|
}
|
|
367
391
|
|
|
368
392
|
private configurePlaybacks() {
|
|
393
|
+
// TODO check if there are DASH and HLS sources and don't register the respective playbacks if not
|
|
369
394
|
Loader.registerPlayback(DashPlayback)
|
|
370
395
|
Loader.registerPlayback(HlsPlayback)
|
|
371
396
|
}
|
package/src/version.ts
CHANGED