xgplayer 2.32.5 → 2.32.6
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/browser/controls/airplay.js +1 -1
- package/browser/controls/cssFullscreen.js +1 -1
- package/browser/controls/danmu.js +3 -1
- package/browser/controls/definition.js +1 -1
- package/browser/controls/download.js +1 -1
- package/browser/controls/enter.js +1 -1
- package/browser/controls/error.js +1 -1
- package/browser/controls/errorRetry.js +1 -1
- package/browser/controls/flex.js +1 -1
- package/browser/controls/fullscreen.js +1 -1
- package/browser/controls/loading.js +1 -1
- package/browser/controls/memoryPlay.js +1 -1
- package/browser/controls/miniplayer.js +9 -7
- package/browser/controls/mobile.js +1 -1
- package/browser/controls/nativeTextTrack.js +1 -1
- package/browser/controls/pc.js +1 -1
- package/browser/controls/pip.js +1 -1
- package/browser/controls/play.js +1 -1
- package/browser/controls/playNext.js +1 -1
- package/browser/controls/playbackRate.js +1 -1
- package/browser/controls/poster.js +1 -1
- package/browser/controls/progress.js +1 -1
- package/browser/controls/reload.js +1 -1
- package/browser/controls/replay.js +1 -1
- package/browser/controls/rotate.js +1 -1
- package/browser/controls/screenShot.js +1 -1
- package/browser/controls/start.js +1 -1
- package/browser/controls/textTrack.js +1 -1
- package/browser/controls/time.js +1 -1
- package/browser/controls/volume.js +1 -1
- package/browser/core_player.js +1 -1
- package/browser/core_player.js.map +1 -1
- package/browser/index.js +11 -7
- package/browser/index.js.map +1 -1
- package/browser/simple_player.js +1 -1
- package/browser/simple_player.js.map +1 -1
- package/dist/controls/airplay.js +1 -1
- package/dist/controls/cssFullscreen.js +1 -1
- package/dist/controls/danmu.js +3 -1
- package/dist/controls/definition.js +1 -1
- package/dist/controls/download.js +1 -1
- package/dist/controls/enter.js +1 -1
- package/dist/controls/error.js +1 -1
- package/dist/controls/errorRetry.js +1 -1
- package/dist/controls/flex.js +1 -1
- package/dist/controls/fullscreen.js +1 -1
- package/dist/controls/loading.js +1 -1
- package/dist/controls/memoryPlay.js +1 -1
- package/dist/controls/miniplayer.js +9 -7
- package/dist/controls/mobile.js +1 -1
- package/dist/controls/nativeTextTrack.js +1 -1
- package/dist/controls/pc.js +1 -1
- package/dist/controls/pip.js +1 -1
- package/dist/controls/play.js +1 -1
- package/dist/controls/playNext.js +1 -1
- package/dist/controls/playbackRate.js +1 -1
- package/dist/controls/poster.js +1 -1
- package/dist/controls/progress.js +1 -1
- package/dist/controls/reload.js +1 -1
- package/dist/controls/replay.js +1 -1
- package/dist/controls/rotate.js +1 -1
- package/dist/controls/screenShot.js +1 -1
- package/dist/controls/start.js +1 -1
- package/dist/controls/textTrack.js +1 -1
- package/dist/controls/time.js +1 -1
- package/dist/controls/volume.js +1 -1
- package/dist/core_player.js +2960 -2889
- package/dist/core_player.js.map +1 -1
- package/dist/index.js +1938 -3321
- package/dist/index.js.map +1 -1
- package/dist/index.min.css +1 -0
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/dist/simple_player.js +274 -281
- package/dist/simple_player.js.map +1 -1
- package/es/_virtual/_rollupPluginBabelHelpers.js +216 -0
- package/es/constant.d.ts +4 -0
- package/es/constant.js +5 -0
- package/es/controls/airplay.js +1 -1
- package/es/controls/cssFullscreen.js +1 -1
- package/es/controls/danmu.js +3 -1
- package/es/controls/definition.js +1 -1
- package/es/controls/download.js +1 -1
- package/es/controls/enter.js +1 -1
- package/es/controls/error.js +1 -1
- package/es/controls/errorRetry.js +1 -1
- package/es/controls/flex.js +1 -1
- package/es/controls/fullscreen.js +1 -1
- package/es/controls/i18n.js +1 -1
- package/es/controls/keyboard.js +1 -1
- package/es/controls/loading.js +1 -1
- package/es/controls/localPreview.js +1 -1
- package/es/controls/memoryPlay.js +1 -1
- package/es/controls/miniplayer.js +9 -7
- package/es/controls/mobile.js +1 -1
- package/es/controls/nativeTextTrack.js +1 -1
- package/es/controls/pc.js +1 -1
- package/es/controls/pip.js +1 -1
- package/es/controls/play.js +1 -1
- package/es/controls/playNext.js +1 -1
- package/es/controls/playbackRate.js +1 -1
- package/es/controls/poster.js +1 -1
- package/es/controls/progress.js +1 -1
- package/es/controls/reload.js +1 -1
- package/es/controls/replay.js +1 -1
- package/es/controls/rotate.js +1 -1
- package/es/controls/screenShot.js +1 -1
- package/es/controls/start.js +1 -1
- package/es/controls/textTrack.js +1 -1
- package/es/controls/time.js +1 -1
- package/es/controls/volume.js +1 -1
- package/es/core_player.js +1 -1
- package/es/core_player.js.map +1 -1
- package/es/defaultConfig.d.ts +243 -0
- package/es/defaultConfig.js +85 -0
- package/es/error.d.ts +114 -0
- package/es/error.js +75 -0
- package/es/events.d.ts +61 -0
- package/es/events.js +62 -0
- package/es/icons.d.ts +2 -0
- package/es/index.css +499 -0
- package/es/index.d.ts +25 -0
- package/es/index.js +11 -7
- package/es/index.js.map +1 -1
- package/es/index.scss +29 -0
- package/es/index.umd.d.ts +60 -0
- package/es/index.umd.js +30 -0
- package/es/lang/en.d.ts +91 -0
- package/es/lang/en.js +77 -0
- package/es/lang/i18n.d.ts +36 -0
- package/es/lang/i18n.js +122 -0
- package/es/lang/index.d.ts +2 -0
- package/es/lang/jp.d.ts +91 -0
- package/es/lang/jp.js +77 -0
- package/es/lang/zh-cn.d.ts +91 -0
- package/es/lang/zh-cn.js +77 -0
- package/es/lang/zh-hk.d.ts +91 -0
- package/es/lang/zh-hk.js +77 -0
- package/es/mediaProxy.d.ts +334 -0
- package/es/mediaProxy.js +623 -0
- package/es/player.d.ts +825 -0
- package/es/player.js +1945 -0
- package/es/plugin/basePlugin.d.ts +180 -0
- package/es/plugin/basePlugin.js +259 -0
- package/es/plugin/hooksDescriptor.d.ts +60 -0
- package/es/plugin/hooksDescriptor.js +149 -0
- package/es/plugin/index.d.ts +13 -0
- package/es/plugin/plugin.d.ts +207 -0
- package/es/plugin/plugin.js +542 -0
- package/es/plugin/pluginsManager.d.ts +162 -0
- package/es/plugin/pluginsManager.js +362 -0
- package/es/plugin/preset.d.ts +1 -0
- package/es/plugin/preset.js +28 -0
- package/es/plugin/resizeObserver.d.ts +3 -0
- package/es/plugin/resizeObserver.js +108 -0
- package/es/plugins/assets/back.js +4 -0
- package/es/plugins/assets/download.js +4 -0
- package/es/plugins/assets/exitCssFull.js +4 -0
- package/es/plugins/assets/exitFull.js +4 -0
- package/es/plugins/assets/loading.js +4 -0
- package/es/plugins/assets/panel.js +4 -0
- package/es/plugins/assets/pause.js +4 -0
- package/es/plugins/assets/pipIcon.js +4 -0
- package/es/plugins/assets/pipIconExit.js +4 -0
- package/es/plugins/assets/play.js +4 -0
- package/es/plugins/assets/playNext.js +4 -0
- package/es/plugins/assets/replay.js +4 -0
- package/es/plugins/assets/requestCssFull.js +7 -0
- package/es/plugins/assets/requestFull.js +4 -0
- package/es/plugins/assets/rotate.js +4 -0
- package/es/plugins/assets/seekicon.js +4 -0
- package/es/plugins/assets/volumeLarge.js +4 -0
- package/es/plugins/assets/volumeMuted.js +4 -0
- package/es/plugins/assets/volumeSmall.js +4 -0
- package/es/plugins/common/iconPlugin.d.ts +5 -0
- package/es/plugins/common/iconPlugin.js +42 -0
- package/es/plugins/common/iconTools.d.ts +1 -0
- package/es/plugins/common/iconTools.js +8 -0
- package/es/plugins/common/index.scss +2 -0
- package/es/plugins/common/optionList.d.ts +15 -0
- package/es/plugins/common/optionList.js +120 -0
- package/es/plugins/common/optionsIcon.d.ts +40 -0
- package/es/plugins/common/optionsIcon.js +304 -0
- package/es/plugins/common/optionsIcon.scss +154 -0
- package/es/plugins/common/thumbnail.d.ts +62 -0
- package/es/plugins/common/thumbnail.js +191 -0
- package/es/plugins/common/thumbnail.scss +27 -0
- package/es/plugins/controls/index.css +132 -0
- package/es/plugins/controls/index.d.ts +73 -0
- package/es/plugins/controls/index.js +189 -0
- package/es/plugins/controls/index.scss +204 -0
- package/es/plugins/cssFullScreen/index.css +12 -0
- package/es/plugins/cssFullScreen/index.d.ts +40 -0
- package/es/plugins/cssFullScreen/index.js +136 -0
- package/es/plugins/cssFullScreen/index.scss +19 -0
- package/es/plugins/danmu/danmuIcon.d.ts +24 -0
- package/es/plugins/danmu/danmuIcon.js +98 -0
- package/es/plugins/danmu/danmuPanel.d.ts +39 -0
- package/es/plugins/danmu/danmuPanel.js +81 -0
- package/es/plugins/danmu/index.css +603 -0
- package/es/plugins/danmu/index.d.ts +96 -0
- package/es/plugins/danmu/index.js +313 -0
- package/es/plugins/danmu/index.scss +356 -0
- package/es/plugins/definition/index.css +4 -0
- package/es/plugins/definition/index.d.ts +38 -0
- package/es/plugins/definition/index.js +164 -0
- package/es/plugins/definition/index.scss +4 -0
- package/es/plugins/download/index.css +13 -0
- package/es/plugins/download/index.d.ts +31 -0
- package/es/plugins/download/index.js +107 -0
- package/es/plugins/download/index.scss +22 -0
- package/es/plugins/dynamicBg/index.css +16 -0
- package/es/plugins/dynamicBg/index.d.ts +83 -0
- package/es/plugins/dynamicBg/index.js +316 -0
- package/es/plugins/dynamicBg/index.scss +19 -0
- package/es/plugins/enter/index.css +104 -0
- package/es/plugins/enter/index.d.ts +19 -0
- package/es/plugins/enter/index.js +46 -0
- package/es/plugins/enter/index.scss +78 -0
- package/es/plugins/error/index.css +29 -0
- package/es/plugins/error/index.d.ts +8 -0
- package/es/plugins/error/index.js +75 -0
- package/es/plugins/error/index.scss +34 -0
- package/es/plugins/fpsDetect/index.d.ts +34 -0
- package/es/plugins/fpsDetect/index.js +149 -0
- package/es/plugins/fullscreen/backicon.d.ts +17 -0
- package/es/plugins/fullscreen/backicon.js +72 -0
- package/es/plugins/fullscreen/index.css +23 -0
- package/es/plugins/fullscreen/index.d.ts +58 -0
- package/es/plugins/fullscreen/index.js +202 -0
- package/es/plugins/fullscreen/index.scss +35 -0
- package/es/plugins/gapJump/index.d.ts +21 -0
- package/es/plugins/gapJump/index.js +142 -0
- package/es/plugins/keyboard/index.d.ts +89 -0
- package/es/plugins/keyboard/index.js +421 -0
- package/es/plugins/loading/index.css +58 -0
- package/es/plugins/loading/index.d.ts +11 -0
- package/es/plugins/loading/index.js +43 -0
- package/es/plugins/loading/index.scss +70 -0
- package/es/plugins/logger/index.d.ts +54 -0
- package/es/plugins/logger/index.js +311 -0
- package/es/plugins/miniScreen/index.css +179 -0
- package/es/plugins/miniScreen/index.d.ts +68 -0
- package/es/plugins/miniScreen/index.js +212 -0
- package/es/plugins/miniScreen/index.scss +198 -0
- package/es/plugins/miniScreen/miniScreenIcon.d.ts +11 -0
- package/es/plugins/miniScreen/miniScreenIcon.js +56 -0
- package/es/plugins/mobile/index.css +181 -0
- package/es/plugins/mobile/index.d.ts +125 -0
- package/es/plugins/mobile/index.js +631 -0
- package/es/plugins/mobile/index.scss +180 -0
- package/es/plugins/mobile/touch.d.ts +43 -0
- package/es/plugins/mobile/touch.js +214 -0
- package/es/plugins/netAdaption/index.d.ts +5 -0
- package/es/plugins/pc/index.css +3 -0
- package/es/plugins/pc/index.d.ts +14 -0
- package/es/plugins/pc/index.js +199 -0
- package/es/plugins/pc/index.scss +5 -0
- package/es/plugins/pip/index.css +12 -0
- package/es/plugins/pip/index.d.ts +37 -0
- package/es/plugins/pip/index.js +222 -0
- package/es/plugins/pip/index.scss +21 -0
- package/es/plugins/play/index.css +12 -0
- package/es/plugins/play/index.d.ts +23 -0
- package/es/plugins/play/index.js +127 -0
- package/es/plugins/play/index.scss +18 -0
- package/es/plugins/playNext/index.css +22 -0
- package/es/plugins/playNext/index.d.ts +19 -0
- package/es/plugins/playNext/index.js +104 -0
- package/es/plugins/playNext/index.scss +35 -0
- package/es/plugins/playbackRate/index.css +4 -0
- package/es/plugins/playbackRate/index.d.ts +31 -0
- package/es/plugins/playbackRate/index.js +140 -0
- package/es/plugins/playbackRate/index.scss +6 -0
- package/es/plugins/poster/index.css +39 -0
- package/es/plugins/poster/index.d.ts +27 -0
- package/es/plugins/poster/index.js +109 -0
- package/es/plugins/poster/index.scss +56 -0
- package/es/plugins/progress/index.css +234 -0
- package/es/plugins/progress/index.d.ts +178 -0
- package/es/plugins/progress/index.js +687 -0
- package/es/plugins/progress/index.scss +288 -0
- package/es/plugins/progress/innerList.d.ts +49 -0
- package/es/plugins/progress/innerList.js +285 -0
- package/es/plugins/progress/miniProgress.d.ts +9 -0
- package/es/plugins/progress/miniProgress.js +55 -0
- package/es/plugins/progressPreview/dotsApi.d.ts +1 -0
- package/es/plugins/progressPreview/dotsApi.js +269 -0
- package/es/plugins/progressPreview/index.css +190 -0
- package/es/plugins/progressPreview/index.d.ts +87 -0
- package/es/plugins/progressPreview/index.js +475 -0
- package/es/plugins/progressPreview/index.scss +235 -0
- package/es/plugins/prompt/index.css +47 -0
- package/es/plugins/prompt/index.d.ts +24 -0
- package/es/plugins/prompt/index.js +110 -0
- package/es/plugins/prompt/index.scss +53 -0
- package/es/plugins/replay/index.css +33 -0
- package/es/plugins/replay/index.d.ts +16 -0
- package/es/plugins/replay/index.js +109 -0
- package/es/plugins/replay/index.scss +41 -0
- package/es/plugins/rotate/index.css +0 -0
- package/es/plugins/rotate/index.d.ts +22 -0
- package/es/plugins/rotate/index.js +148 -0
- package/es/plugins/rotate/index.scss +0 -0
- package/es/plugins/rotate/index2.js +2 -0
- package/es/plugins/screenShot/index.css +3 -0
- package/es/plugins/screenShot/index.d.ts +30 -0
- package/es/plugins/screenShot/index.js +178 -0
- package/es/plugins/screenShot/index.scss +5 -0
- package/es/plugins/start/index.css +91 -0
- package/es/plugins/start/index.d.ts +41 -0
- package/es/plugins/start/index.js +267 -0
- package/es/plugins/start/index.scss +115 -0
- package/es/plugins/stats/index.d.ts +38 -0
- package/es/plugins/stats/index.js +194 -0
- package/es/plugins/testspeed/index.d.ts +26 -0
- package/es/plugins/testspeed/index.js +207 -0
- package/es/plugins/time/index.css +46 -0
- package/es/plugins/time/index.d.ts +28 -0
- package/es/plugins/time/index.js +225 -0
- package/es/plugins/time/index.scss +57 -0
- package/es/plugins/time/timesegments.d.ts +24 -0
- package/es/plugins/time/timesegments.js +216 -0
- package/es/plugins/track/index.css +91 -0
- package/es/plugins/track/index.d.ts +132 -0
- package/es/plugins/track/index.js +463 -0
- package/es/plugins/track/index.scss +111 -0
- package/es/plugins/track/nativeSubTitle.d.ts +22 -0
- package/es/plugins/track/nativeSubTitle.js +94 -0
- package/es/plugins/volume/index.css +95 -0
- package/es/plugins/volume/index.d.ts +88 -0
- package/es/plugins/volume/index.js +319 -0
- package/es/plugins/volume/index.scss +124 -0
- package/es/plugins/waitingTimeoutJump/index.d.ts +15 -0
- package/es/plugins/waitingTimeoutJump/index.js +88 -0
- package/es/presets/default-en.d.ts +33 -0
- package/es/presets/default-en.js +63 -0
- package/es/presets/default.d.ts +34 -0
- package/es/presets/default.js +70 -0
- package/es/presets/index.d.ts +4 -0
- package/es/presets/live.d.ts +94 -0
- package/es/presets/live.js +39 -0
- package/es/presets/mobile.d.ts +103 -0
- package/es/presets/mobile.js +34 -0
- package/es/simple_player.js +1 -1
- package/es/simple_player.js.map +1 -1
- package/es/state.d.ts +11 -0
- package/es/state.js +12 -0
- package/es/stateClassMap.d.ts +32 -0
- package/es/stateClassMap.js +32 -0
- package/es/style/common/animation.scss +16 -0
- package/es/style/common/svg-url.scss +70 -0
- package/es/style/common.scss +457 -0
- package/es/style/index.scss +4 -0
- package/es/style/variable.scss +76 -0
- package/es/utils/database.d.ts +31 -0
- package/es/utils/database.js +107 -0
- package/es/utils/debug.d.ts +10 -0
- package/es/utils/debug.js +43 -0
- package/es/utils/draggabilly.d.ts +54 -0
- package/es/utils/draggabilly.js +410 -0
- package/es/utils/sniffer.d.ts +28 -0
- package/es/utils/sniffer.js +150 -0
- package/es/utils/url.d.ts +1 -0
- package/es/utils/util.d.ts +304 -0
- package/es/utils/util.js +827 -0
- package/es/utils/xgplayerTimeRange.d.ts +7 -0
- package/es/utils/xgplayerTimeRange.js +25 -0
- package/es/version.d.ts +2 -0
- package/es/version.js +2 -0
- package/package.json +2 -3
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export default class Stats extends BasePlugin {
|
|
2
|
+
static get defaultConfig(): {};
|
|
3
|
+
_recordUserActions: (actionData: any) => void;
|
|
4
|
+
_getTime(): {
|
|
5
|
+
timestamp: number;
|
|
6
|
+
timeFormat: string;
|
|
7
|
+
};
|
|
8
|
+
_onReset: () => void;
|
|
9
|
+
_recordInfo: (data: any) => void;
|
|
10
|
+
_downloadStats: () => void;
|
|
11
|
+
downloadStats(): void;
|
|
12
|
+
/**
|
|
13
|
+
* @params type
|
|
14
|
+
*/
|
|
15
|
+
info(data: any): void;
|
|
16
|
+
_info(data: any): void;
|
|
17
|
+
_infoProfile(data: any): void;
|
|
18
|
+
reset(): void;
|
|
19
|
+
_stats: {
|
|
20
|
+
info: any[];
|
|
21
|
+
media: {};
|
|
22
|
+
};
|
|
23
|
+
getStats(): {
|
|
24
|
+
raw: {
|
|
25
|
+
info: any[];
|
|
26
|
+
media: {};
|
|
27
|
+
};
|
|
28
|
+
timestat: string[];
|
|
29
|
+
profile: {
|
|
30
|
+
traceEvents: any[];
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
_getTimeStats(): string[];
|
|
34
|
+
_getProfile(): {
|
|
35
|
+
traceEvents: any[];
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
import { BasePlugin } from "../../plugin";
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, defineProperty as _defineProperty, objectSpread2 as _objectSpread2, assertThisInitialized as _assertThisInitialized, createClass as _createClass } from "../../_virtual/_rollupPluginBabelHelpers.js";
|
|
2
|
+
import "../../utils/util.js";
|
|
3
|
+
import { USER_ACTION, STATS_EVENTS as STATS_EVENTS$1 } from "../../events.js";
|
|
4
|
+
import BasePlugin from "../../plugin/basePlugin.js";
|
|
5
|
+
import "delegate";
|
|
6
|
+
var INFO = "info";
|
|
7
|
+
var STATS_EVENTS = STATS_EVENTS$1;
|
|
8
|
+
var Stats = /* @__PURE__ */ function(_BasePlugin) {
|
|
9
|
+
_inherits(Stats2, _BasePlugin);
|
|
10
|
+
var _super = _createSuper(Stats2);
|
|
11
|
+
function Stats2() {
|
|
12
|
+
var _this;
|
|
13
|
+
_classCallCheck(this, Stats2);
|
|
14
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
15
|
+
args[_key] = arguments[_key];
|
|
16
|
+
}
|
|
17
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
18
|
+
_defineProperty(_assertThisInitialized(_this), "_recordUserActions", function(actionData) {
|
|
19
|
+
var time = _this._getTime();
|
|
20
|
+
var payload = Object.assign({}, actionData, {
|
|
21
|
+
msg: actionData.msg || actionData.action
|
|
22
|
+
});
|
|
23
|
+
_this._stats[INFO].push(_objectSpread2(_objectSpread2({
|
|
24
|
+
type: "userAction"
|
|
25
|
+
}, time), {}, {
|
|
26
|
+
payload
|
|
27
|
+
}));
|
|
28
|
+
});
|
|
29
|
+
_defineProperty(_assertThisInitialized(_this), "_onReset", function() {
|
|
30
|
+
_this.reset();
|
|
31
|
+
});
|
|
32
|
+
_defineProperty(_assertThisInitialized(_this), "_recordInfo", function(data) {
|
|
33
|
+
_this.info(data);
|
|
34
|
+
});
|
|
35
|
+
_defineProperty(_assertThisInitialized(_this), "_downloadStats", function() {
|
|
36
|
+
var stats = _this.getStats();
|
|
37
|
+
var blob = new Blob([JSON.stringify(stats)], {
|
|
38
|
+
type: "application/json"
|
|
39
|
+
});
|
|
40
|
+
var downloadUrl = window.URL.createObjectURL(blob);
|
|
41
|
+
var link = document.createElement("a");
|
|
42
|
+
link.style.display = "none";
|
|
43
|
+
link.href = downloadUrl;
|
|
44
|
+
link.download = "player.txt";
|
|
45
|
+
link.disabled = false;
|
|
46
|
+
link.click();
|
|
47
|
+
});
|
|
48
|
+
return _this;
|
|
49
|
+
}
|
|
50
|
+
_createClass(Stats2, [{
|
|
51
|
+
key: "_getTime",
|
|
52
|
+
value: function _getTime() {
|
|
53
|
+
return {
|
|
54
|
+
timestamp: Date.now(),
|
|
55
|
+
timeFormat: new Date().toISOString()
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "afterCreate",
|
|
60
|
+
value: function afterCreate() {
|
|
61
|
+
this.reset();
|
|
62
|
+
this.on(USER_ACTION, this._recordUserActions);
|
|
63
|
+
this.on(STATS_EVENTS.STATS_INFO, this._recordInfo);
|
|
64
|
+
this.on(STATS_EVENTS.STATS_DOWNLOAD, this._downloadStats);
|
|
65
|
+
this.on(STATS_EVENTS.STATS_RESET, this._onReset);
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
key: "destroy",
|
|
69
|
+
value: function destroy() {
|
|
70
|
+
this.offAll();
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
73
|
+
key: "downloadStats",
|
|
74
|
+
value: function downloadStats() {
|
|
75
|
+
this._downloadStats();
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
key: "info",
|
|
79
|
+
value: function info(data) {
|
|
80
|
+
if (data.profile) {
|
|
81
|
+
this._infoProfile(data);
|
|
82
|
+
} else {
|
|
83
|
+
this._info(data);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
key: "_info",
|
|
88
|
+
value: function _info(data) {
|
|
89
|
+
var time = this._getTime();
|
|
90
|
+
this._stats[INFO].push(_objectSpread2(_objectSpread2({}, time), {}, {
|
|
91
|
+
payload: data
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
key: "_infoProfile",
|
|
96
|
+
value: function _infoProfile(data) {
|
|
97
|
+
if (data && data.startMs) {
|
|
98
|
+
var endMs = Date.now();
|
|
99
|
+
var dur = endMs - data.startMs;
|
|
100
|
+
var profile = _objectSpread2({
|
|
101
|
+
cat: "function",
|
|
102
|
+
dur,
|
|
103
|
+
name: data.name || data.msg,
|
|
104
|
+
ph: "X",
|
|
105
|
+
pid: 0,
|
|
106
|
+
tid: 0,
|
|
107
|
+
ts: data.startMs,
|
|
108
|
+
profile: true
|
|
109
|
+
}, data);
|
|
110
|
+
this._info(profile);
|
|
111
|
+
} else {
|
|
112
|
+
console.warn("infoProfile need object data, include startMs");
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}, {
|
|
116
|
+
key: "reset",
|
|
117
|
+
value: function reset() {
|
|
118
|
+
var _this$_stats;
|
|
119
|
+
this._stats = (_this$_stats = {}, _defineProperty(_this$_stats, INFO, []), _defineProperty(_this$_stats, "media", {}), _this$_stats);
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
key: "getStats",
|
|
123
|
+
value: function getStats() {
|
|
124
|
+
var player = this.player;
|
|
125
|
+
var mediaElem = player.media;
|
|
126
|
+
var buffered = [];
|
|
127
|
+
for (var i = 0; i < mediaElem.buffered.length; i++) {
|
|
128
|
+
buffered.push({
|
|
129
|
+
start: mediaElem.buffered.start(i),
|
|
130
|
+
end: mediaElem.buffered.end(i)
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
var mediaInfo = {
|
|
134
|
+
currentTime: mediaElem.currentTime,
|
|
135
|
+
readyState: mediaElem.readyState,
|
|
136
|
+
buffered,
|
|
137
|
+
paused: mediaElem.paused,
|
|
138
|
+
ended: mediaElem.ended
|
|
139
|
+
};
|
|
140
|
+
this._stats.media = mediaInfo;
|
|
141
|
+
return {
|
|
142
|
+
raw: this._stats,
|
|
143
|
+
timestat: this._getTimeStats(),
|
|
144
|
+
profile: this._getProfile()
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}, {
|
|
148
|
+
key: "_getTimeStats",
|
|
149
|
+
value: function _getTimeStats() {
|
|
150
|
+
var allStat = this._stats[INFO];
|
|
151
|
+
var msgs = allStat.map(function(stat) {
|
|
152
|
+
var data = stat.payload.data;
|
|
153
|
+
var msg = "";
|
|
154
|
+
try {
|
|
155
|
+
if (data instanceof Error) {
|
|
156
|
+
msg = data.msg;
|
|
157
|
+
} else if (data !== void 0) {
|
|
158
|
+
msg = JSON.stringify(data);
|
|
159
|
+
}
|
|
160
|
+
} catch (error) {
|
|
161
|
+
console.log("err", error);
|
|
162
|
+
}
|
|
163
|
+
return "[".concat(stat.timeFormat, "] : ").concat(stat.payload.msg, " ").concat(msg, " ");
|
|
164
|
+
});
|
|
165
|
+
return msgs;
|
|
166
|
+
}
|
|
167
|
+
}, {
|
|
168
|
+
key: "_getProfile",
|
|
169
|
+
value: function _getProfile() {
|
|
170
|
+
var profile = {
|
|
171
|
+
traceEvents: []
|
|
172
|
+
};
|
|
173
|
+
var allStat = this._stats[INFO];
|
|
174
|
+
allStat.forEach(function(stat) {
|
|
175
|
+
if (stat.payload.profile) {
|
|
176
|
+
profile.traceEvents.push(stat.payload);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
return profile;
|
|
180
|
+
}
|
|
181
|
+
}], [{
|
|
182
|
+
key: "pluginName",
|
|
183
|
+
get: function get() {
|
|
184
|
+
return "stats";
|
|
185
|
+
}
|
|
186
|
+
}, {
|
|
187
|
+
key: "defaultConfig",
|
|
188
|
+
get: function get() {
|
|
189
|
+
return {};
|
|
190
|
+
}
|
|
191
|
+
}]);
|
|
192
|
+
return Stats2;
|
|
193
|
+
}(BasePlugin);
|
|
194
|
+
export { Stats as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default class TestSpeed extends BasePlugin {
|
|
2
|
+
static get defaultConfig(): {
|
|
3
|
+
openSpeed: boolean;
|
|
4
|
+
testCnt: number;
|
|
5
|
+
loadSize: number;
|
|
6
|
+
testTimeStep: number;
|
|
7
|
+
url: string;
|
|
8
|
+
saveSpeedMax: number;
|
|
9
|
+
addSpeedTypeList: any[];
|
|
10
|
+
};
|
|
11
|
+
getSpeed: (type?: string) => number;
|
|
12
|
+
timer: NodeJS.Timeout;
|
|
13
|
+
cnt: number;
|
|
14
|
+
xhr: XMLHttpRequest;
|
|
15
|
+
startTimer: () => void;
|
|
16
|
+
initSpeedList: () => void;
|
|
17
|
+
speedListCache: {};
|
|
18
|
+
_onRealSpeedChange: (data: any) => void;
|
|
19
|
+
testSpeed: () => void;
|
|
20
|
+
appendList: (speed: any, type?: string) => void;
|
|
21
|
+
getSpeedName(namePrefix: any, type: any): string;
|
|
22
|
+
updateSpeed: (type?: string) => void;
|
|
23
|
+
set openSpeed(arg: any);
|
|
24
|
+
get openSpeed(): any;
|
|
25
|
+
}
|
|
26
|
+
import BasePlugin from "../../plugin";
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { inherits as _inherits, createSuper as _createSuper, classCallCheck as _classCallCheck, defineProperty as _defineProperty, assertThisInitialized as _assertThisInitialized, createClass as _createClass, toConsumableArray as _toConsumableArray } from "../../_virtual/_rollupPluginBabelHelpers.js";
|
|
2
|
+
import util from "../../utils/util.js";
|
|
3
|
+
import { DOWNLOAD_SPEED_CHANGE, LOADED_DATA, REPLAY } from "../../events.js";
|
|
4
|
+
import "../../utils/debug.js";
|
|
5
|
+
import Plugin from "../../plugin/plugin.js";
|
|
6
|
+
var DEFAULT_SPEED_TYPE = "cdn";
|
|
7
|
+
var SPEED_TYPE = ["cdn"];
|
|
8
|
+
var TestSpeed = /* @__PURE__ */ function(_BasePlugin) {
|
|
9
|
+
_inherits(TestSpeed2, _BasePlugin);
|
|
10
|
+
var _super = _createSuper(TestSpeed2);
|
|
11
|
+
function TestSpeed2() {
|
|
12
|
+
var _this;
|
|
13
|
+
_classCallCheck(this, TestSpeed2);
|
|
14
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
15
|
+
args[_key] = arguments[_key];
|
|
16
|
+
}
|
|
17
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
18
|
+
_defineProperty(_assertThisInitialized(_this), "getSpeed", function() {
|
|
19
|
+
var type = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : DEFAULT_SPEED_TYPE;
|
|
20
|
+
if (!_this.speedListCache || !_this.speedListCache[type])
|
|
21
|
+
return 0;
|
|
22
|
+
if (_this.speedListCache[type].length <= 0)
|
|
23
|
+
return 0;
|
|
24
|
+
var total = 0;
|
|
25
|
+
_this.speedListCache[type].map(function(item) {
|
|
26
|
+
total += item;
|
|
27
|
+
});
|
|
28
|
+
return Math.floor(total / _this.speedListCache[type].length);
|
|
29
|
+
});
|
|
30
|
+
_defineProperty(_assertThisInitialized(_this), "startTimer", function() {
|
|
31
|
+
if (util.isMSE(_this.player.video)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
_this.initSpeedList();
|
|
35
|
+
_this.cnt = 0;
|
|
36
|
+
_this.timer = setTimeout(_this.testSpeed, _this.config.testTimeStep);
|
|
37
|
+
});
|
|
38
|
+
_defineProperty(_assertThisInitialized(_this), "initSpeedList", function() {
|
|
39
|
+
_this.speedListCache = {};
|
|
40
|
+
SPEED_TYPE.forEach(function(type) {
|
|
41
|
+
_this.speedListCache[type] = [];
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
_defineProperty(_assertThisInitialized(_this), "_onRealSpeedChange", function(data) {
|
|
45
|
+
data.speed && _this.appendList(data.speed, data.type || DEFAULT_SPEED_TYPE);
|
|
46
|
+
});
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "testSpeed", function() {
|
|
48
|
+
clearTimeout(_this.timer);
|
|
49
|
+
_this.timer = null;
|
|
50
|
+
if (!_this.player || !_this.config.openSpeed)
|
|
51
|
+
return;
|
|
52
|
+
var _this$config = _this.config, url = _this$config.url, loadSize = _this$config.loadSize, testCnt = _this$config.testCnt, testTimeStep = _this$config.testTimeStep;
|
|
53
|
+
var testSpeedUrl = url + (url.indexOf("?") < 0 ? "?testst=" : "&testst=") + Date.now();
|
|
54
|
+
if (_this.cnt >= testCnt) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
_this.cnt++;
|
|
58
|
+
try {
|
|
59
|
+
var start = new Date().getTime();
|
|
60
|
+
var end = null;
|
|
61
|
+
var xhr = new XMLHttpRequest();
|
|
62
|
+
_this.xhr = xhr;
|
|
63
|
+
xhr.open("GET", testSpeedUrl);
|
|
64
|
+
var headers = {};
|
|
65
|
+
var random = Math.floor(Math.random() * 10);
|
|
66
|
+
headers.Range = "bytes=" + random + "-" + (loadSize + random);
|
|
67
|
+
if (headers) {
|
|
68
|
+
Object.keys(headers).forEach(function(k) {
|
|
69
|
+
xhr.setRequestHeader(k, headers[k]);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
xhr.onreadystatechange = function() {
|
|
73
|
+
if (xhr.readyState === 4) {
|
|
74
|
+
_this.xhr = null;
|
|
75
|
+
end = new Date().getTime();
|
|
76
|
+
var size = xhr.getResponseHeader("Content-Length") / 1024 * 8;
|
|
77
|
+
var speed = Math.round(size * 1e3 / (end - start));
|
|
78
|
+
_this.appendList(speed);
|
|
79
|
+
_this.timer = setTimeout(_this.testSpeed, testTimeStep);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
xhr.send();
|
|
83
|
+
} catch (e) {
|
|
84
|
+
console.error(e);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
_defineProperty(_assertThisInitialized(_this), "appendList", function(speed) {
|
|
88
|
+
var type = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : DEFAULT_SPEED_TYPE;
|
|
89
|
+
if (!_this.speedListCache || !_this.speedListCache[type])
|
|
90
|
+
return;
|
|
91
|
+
var saveSpeedMax = _this.config.saveSpeedMax;
|
|
92
|
+
if (_this.speedListCache[type].length >= saveSpeedMax) {
|
|
93
|
+
_this.speedListCache[type].shift();
|
|
94
|
+
}
|
|
95
|
+
_this.speedListCache[type].push(speed);
|
|
96
|
+
var _assertThisInitialize = _assertThisInitialized(_this), player = _assertThisInitialize.player;
|
|
97
|
+
if (player) {
|
|
98
|
+
type === DEFAULT_SPEED_TYPE ? player.realTimeSpeed = speed : player[_this.getSpeedName("realTime", type)] = speed;
|
|
99
|
+
}
|
|
100
|
+
_this.updateSpeed(type);
|
|
101
|
+
});
|
|
102
|
+
_defineProperty(_assertThisInitialized(_this), "updateSpeed", function() {
|
|
103
|
+
var type = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : DEFAULT_SPEED_TYPE;
|
|
104
|
+
var speed = _this.getSpeed(type);
|
|
105
|
+
var _assertThisInitialize2 = _assertThisInitialized(_this), player = _assertThisInitialize2.player;
|
|
106
|
+
if (player) {
|
|
107
|
+
if (type === DEFAULT_SPEED_TYPE) {
|
|
108
|
+
if (!player.avgSpeed || speed !== player.avgSpeed) {
|
|
109
|
+
player.avgSpeed = speed;
|
|
110
|
+
player.emit(DOWNLOAD_SPEED_CHANGE, {
|
|
111
|
+
speed,
|
|
112
|
+
realTimeSpeed: player.realTimeSpeed
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
var speedName = _this.getSpeedName("avg", type);
|
|
117
|
+
if (!player[speedName] || speed !== player[speedName]) {
|
|
118
|
+
player[speedName] = speed;
|
|
119
|
+
player.emit(DOWNLOAD_SPEED_CHANGE, {
|
|
120
|
+
speed,
|
|
121
|
+
realTimeSpeed: player.realTimeSpeed
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
return _this;
|
|
128
|
+
}
|
|
129
|
+
_createClass(TestSpeed2, [{
|
|
130
|
+
key: "afterCreate",
|
|
131
|
+
value: function afterCreate() {
|
|
132
|
+
var _this$config2 = this.config, openSpeed = _this$config2.openSpeed, addSpeedTypeList = _this$config2.addSpeedTypeList;
|
|
133
|
+
if ((addSpeedTypeList === null || addSpeedTypeList === void 0 ? void 0 : addSpeedTypeList.length) > 0) {
|
|
134
|
+
SPEED_TYPE.push.apply(SPEED_TYPE, _toConsumableArray(addSpeedTypeList));
|
|
135
|
+
}
|
|
136
|
+
this.initSpeedList();
|
|
137
|
+
this.on("real_time_speed", this._onRealSpeedChange);
|
|
138
|
+
this.timer = null;
|
|
139
|
+
this.cnt = 0;
|
|
140
|
+
this.xhr = null;
|
|
141
|
+
if (!openSpeed) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
this.on([LOADED_DATA, REPLAY], this.startTimer);
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
key: "getSpeedName",
|
|
148
|
+
value: function getSpeedName(namePrefix, type) {
|
|
149
|
+
return namePrefix + "Speed" + type.toUpperCase();
|
|
150
|
+
}
|
|
151
|
+
}, {
|
|
152
|
+
key: "openSpeed",
|
|
153
|
+
get: function get() {
|
|
154
|
+
return this.config.openSpeed;
|
|
155
|
+
},
|
|
156
|
+
set: function set(value) {
|
|
157
|
+
this.config.openSpeed = value;
|
|
158
|
+
if (!value && this.timer) {
|
|
159
|
+
clearTimeout(this.timer);
|
|
160
|
+
this.timer = null;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (this.config.openSpeed) {
|
|
164
|
+
if (this.timer)
|
|
165
|
+
return;
|
|
166
|
+
this.timer = setTimeout(this.testSpeed, this.config.testTimeStep);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}, {
|
|
170
|
+
key: "destroy",
|
|
171
|
+
value: function destroy() {
|
|
172
|
+
var _this2 = this;
|
|
173
|
+
this.off("real_time_speed", this._onRealSpeedChange);
|
|
174
|
+
this.off([LOADED_DATA, REPLAY], this.startTimer);
|
|
175
|
+
SPEED_TYPE.forEach(function(type) {
|
|
176
|
+
_this2.speedListCache && _this2.speedListCache[type] && (_this2.speedListCache[type] = []);
|
|
177
|
+
});
|
|
178
|
+
this.speedListCache && (this.speedListCache = {});
|
|
179
|
+
clearTimeout(this.timer);
|
|
180
|
+
this.timer = null;
|
|
181
|
+
if (this.xhr && this.xhr.readyState !== 4) {
|
|
182
|
+
this.xhr.cancel && this.xhr.cancel();
|
|
183
|
+
this.xhr = null;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}], [{
|
|
187
|
+
key: "pluginName",
|
|
188
|
+
get: function get() {
|
|
189
|
+
return "testspeed";
|
|
190
|
+
}
|
|
191
|
+
}, {
|
|
192
|
+
key: "defaultConfig",
|
|
193
|
+
get: function get() {
|
|
194
|
+
return {
|
|
195
|
+
openSpeed: false,
|
|
196
|
+
testCnt: 3,
|
|
197
|
+
loadSize: 200 * 1024,
|
|
198
|
+
testTimeStep: 3e3,
|
|
199
|
+
url: "",
|
|
200
|
+
saveSpeedMax: 5,
|
|
201
|
+
addSpeedTypeList: []
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
}]);
|
|
205
|
+
return TestSpeed2;
|
|
206
|
+
}(Plugin);
|
|
207
|
+
export { TestSpeed as default };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
.xgplayer .xgplayer-time {
|
|
2
|
+
min-width: 40px;
|
|
3
|
+
font-size: 14px;
|
|
4
|
+
font-family: PingFangSC-Semibold;
|
|
5
|
+
color: #fff;
|
|
6
|
+
text-align: center;
|
|
7
|
+
display: inline-block;
|
|
8
|
+
line-height: 40px;
|
|
9
|
+
}
|
|
10
|
+
.xgplayer .xgplayer-time span {
|
|
11
|
+
display: inline-block;
|
|
12
|
+
line-height: 40px;
|
|
13
|
+
height: 40px;
|
|
14
|
+
}
|
|
15
|
+
.xgplayer .xgplayer-time span .time-min-width {
|
|
16
|
+
text-align: center;
|
|
17
|
+
min-width: 2ch;
|
|
18
|
+
}
|
|
19
|
+
.xgplayer .xgplayer-time span .time-min-width:first-child {
|
|
20
|
+
text-align: right;
|
|
21
|
+
}
|
|
22
|
+
.xgplayer .xgplayer-time span .time-min-width:last-child {
|
|
23
|
+
text-align: left;
|
|
24
|
+
}
|
|
25
|
+
.xgplayer .xgplayer-time .time-duration {
|
|
26
|
+
color: rgba(255, 255, 255, 0.5);
|
|
27
|
+
}
|
|
28
|
+
.xgplayer .xgplayer-time .time-live-tag {
|
|
29
|
+
display: none;
|
|
30
|
+
}
|
|
31
|
+
.xgplayer .xgplayer-time.xg-time-left {
|
|
32
|
+
margin-left: 0;
|
|
33
|
+
}
|
|
34
|
+
.xgplayer .xgplayer-time.xg-time-right {
|
|
35
|
+
margin-right: 0;
|
|
36
|
+
}
|
|
37
|
+
.xgplayer.xgplayer-mobile .xgplayer-time {
|
|
38
|
+
min-width: 30px;
|
|
39
|
+
font-size: 12px;
|
|
40
|
+
}
|
|
41
|
+
.xgplayer.xgplayer-mobile .xgplayer-time.xg-time-left {
|
|
42
|
+
margin-right: 8px;
|
|
43
|
+
}
|
|
44
|
+
.xgplayer.xgplayer-mobile .xgplayer-time.xg-time-right {
|
|
45
|
+
margin-left: 8px;
|
|
46
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export default Time;
|
|
2
|
+
declare class Time extends Plugin {
|
|
3
|
+
static get defaultConfig(): {
|
|
4
|
+
position: string;
|
|
5
|
+
index: number;
|
|
6
|
+
disable: boolean;
|
|
7
|
+
};
|
|
8
|
+
constructor(args: any);
|
|
9
|
+
isActiving: boolean;
|
|
10
|
+
get duration(): number;
|
|
11
|
+
get currentTime(): any;
|
|
12
|
+
get timeOffset(): number;
|
|
13
|
+
mode: string;
|
|
14
|
+
durationDom: HTMLElement;
|
|
15
|
+
timeDom: HTMLElement;
|
|
16
|
+
show(): void;
|
|
17
|
+
onTimeUpdate(isEnded: any): void;
|
|
18
|
+
onReset(): void;
|
|
19
|
+
createCenterTime(): void;
|
|
20
|
+
centerCurDom: HTMLElement;
|
|
21
|
+
centerDurDom: HTMLElement;
|
|
22
|
+
changeLiveState(isLive: any): void;
|
|
23
|
+
updateTime(time: any): void;
|
|
24
|
+
minWidthTime(timeStr: any): any;
|
|
25
|
+
resetActive(): void;
|
|
26
|
+
render(): string;
|
|
27
|
+
}
|
|
28
|
+
import Plugin from "../../plugin";
|