@gcorevideo/player 0.0.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/assets/icons/new/arrow-left.svg +5 -0
- package/assets/icons/new/arrow-right.svg +5 -0
- package/assets/icons/new/check.svg +5 -0
- package/assets/icons/new/close.svg +12 -0
- package/assets/icons/new/full.svg +8 -0
- package/assets/icons/new/fullscreen-off.svg +14 -0
- package/assets/icons/new/fullscreen-on.svg +14 -0
- package/assets/icons/new/gear-hd.svg +16 -0
- package/assets/icons/new/gear.svg +12 -0
- package/assets/icons/new/hd.svg +8 -0
- package/assets/icons/new/pause.svg +5 -0
- package/assets/icons/new/pip.svg +5 -0
- package/assets/icons/new/play.svg +10 -0
- package/assets/icons/new/replayleft.svg +5 -0
- package/assets/icons/new/replayright.svg +5 -0
- package/assets/icons/new/speed.svg +5 -0
- package/assets/icons/new/stats.svg +3 -0
- package/assets/icons/new/stop.svg +3 -0
- package/assets/icons/new/subtitles-off.svg +5 -0
- package/assets/icons/new/subtitles-on.svg +6 -0
- package/assets/icons/new/volume-max.svg +5 -0
- package/assets/icons/new/volume-min.svg +5 -0
- package/assets/icons/new/volume-off.svg +5 -0
- package/assets/icons/old/cardboard.svg +4 -0
- package/assets/icons/old/close-share.svg +13 -0
- package/assets/icons/old/close.svg +13 -0
- package/assets/icons/old/fb.svg +13 -0
- package/assets/icons/old/fullscreen.svg +12 -0
- package/assets/icons/old/language.svg +1 -0
- package/assets/icons/old/pause.svg +12 -0
- package/assets/icons/old/play.svg +12 -0
- package/assets/icons/old/quality-arrow.svg +13 -0
- package/assets/icons/old/reload.svg +4 -0
- package/assets/icons/old/share.svg +13 -0
- package/assets/icons/old/sound-off.svg +15 -0
- package/assets/icons/old/sound-on.svg +15 -0
- package/assets/icons/old/streams.svg +3 -0
- package/assets/icons/old/twitter.svg +13 -0
- package/assets/icons/old/wn.svg +15 -0
- package/assets/icons/standard/01-play.svg +3 -0
- package/assets/icons/standard/02-pause.svg +3 -0
- package/assets/icons/standard/03-stop.svg +3 -0
- package/assets/icons/standard/04-volume.svg +3 -0
- package/assets/icons/standard/05-mute.svg +3 -0
- package/assets/icons/standard/06-expand.svg +3 -0
- package/assets/icons/standard/07-shrink.svg +3 -0
- package/assets/icons/standard/08-hd.svg +3 -0
- package/assets/icons/standard/09-cc.svg +8 -0
- package/assets/icons/standard/10-reload.svg +4 -0
- package/assets/style/main.scss +50 -0
- package/assets/style/theme.scss +42 -0
- package/assets/style/variables.scss +7 -0
- package/dist/DashPlayback-6wKK0_pL.js +666 -0
- package/dist/DashPlayback-8U6_s4Jc.js +666 -0
- package/dist/DashPlayback-BeZz7mN9.js +663 -0
- package/dist/DashPlayback-CRdja67F.js +667 -0
- package/dist/DashPlayback-D0df6zGg.js +663 -0
- package/dist/DashPlayback-D7egS-CZ.js +664 -0
- package/dist/DashPlayback-DH5lZMRR.js +663 -0
- package/dist/DashPlayback-DZfIc9sK.js +665 -0
- package/dist/DashPlayback-VhCxbQhn.js +666 -0
- package/dist/HlsPlayback-Avwy8-0O.js +749 -0
- package/dist/index.css +125 -0
- package/dist/index.js +467 -0
- package/lib/Player.d.ts +50 -0
- package/lib/Player.d.ts.map +1 -0
- package/lib/Player.js +310 -0
- package/lib/backend.d.ts +3 -0
- package/lib/backend.d.ts.map +1 -0
- package/lib/backend.js +10 -0
- package/lib/constants.d.ts +19 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +18 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +9 -0
- package/lib/internal.types.d.ts +105 -0
- package/lib/internal.types.d.ts.map +1 -0
- package/lib/internal.types.js +1 -0
- package/lib/playback.types.d.ts +13 -0
- package/lib/playback.types.d.ts.map +1 -0
- package/lib/playback.types.js +1 -0
- package/lib/plugins/audio-selector/AudioSelector.d.ts +48 -0
- package/lib/plugins/audio-selector/AudioSelector.d.ts.map +1 -0
- package/lib/plugins/audio-selector/AudioSelector.js +282 -0
- package/lib/plugins/big-mute-button/BigMuteButton.d.ts +33 -0
- package/lib/plugins/big-mute-button/BigMuteButton.d.ts.map +1 -0
- package/lib/plugins/big-mute-button/BigMuteButton.js +148 -0
- package/lib/plugins/bottom-gear/BottomGear.d.ts +30 -0
- package/lib/plugins/bottom-gear/BottomGear.d.ts.map +1 -0
- package/lib/plugins/bottom-gear/BottomGear.js +103 -0
- package/lib/plugins/click-to-pause/ClickToPause.d.ts +16 -0
- package/lib/plugins/click-to-pause/ClickToPause.d.ts.map +1 -0
- package/lib/plugins/click-to-pause/ClickToPause.js +73 -0
- package/lib/plugins/dash-playback/DashPlayback.d.ts +81 -0
- package/lib/plugins/dash-playback/DashPlayback.d.ts.map +1 -0
- package/lib/plugins/dash-playback/DashPlayback.js +658 -0
- package/lib/plugins/dash-plugin/DashPlayback.d.ts +86 -0
- package/lib/plugins/dash-plugin/DashPlayback.d.ts.map +1 -0
- package/lib/plugins/dash-plugin/DashPlayback.js +659 -0
- package/lib/plugins/disable-controls/DisableControls.d.ts +15 -0
- package/lib/plugins/disable-controls/DisableControls.d.ts.map +1 -0
- package/lib/plugins/disable-controls/DisableControls.js +69 -0
- package/lib/plugins/dvr-controls/DVRControls.d.ts +27 -0
- package/lib/plugins/dvr-controls/DVRControls.d.ts.map +1 -0
- package/lib/plugins/dvr-controls/DVRControls.js +110 -0
- package/lib/plugins/hls-playback/HlsPlayback.d.ts +102 -0
- package/lib/plugins/hls-playback/HlsPlayback.d.ts.map +1 -0
- package/lib/plugins/hls-playback/HlsPlayback.js +747 -0
- package/lib/plugins/level-selector/LevelSelector.d.ts +48 -0
- package/lib/plugins/level-selector/LevelSelector.d.ts.map +1 -0
- package/lib/plugins/level-selector/LevelSelector.js +287 -0
- package/lib/plugins/media-control/MediaControl.d.ts +186 -0
- package/lib/plugins/media-control/MediaControl.d.ts.map +1 -0
- package/lib/plugins/media-control/MediaControl.js +1000 -0
- package/lib/plugins/poster/Poster.d.ts +41 -0
- package/lib/plugins/poster/Poster.d.ts.map +1 -0
- package/lib/plugins/poster/Poster.js +186 -0
- package/lib/trace/LogTracer.d.ts +12 -0
- package/lib/trace/LogTracer.d.ts.map +1 -0
- package/lib/trace/LogTracer.js +17 -0
- package/lib/trace/SentryTracer.d.ts +11 -0
- package/lib/trace/SentryTracer.d.ts.map +1 -0
- package/lib/trace/SentryTracer.js +18 -0
- package/lib/trace/Tracer.d.ts +13 -0
- package/lib/trace/Tracer.d.ts.map +1 -0
- package/lib/trace/Tracer.js +15 -0
- package/lib/trace/index.d.ts +18 -0
- package/lib/trace/index.d.ts.map +1 -0
- package/lib/trace/index.js +27 -0
- package/lib/trace/types.d.ts +8 -0
- package/lib/trace/types.d.ts.map +1 -0
- package/lib/trace/types.js +1 -0
- package/lib/types.d.ts +82 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +1 -0
- package/lib/utils/Logger.d.ts +23 -0
- package/lib/utils/Logger.d.ts.map +1 -0
- package/lib/utils/Logger.js +81 -0
- package/lib/utils/canAutoplay.d.ts +6 -0
- package/lib/utils/canAutoplay.d.ts.map +1 -0
- package/lib/utils/canAutoplay.js +30 -0
- package/lib/utils/errors.d.ts +2 -0
- package/lib/utils/errors.d.ts.map +1 -0
- package/lib/utils/errors.js +6 -0
- package/lib/utils/queryParams.d.ts +2 -0
- package/lib/utils/queryParams.d.ts.map +1 -0
- package/lib/utils/queryParams.js +4 -0
- package/lib/utils/scripts-load.d.ts +2 -0
- package/lib/utils/scripts-load.d.ts.map +1 -0
- package/lib/utils/scripts-load.js +20 -0
- package/lib/utils/types.d.ts +4 -0
- package/lib/utils/types.d.ts.map +1 -0
- package/lib/utils/types.js +1 -0
- package/lib/utils/utils.d.ts +7 -0
- package/lib/utils/utils.d.ts.map +1 -0
- package/lib/utils/utils.js +57 -0
- package/package.json +57 -0
- package/rollup.config.js +34 -0
- package/src/Player.ts +390 -0
- package/src/backend.ts +12 -0
- package/src/constants.ts +17 -0
- package/src/index.ts +9 -0
- package/src/internal.types.ts +126 -0
- package/src/playback.types.ts +15 -0
- package/src/plugins/dash-playback/DashPlayback.ts +808 -0
- package/src/plugins/dash-playback/_DashPlayback.js +688 -0
- package/src/plugins/hls-playback/HlsPlayback.ts +909 -0
- package/src/plugins/hls-playback/hls.js +706 -0
- package/src/trace/LogTracer.ts +23 -0
- package/src/trace/SentryTracer.ts +18 -0
- package/src/trace/Tracer.ts +27 -0
- package/src/trace/index.ts +32 -0
- package/src/trace/types.ts +7 -0
- package/src/types.ts +100 -0
- package/src/typings/@clappr/core/error_mixin.d.ts +15 -0
- package/src/typings/@clappr/core/events.d.ts +7 -0
- package/src/typings/@clappr/core/html5_video.d.ts +28 -0
- package/src/typings/@clappr/core/playback.d.ts +5 -0
- package/src/typings/@clappr/core/player.d.ts +83 -0
- package/src/typings/@clappr/plugins.d.ts +29 -0
- package/src/typings/clappr-zepto.xd.xts +44 -0
- package/src/typings/globals.d.ts +8 -0
- package/src/utils/Logger.ts +107 -0
- package/src/utils/canAutoplay.ts +39 -0
- package/src/utils/errors.ts +6 -0
- package/src/utils/queryParams.ts +5 -0
- package/src/utils/scripts-load.ts +26 -0
- package/src/utils/types.ts +5 -0
- package/src/utils/utils.ts +64 -0
- package/tsconfig.json +43 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { UIContainerPlugin, Container } from '@clappr/core';
|
|
2
|
+
import '../../../assets/plugins/poster/poster.scss';
|
|
3
|
+
export default class Poster extends UIContainerPlugin {
|
|
4
|
+
private hasFatalError;
|
|
5
|
+
private hasStartedPlaying;
|
|
6
|
+
private playRequested;
|
|
7
|
+
private $playButton;
|
|
8
|
+
private $playWrapper;
|
|
9
|
+
get name(): string;
|
|
10
|
+
get supportedVersion(): {
|
|
11
|
+
min: string;
|
|
12
|
+
};
|
|
13
|
+
get template(): any;
|
|
14
|
+
get shouldRender(): boolean;
|
|
15
|
+
get attributes(): {
|
|
16
|
+
class: string;
|
|
17
|
+
'data-poster': string;
|
|
18
|
+
};
|
|
19
|
+
get events(): {
|
|
20
|
+
click: string;
|
|
21
|
+
};
|
|
22
|
+
get showOnVideoEnd(): any;
|
|
23
|
+
constructor(container: Container);
|
|
24
|
+
bindEvents(): void;
|
|
25
|
+
private onError;
|
|
26
|
+
onPlay(): void;
|
|
27
|
+
onStop(): void;
|
|
28
|
+
updatePlayButton(show: boolean): void;
|
|
29
|
+
showPlayButton(): void;
|
|
30
|
+
hidePlayButton(): void;
|
|
31
|
+
clicked(): boolean;
|
|
32
|
+
shouldHideOnPlay(): boolean;
|
|
33
|
+
update(): void;
|
|
34
|
+
updatePoster(): void;
|
|
35
|
+
showPoster(): void;
|
|
36
|
+
hidePoster(): void;
|
|
37
|
+
render(): this;
|
|
38
|
+
removeVideoElementPoster(): void;
|
|
39
|
+
destroy(): this;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=Poster.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Poster.d.ts","sourceRoot":"","sources":["../../../src/plugins/poster/Poster.ts"],"names":[],"mappings":"AAIA,OAAO,EAAiC,iBAAiB,EAAe,SAAS,EAAE,MAAM,cAAc,CAAC;AAExG,OAAO,4CAA4C,CAAC;AAapD,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,iBAAiB;IACnD,OAAO,CAAC,aAAa,CAAS;IAE9B,OAAO,CAAC,iBAAiB,CAAS;IAElC,OAAO,CAAC,aAAa,CAAS;IAE9B,OAAO,CAAC,WAAW,CAA4B;IAE/C,OAAO,CAAC,YAAY,CAA4B;IAEhD,IAAI,IAAI,WAEP;IAED,IAAI,gBAAgB;;MAEnB;IAED,IAAI,QAAQ,QAEX;IAED,IAAI,YAAY,YAIf;IAED,IAAI,UAAU;;;MAKb;IAED,IAAI,MAAM;;MAIT;IAED,IAAI,cAAc,QAEjB;gBAEW,SAAS,EAAE,SAAS;IAOhC,UAAU;IAWV,OAAO,CAAC,OAAO;IAWf,MAAM;IAKN,MAAM;IAMN,gBAAgB,CAAC,IAAI,EAAE,OAAO;IAQ9B,cAAc;IAad,cAAc;IAKd,OAAO;IAiBP,gBAAgB;IAKhB,MAAM;IAWN,YAAY;IAQZ,UAAU;IAKV,UAAU;IASV,MAAM;IAoCN,wBAAwB;IAQxB,OAAO;CAIR"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
//Copyright 2014 Globo.com Player authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style
|
|
3
|
+
// license that can be found in the LICENSE file.
|
|
4
|
+
import { Events, Playback, PlayerError, UIContainerPlugin, template, $ } from '@clappr/core';
|
|
5
|
+
import '../../../assets/plugins/poster/poster.scss';
|
|
6
|
+
import posterHTML from '../../../assets/plugins/poster/poster.ejs';
|
|
7
|
+
import playIcon from '../../../assets/icons/new/play.svg';
|
|
8
|
+
import assert from 'assert';
|
|
9
|
+
const T = 'plugins.poster_custom';
|
|
10
|
+
assert(process.env.CLAPPR_VERSION, 'CLAPPR_VERSION is required');
|
|
11
|
+
const CLAPPR_VERSION = process.env.CLAPPR_VERSION;
|
|
12
|
+
export default class Poster extends UIContainerPlugin {
|
|
13
|
+
hasFatalError = false;
|
|
14
|
+
hasStartedPlaying = false;
|
|
15
|
+
playRequested = false;
|
|
16
|
+
$playButton = null;
|
|
17
|
+
$playWrapper = null;
|
|
18
|
+
get name() {
|
|
19
|
+
return 'poster_custom';
|
|
20
|
+
}
|
|
21
|
+
get supportedVersion() {
|
|
22
|
+
return { min: CLAPPR_VERSION };
|
|
23
|
+
}
|
|
24
|
+
get template() {
|
|
25
|
+
return template(posterHTML);
|
|
26
|
+
}
|
|
27
|
+
get shouldRender() {
|
|
28
|
+
const showForNoOp = !!(this.options.poster && this.options.poster.showForNoOp);
|
|
29
|
+
return this.container.playback.name !== 'html_img' && (this.container.playback.getPlaybackType() !== Playback.NO_OP || showForNoOp);
|
|
30
|
+
}
|
|
31
|
+
get attributes() {
|
|
32
|
+
return {
|
|
33
|
+
'class': 'player-poster',
|
|
34
|
+
'data-poster': ''
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
get events() {
|
|
38
|
+
return {
|
|
39
|
+
'click': 'clicked'
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
get showOnVideoEnd() {
|
|
43
|
+
return !this.options.poster || this.options.poster.showOnVideoEnd || this.options.poster.showOnVideoEnd === undefined;
|
|
44
|
+
}
|
|
45
|
+
constructor(container) {
|
|
46
|
+
super(container);
|
|
47
|
+
this.render();
|
|
48
|
+
setTimeout(() => this.update(), 0);
|
|
49
|
+
}
|
|
50
|
+
bindEvents() {
|
|
51
|
+
this.listenTo(this.container, Events.CONTAINER_STOP, this.onStop);
|
|
52
|
+
this.listenTo(this.container, Events.CONTAINER_PLAY, this.onPlay);
|
|
53
|
+
this.listenTo(this.container, Events.CONTAINER_STATE_BUFFERING, this.update);
|
|
54
|
+
this.listenTo(this.container, Events.CONTAINER_STATE_BUFFERFULL, this.update);
|
|
55
|
+
this.listenTo(this.container, Events.CONTAINER_OPTIONS_CHANGE, this.render);
|
|
56
|
+
this.listenTo(this.container, Events.CONTAINER_ERROR, this.onError);
|
|
57
|
+
this.showOnVideoEnd && this.listenTo(this.container, Events.CONTAINER_ENDED, this.onStop);
|
|
58
|
+
this.listenTo(this.container, Events.CONTAINER_READY, this.render);
|
|
59
|
+
}
|
|
60
|
+
onError(error) {
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
this.hasFatalError = error.level === PlayerError.Levels.FATAL;
|
|
63
|
+
if (this.hasFatalError) {
|
|
64
|
+
this.hasStartedPlaying = false;
|
|
65
|
+
this.playRequested = false;
|
|
66
|
+
this.showPlayButton();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
onPlay() {
|
|
70
|
+
this.hasStartedPlaying = true;
|
|
71
|
+
this.update();
|
|
72
|
+
}
|
|
73
|
+
onStop() {
|
|
74
|
+
this.hasStartedPlaying = false;
|
|
75
|
+
this.playRequested = false;
|
|
76
|
+
this.update();
|
|
77
|
+
}
|
|
78
|
+
updatePlayButton(show) {
|
|
79
|
+
if (show && (!this.options.chromeless || this.options.allowUserInteraction)) {
|
|
80
|
+
this.showPlayButton();
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
this.hidePlayButton();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
showPlayButton() {
|
|
87
|
+
if (this.options.disableMediaControl) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (this.hasFatalError && !this.options.disableErrorScreen) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
this.$playButton?.show();
|
|
94
|
+
this.$el.addClass('clickable');
|
|
95
|
+
this.container.$el.addClass('container-with-poster-clickable');
|
|
96
|
+
}
|
|
97
|
+
hidePlayButton() {
|
|
98
|
+
this.$playButton.hide();
|
|
99
|
+
this.$el.removeClass('clickable');
|
|
100
|
+
}
|
|
101
|
+
clicked() {
|
|
102
|
+
// Let "click_to_pause" plugin handle click event if media has started playing
|
|
103
|
+
if (!this.hasStartedPlaying) {
|
|
104
|
+
if (!this.options.chromeless || this.options.allowUserInteraction) {
|
|
105
|
+
this.playRequested = true;
|
|
106
|
+
this.update();
|
|
107
|
+
this.container.playback && (this.container.playback._consented = true);
|
|
108
|
+
this.container.play();
|
|
109
|
+
}
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
this.container.trigger('container:start');
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
shouldHideOnPlay() {
|
|
116
|
+
// Audio broadcasts should keep the poster up; video should hide poster while playing.
|
|
117
|
+
return !this.container.playback.isAudioOnly;
|
|
118
|
+
}
|
|
119
|
+
update() {
|
|
120
|
+
if (!this.shouldRender) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const showPlayButton = !this.playRequested && !this.hasStartedPlaying && !this.container.buffering;
|
|
124
|
+
this.updatePlayButton(showPlayButton);
|
|
125
|
+
this.updatePoster();
|
|
126
|
+
}
|
|
127
|
+
updatePoster() {
|
|
128
|
+
if (!this.hasStartedPlaying) {
|
|
129
|
+
this.showPoster();
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
this.hidePoster();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
showPoster() {
|
|
136
|
+
this.container.disableMediaControl();
|
|
137
|
+
this.$el.show();
|
|
138
|
+
}
|
|
139
|
+
hidePoster() {
|
|
140
|
+
if (!this.options.disableMediaControl) {
|
|
141
|
+
this.container.enableMediaControl();
|
|
142
|
+
}
|
|
143
|
+
if (this.shouldHideOnPlay()) {
|
|
144
|
+
this.$el.hide();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
render() {
|
|
148
|
+
if (!this.shouldRender) {
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
this.$el.html(this.template());
|
|
152
|
+
const isRegularPoster = this.options.poster && this.options.poster.custom === undefined;
|
|
153
|
+
if (isRegularPoster) {
|
|
154
|
+
const posterUrl = this.options.poster.url || this.options.poster;
|
|
155
|
+
this.$el.css({ 'background-image': 'url(' + posterUrl + ')' });
|
|
156
|
+
}
|
|
157
|
+
else if (this.options.poster) {
|
|
158
|
+
this.$el.css({ 'background': this.options.poster.custom });
|
|
159
|
+
}
|
|
160
|
+
this.container.$el.removeClass('container-with-poster-clickable');
|
|
161
|
+
this.container.$el.append(this.el);
|
|
162
|
+
this.$playWrapper = this.$el.find('.play-wrapper');
|
|
163
|
+
this.$playWrapper.addClass('control-need-disable');
|
|
164
|
+
this.$playButton = $('<div class=\'circle-poster gcore-skin-button-color gcore-skin-border-color\'></div>');
|
|
165
|
+
this.$playWrapper.append(this.$playButton);
|
|
166
|
+
this.$playButton.append(playIcon);
|
|
167
|
+
if (this.options.autoPlay) {
|
|
168
|
+
this.$playButton.hide();
|
|
169
|
+
}
|
|
170
|
+
this.$playButton.addClass('poster-icon');
|
|
171
|
+
this.$playButton.attr('data-poster', '');
|
|
172
|
+
this.update();
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
removeVideoElementPoster() {
|
|
176
|
+
this.container.playback &&
|
|
177
|
+
this.container.playback.$el &&
|
|
178
|
+
this.container.playback.$el[0] &&
|
|
179
|
+
this.container.playback.$el[0].removeAttribute &&
|
|
180
|
+
this.container.playback.$el[0].removeAttribute('poster');
|
|
181
|
+
}
|
|
182
|
+
destroy() {
|
|
183
|
+
this.container.$el.removeClass('container-with-poster-clickable');
|
|
184
|
+
return this;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Tracer } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A tracer that logs to the console
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare class LogTracer implements Tracer {
|
|
7
|
+
private logger;
|
|
8
|
+
constructor(ns?: string);
|
|
9
|
+
reportError(e: Error): void;
|
|
10
|
+
trace(msg: string, data?: Record<string, unknown>): void;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=LogTracer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogTracer.d.ts","sourceRoot":"","sources":["../../src/trace/LogTracer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAIzC;;;GAGG;AACH,qBAAa,SAAU,YAAW,MAAM;IACtC,OAAO,CAAC,MAAM,CAAS;gBAEX,EAAE,SAAK;IAInB,WAAW,CAAC,CAAC,EAAE,KAAK;IAIpB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAGlD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Logger } from "../utils/Logger.js";
|
|
2
|
+
/**
|
|
3
|
+
* A tracer that logs to the console
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export class LogTracer {
|
|
7
|
+
logger;
|
|
8
|
+
constructor(ns = "") {
|
|
9
|
+
this.logger = new Logger(ns);
|
|
10
|
+
}
|
|
11
|
+
reportError(e) {
|
|
12
|
+
this.logger.error(e);
|
|
13
|
+
}
|
|
14
|
+
trace(msg, data) {
|
|
15
|
+
this.logger.debug(msg, data);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Client } from "@sentry/types";
|
|
2
|
+
/**
|
|
3
|
+
* @beta
|
|
4
|
+
*/
|
|
5
|
+
export declare class SentryTracer {
|
|
6
|
+
private client;
|
|
7
|
+
constructor(client: Client);
|
|
8
|
+
reportError(e: Error): void;
|
|
9
|
+
trace(msg: string, data?: Record<string, unknown>): void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=SentryTracer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SentryTracer.d.ts","sourceRoot":"","sources":["../../src/trace/SentryTracer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AAErC;;GAEG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAElC,WAAW,CAAC,CAAC,EAAE,KAAK;IAIpB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAKlD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @beta
|
|
3
|
+
*/
|
|
4
|
+
export class SentryTracer {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
reportError(e) {
|
|
10
|
+
this.client.captureException(e);
|
|
11
|
+
}
|
|
12
|
+
trace(msg, data) {
|
|
13
|
+
this.client.captureMessage(msg, "info", {
|
|
14
|
+
data,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type TagValue = string | boolean | number | null | undefined;
|
|
2
|
+
export interface Tracer {
|
|
3
|
+
reportError(e: unknown): void;
|
|
4
|
+
trace(msg: string, data: Record<string, unknown>): void;
|
|
5
|
+
}
|
|
6
|
+
export declare class LogTracer implements Tracer {
|
|
7
|
+
private tags;
|
|
8
|
+
reportError(e: Error): void;
|
|
9
|
+
setTag(name: string, value: TagValue): void;
|
|
10
|
+
trace(msg: string, data?: Record<string, unknown>): void;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=Tracer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tracer.d.ts","sourceRoot":"","sources":["../../src/trace/Tracer.ts"],"names":[],"mappings":"AAIA,KAAK,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAE7D,MAAM,WAAW,MAAM;IACrB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACzD;AAED,qBAAa,SAAU,YAAW,MAAM;IACtC,OAAO,CAAC,IAAI,CAAgC;IAE5C,WAAW,CAAC,CAAC,EAAE,KAAK;IAIpB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ;IAIpC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAIlD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Logger } from "../utils/Logger.js";
|
|
2
|
+
const logger = new Logger("_");
|
|
3
|
+
export class LogTracer {
|
|
4
|
+
tags = {};
|
|
5
|
+
reportError(e) {
|
|
6
|
+
logger.error(e, this.tags);
|
|
7
|
+
}
|
|
8
|
+
setTag(name, value) {
|
|
9
|
+
this.tags[name] = value;
|
|
10
|
+
}
|
|
11
|
+
trace(msg, data) {
|
|
12
|
+
const fullData = Object.assign({}, this.tags, data);
|
|
13
|
+
logger.debug(msg, fullData);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Tracer } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
* Sets a tracer implementation, e.g., LogTracer or SentryTracer
|
|
5
|
+
*/
|
|
6
|
+
export declare function setTracer(t: Tracer): void;
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
* @param e
|
|
10
|
+
*/
|
|
11
|
+
export declare function reportError(e: unknown): void;
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
* @param msg
|
|
15
|
+
* @param data
|
|
16
|
+
*/
|
|
17
|
+
export declare function trace(msg: string, data?: Record<string, unknown>): void;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/trace/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAOzC;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,QAGlC;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,QAErC;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,QAEpE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const tracer = {
|
|
2
|
+
trace: () => { },
|
|
3
|
+
reportError: () => { },
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* @public
|
|
7
|
+
* Sets a tracer implementation, e.g., LogTracer or SentryTracer
|
|
8
|
+
*/
|
|
9
|
+
export function setTracer(t) {
|
|
10
|
+
tracer.trace = t.trace.bind(t);
|
|
11
|
+
tracer.reportError = t.reportError.bind(t);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @public
|
|
15
|
+
* @param e
|
|
16
|
+
*/
|
|
17
|
+
export function reportError(e) {
|
|
18
|
+
tracer.reportError(e);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @public
|
|
22
|
+
* @param msg
|
|
23
|
+
* @param data
|
|
24
|
+
*/
|
|
25
|
+
export function trace(msg, data = {}) {
|
|
26
|
+
tracer.trace(msg, data);
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/trace/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export type PlayerDebugTag = 'all' | 'clappr' | 'dash' | 'hls' | 'none';
|
|
2
|
+
export type PlayerDebugSettings = PlayerDebugTag | boolean;
|
|
3
|
+
export type PlaybackType = 'live' | 'vod';
|
|
4
|
+
export type MediaTransport = 'dash' | 'hls' | 'mpegts';
|
|
5
|
+
export type TransportPreference = MediaTransport | 'auto';
|
|
6
|
+
export type PlayerPlugin = {
|
|
7
|
+
new (...args: any[]): unknown;
|
|
8
|
+
type: 'core' | 'container' | 'playback';
|
|
9
|
+
};
|
|
10
|
+
export type PlayerConfig = {
|
|
11
|
+
autoPlay?: boolean;
|
|
12
|
+
debug?: PlayerDebugSettings;
|
|
13
|
+
language?: string;
|
|
14
|
+
loop?: boolean;
|
|
15
|
+
multisources: StreamMediaSource[];
|
|
16
|
+
mute?: boolean;
|
|
17
|
+
playbackType: PlaybackType;
|
|
18
|
+
pluginSettings?: Record<string, unknown>;
|
|
19
|
+
poster?: string;
|
|
20
|
+
priorityTransport?: TransportPreference;
|
|
21
|
+
realtimeApi?: string;
|
|
22
|
+
strings: TranslationSettings;
|
|
23
|
+
};
|
|
24
|
+
export type PlayerOptionsThumbnails = {
|
|
25
|
+
sprite?: string | null;
|
|
26
|
+
vtt?: string | null;
|
|
27
|
+
};
|
|
28
|
+
export type ContextMenuSettings = {
|
|
29
|
+
preventShowContextMenu?: boolean;
|
|
30
|
+
};
|
|
31
|
+
type LangTag = string;
|
|
32
|
+
type TranslationKey = string;
|
|
33
|
+
export type BroadcastSettings = {
|
|
34
|
+
status?: 'live' | 'noActiveStreams';
|
|
35
|
+
};
|
|
36
|
+
export type ClipsPluginOptions = Record<string, unknown>;
|
|
37
|
+
export type PlaybackSettings = {
|
|
38
|
+
hlsjsConfig?: Record<string, unknown>;
|
|
39
|
+
playInline?: boolean;
|
|
40
|
+
preload?: 'auto' | 'metadata' | 'none';
|
|
41
|
+
triggerFatalErrorOnResourceDenied?: boolean;
|
|
42
|
+
};
|
|
43
|
+
export type DashSettings = Record<string, unknown>;
|
|
44
|
+
export type StreamMediaSourceDto = {
|
|
45
|
+
description: string;
|
|
46
|
+
dvr: boolean;
|
|
47
|
+
hls_cmaf_url?: string;
|
|
48
|
+
hls_mpegts_url?: string;
|
|
49
|
+
id: number;
|
|
50
|
+
live: boolean;
|
|
51
|
+
priority_transport: TransportPreference;
|
|
52
|
+
poster: string | null;
|
|
53
|
+
projection: ProjectionType | null;
|
|
54
|
+
screenshot: string | null;
|
|
55
|
+
source: string;
|
|
56
|
+
source_dash: string | null;
|
|
57
|
+
sprite: string | null;
|
|
58
|
+
title: string;
|
|
59
|
+
vtt: string | null;
|
|
60
|
+
};
|
|
61
|
+
export type StreamMediaSource = {
|
|
62
|
+
description: string;
|
|
63
|
+
dvr: boolean;
|
|
64
|
+
hlsCmafUrl?: string;
|
|
65
|
+
hlsMpegtsUrl?: string;
|
|
66
|
+
id: number;
|
|
67
|
+
live: boolean;
|
|
68
|
+
priorityTransport: TransportPreference;
|
|
69
|
+
poster: string | null;
|
|
70
|
+
projection: ProjectionType | null;
|
|
71
|
+
screenshot: string | null;
|
|
72
|
+
source: string;
|
|
73
|
+
sourceDash: string | null;
|
|
74
|
+
sprite: string | null;
|
|
75
|
+
title: string;
|
|
76
|
+
vtt: string | null;
|
|
77
|
+
};
|
|
78
|
+
export type SrcProjectionType = 'regular' | '360' | 'vr180' | 'vr360tb';
|
|
79
|
+
export type ProjectionType = '360' | '180' | '360_TB';
|
|
80
|
+
export type TranslationSettings = Partial<Record<LangTag, Record<TranslationKey, string>>>;
|
|
81
|
+
export {};
|
|
82
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|
package/lib/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @beta
|
|
3
|
+
*/
|
|
4
|
+
export type WriteFn = (...args: any[]) => void;
|
|
5
|
+
/**
|
|
6
|
+
* Logging utility with [debug](https://www.npmjs.com/package/debug)-like API
|
|
7
|
+
* @beta
|
|
8
|
+
*/
|
|
9
|
+
export declare class Logger {
|
|
10
|
+
readonly info: WriteFn;
|
|
11
|
+
readonly warn: WriteFn;
|
|
12
|
+
readonly error: WriteFn;
|
|
13
|
+
readonly debug: WriteFn;
|
|
14
|
+
private static items;
|
|
15
|
+
constructor(namespace: string, appName?: string);
|
|
16
|
+
/**
|
|
17
|
+
* @param patterns - comma-separated list of patterns, can contain '*' as a wildcard
|
|
18
|
+
*/
|
|
19
|
+
static enable(patterns: string): void;
|
|
20
|
+
static disable(): void;
|
|
21
|
+
private static toggleItems;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=Logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/utils/Logger.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;AA2C/C;;;GAGG;AACH,qBAAa,MAAM;IACjB,SAAgB,IAAI,EAAE,OAAO,CAAC;IAC9B,SAAgB,IAAI,EAAE,OAAO,CAAC;IAC9B,SAAgB,KAAK,EAAE,OAAO,CAAC;IAC/B,SAAgB,KAAK,EAAE,OAAO,CAAC;IAE/B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAyB;gBAEjC,SAAS,EAAE,MAAM,EAAE,OAAO,SAAW;IAqBjD;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM;IAS9B,MAAM,CAAC,OAAO;IAId,OAAO,CAAC,MAAM,CAAC,WAAW;CAS3B"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const APP_NAME = "gplayer";
|
|
2
|
+
class DebuggerWrapper {
|
|
3
|
+
writer;
|
|
4
|
+
namespace;
|
|
5
|
+
currentWriter;
|
|
6
|
+
constructor(writer, namespace, enabled = true) {
|
|
7
|
+
this.writer = writer;
|
|
8
|
+
this.namespace = namespace;
|
|
9
|
+
this.currentWriter = enabled ? writer : nullWriter;
|
|
10
|
+
}
|
|
11
|
+
enable() {
|
|
12
|
+
this.currentWriter = this.writer;
|
|
13
|
+
}
|
|
14
|
+
disable() {
|
|
15
|
+
this.currentWriter = nullWriter;
|
|
16
|
+
}
|
|
17
|
+
write = (m, ...args) => {
|
|
18
|
+
const tokens = args.map((_) => "%s");
|
|
19
|
+
if (typeof m === "string" || args.length > 0) {
|
|
20
|
+
tokens.unshift("%s");
|
|
21
|
+
}
|
|
22
|
+
this.currentWriter(`${this.namespace}: ${tokens.join(' ')}`, m, ...args.map(a => JSON.stringify(a)));
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const currentPatterns = [];
|
|
26
|
+
function parsePattern(pattern) {
|
|
27
|
+
if (pattern === "*") {
|
|
28
|
+
return /.?/;
|
|
29
|
+
}
|
|
30
|
+
return new RegExp("^" + pattern.replace(/\*/g, "[@\\w-]+"), "i");
|
|
31
|
+
}
|
|
32
|
+
function pass(namespace) {
|
|
33
|
+
return currentPatterns.some((p) => p.test(namespace));
|
|
34
|
+
}
|
|
35
|
+
function nullWriter() { }
|
|
36
|
+
/**
|
|
37
|
+
* Logging utility with [debug](https://www.npmjs.com/package/debug)-like API
|
|
38
|
+
* @beta
|
|
39
|
+
*/
|
|
40
|
+
export class Logger {
|
|
41
|
+
info;
|
|
42
|
+
warn;
|
|
43
|
+
error;
|
|
44
|
+
debug;
|
|
45
|
+
static items = [];
|
|
46
|
+
constructor(namespace, appName = APP_NAME) {
|
|
47
|
+
const ns = namespace ? `:${namespace}` : "";
|
|
48
|
+
const info = new DebuggerWrapper(console.info.bind(console), `${appName}:INFO${ns}`, pass(namespace));
|
|
49
|
+
this.info = info.write;
|
|
50
|
+
const warn = new DebuggerWrapper(console.warn.bind(console), `${appName}:WARN${ns}`, pass(namespace));
|
|
51
|
+
this.warn = warn.write;
|
|
52
|
+
const error = new DebuggerWrapper(console.error.bind(console), `${appName}:ERROR${ns}`, pass(namespace));
|
|
53
|
+
this.error = error.write;
|
|
54
|
+
const debug = new DebuggerWrapper(console.debug.bind(console), `${appName}:DEBUG${ns}`, pass(namespace));
|
|
55
|
+
this.debug = debug.write;
|
|
56
|
+
Logger.items.push(warn);
|
|
57
|
+
Logger.items.push(info);
|
|
58
|
+
Logger.items.push(error);
|
|
59
|
+
Logger.items.push(debug);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @param patterns - comma-separated list of patterns, can contain '*' as a wildcard
|
|
63
|
+
*/
|
|
64
|
+
static enable(patterns) {
|
|
65
|
+
currentPatterns.splice(0, currentPatterns.length, ...patterns.split(",").filter(Boolean).map(parsePattern));
|
|
66
|
+
Logger.toggleItems();
|
|
67
|
+
}
|
|
68
|
+
static disable() {
|
|
69
|
+
currentPatterns.splice(0, currentPatterns.length);
|
|
70
|
+
}
|
|
71
|
+
static toggleItems() {
|
|
72
|
+
for (const w of Logger.items) {
|
|
73
|
+
if (pass(w.namespace)) {
|
|
74
|
+
w.enable();
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
w.disable();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canAutoplay.d.ts","sourceRoot":"","sources":["../../src/utils/canAutoplay.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;CAChB,CAAA;AAED,4BAAkC,OAAO,CAAC,iBAAiB,CAAC,CA4B3D"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Browser } from '@clappr/core';
|
|
2
|
+
import canAutoPlay from 'can-autoplay';
|
|
3
|
+
import { reportError, trace } from "../trace/index.js";
|
|
4
|
+
export default async function () {
|
|
5
|
+
let autoPlay = false;
|
|
6
|
+
let muted = false;
|
|
7
|
+
trace("canAutoplay enter");
|
|
8
|
+
try {
|
|
9
|
+
const autoplay = await canAutoPlay.video();
|
|
10
|
+
if (autoplay.result) {
|
|
11
|
+
autoPlay = true;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
const checkObj = Browser.isiOS ? { muted: true, inline: true } : { muted: true };
|
|
15
|
+
const mute = await canAutoPlay.video(checkObj);
|
|
16
|
+
if (!mute.result) {
|
|
17
|
+
autoPlay = false;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
muted = true;
|
|
21
|
+
autoPlay = true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
reportError(e);
|
|
27
|
+
}
|
|
28
|
+
trace("canAutoplay leave", { autoPlay, muted });
|
|
29
|
+
return { autoPlay, muted };
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,CAK3C"}
|