@volcengine/veplayer 1.15.1 → 1.15.2-rc.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.
Potentially problematic release.
This version of @volcengine/veplayer might be problematic. Click here for more details.
- package/.changeset/config.json +11 -0
- package/.changeset/curvy-yaks-smoke.md +5 -0
- package/.changeset/neat-eyes-search.md +5 -0
- package/.codebase/pipelines/create-api-doc.yaml +16 -0
- package/.eslintignore +5 -0
- package/.eslintrc.json +53 -0
- package/.stylelintrc.js +51 -0
- package/CHANGELOG.md +5665 -0
- package/DEV_README.md +39 -0
- package/LICENSE +20 -0
- package/README_EN.md +46 -0
- package/build.sh +44 -0
- package/docg.config.js +65 -0
- package/env/byteplus.js +30 -0
- package/env/volcengine.js +50 -0
- package/fixtures/favicon.ico +0 -0
- package/fixtures/index.base.js +59 -0
- package/fixtures/index.html +41 -0
- package/fixtures/index.js +185 -0
- package/libd.config.js +147 -0
- package/localhost+2-key.pem +28 -0
- package/localhost+2.pem +26 -0
- package/lux.config.mjs +37 -0
- package/package.json +123 -4
- package/sdkhub.config.json +10 -0
- package/src/@types/global.d.ts +35 -0
- package/src/assets/common/error.svg +3 -0
- package/src/assets/common/errorImg.png +0 -0
- package/src/assets/common/errorImg.svg +12 -0
- package/src/assets/icons/mobile/definition.svg +3 -0
- package/src/assets/icons/mobile/line.svg +3 -0
- package/src/assets/icons/mobile/mobileDanmu.svg +1 -0
- package/src/assets/icons/mobile/mobileDanmuAcitive.svg +1 -0
- package/src/assets/icons/mobile/mobileDanmuSetting.svg +1 -0
- package/src/assets/icons/mobile/mobileExitFullscreen.svg +1 -0
- package/src/assets/icons/mobile/mobileFullscreen.svg +1 -0
- package/src/assets/icons/mobile/mobilePause.svg +4 -0
- package/src/assets/icons/mobile/mobilePlay.svg +4 -0
- package/src/assets/icons/mobile/mobilePlaynext.svg +1 -0
- package/src/assets/icons/mobile/mobileRefresh.svg +1 -0
- package/src/assets/icons/mobile/more.svg +3 -0
- package/src/assets/icons/mobile/muted.svg +22 -0
- package/src/assets/icons/mobile/playbackrate.svg +3 -0
- package/src/assets/icons/pc/danmu.svg +1 -0
- package/src/assets/icons/pc/danmuActive.svg +1 -0
- package/src/assets/icons/pc/danmuSettings.svg +1 -0
- package/src/assets/icons/pc/download.svg +14 -0
- package/src/assets/icons/pc/exitFullscreen.svg +1 -0
- package/src/assets/icons/pc/exitMirror.svg +10 -0
- package/src/assets/icons/pc/extend.svg +1 -0
- package/src/assets/icons/pc/fullscreen.svg +1 -0
- package/src/assets/icons/pc/getMirror.svg +10 -0
- package/src/assets/icons/pc/list.svg +20 -0
- package/src/assets/icons/pc/noPoster.svg +119 -0
- package/src/assets/icons/pc/pause.svg +1 -0
- package/src/assets/icons/pc/pip.svg +1 -0
- package/src/assets/icons/pc/pipExit.svg +1 -0
- package/src/assets/icons/pc/play-next-btn.svg +4 -0
- package/src/assets/icons/pc/play.svg +1 -0
- package/src/assets/icons/pc/playNext.svg +1 -0
- package/src/assets/icons/pc/playerLoading.svg +1 -0
- package/src/assets/icons/pc/refresh.svg +1 -0
- package/src/assets/icons/pc/replay.svg +1 -0
- package/src/assets/icons/pc/reset.svg +6 -0
- package/src/assets/icons/pc/startPlay.svg +1 -0
- package/src/assets/icons/pc/subtitleclose.svg +5 -0
- package/src/assets/icons/pc/subtitleopen.svg +3 -0
- package/src/assets/icons/pc/theaterEnter.svg +1 -0
- package/src/assets/icons/pc/theaterExit.svg +1 -0
- package/src/assets/icons/pc/volumeLarge.svg +1 -0
- package/src/assets/icons/pc/volumeMuted.svg +1 -0
- package/src/assets/icons/pc/volumeSmall.svg +1 -0
- package/src/config/defaultPreset.ts +110 -0
- package/src/config/playerOptionMobile.ts +166 -0
- package/src/config/playerOptionPc.ts +147 -0
- package/src/config/playerPreset.ts +242 -0
- package/src/constants/api.ts +13 -0
- package/src/constants/event.ts +577 -0
- package/src/constants/player.ts +84 -0
- package/src/constants/plugin.ts +19 -0
- package/src/constants/umdMap.ts +137 -0
- package/src/constants/umdPlugins.json +68 -0
- package/src/core/index.ts +7 -0
- package/src/core/player.ts +2713 -0
- package/src/core/playerData.ts +812 -0
- package/src/env.d.ts +47 -0
- package/src/index.ts +24 -0
- package/src/index.umd.ts +54 -0
- package/src/interface/adaptRange.d.ts +33 -0
- package/src/interface/api.ts +132 -0
- package/src/interface/autoBitrate.d.ts +41 -0
- package/src/interface/index.ts +1685 -0
- package/src/interface/rtm.ts +56 -0
- package/src/interface/sdkErrorPlugin.ts +145 -0
- package/src/interface/subtitle.ts +381 -0
- package/src/interface/video.ts +107 -0
- package/src/interface/xgplayer.ts +748 -0
- package/src/lang/constants.ts +69 -0
- package/src/lang/en.ts +98 -0
- package/src/lang/index.ts +33 -0
- package/src/lang/jp.ts +100 -0
- package/src/lang/zh-hk.ts +80 -0
- package/src/lang/zh.ts +79 -0
- package/src/license/index.ts +315 -0
- package/src/license/ttlicense2.js +15 -0
- package/src/license/ttlicense2.wasm +0 -0
- package/src/music/icons/back.svg +3 -0
- package/src/music/icons/forward.svg +3 -0
- package/src/music/icons/loop.svg +10 -0
- package/src/music/icons/order.svg +10 -0
- package/src/music/icons/pause-circle.svg +23 -0
- package/src/music/icons/play-circle.svg +22 -0
- package/src/music/icons/random.svg +10 -0
- package/src/music/icons/sloop.svg +10 -0
- package/src/music/index.ts +5 -0
- package/src/music/music.ts +550 -0
- package/src/music/plugins/index.less +185 -0
- package/src/music/plugins/index.ts +6 -0
- package/src/music/plugins/musicBackward.ts +82 -0
- package/src/music/plugins/musicCover.ts +45 -0
- package/src/music/plugins/musicForward.ts +82 -0
- package/src/music/plugins/musicMeta.ts +32 -0
- package/src/music/plugins/musicMode.ts +152 -0
- package/src/music/plugins/musicNext.ts +93 -0
- package/src/music/plugins/musicPrev.ts +94 -0
- package/src/music/preset.ts +69 -0
- package/src/music/xhr.ts +37 -0
- package/src/plugins/common/extendPluginFactory.ts +132 -0
- package/src/plugins/common/mobilePlayerPanel.ts +253 -0
- package/src/plugins/external/LiveInfoPanel.ts +340 -0
- package/src/plugins/external/ad/adsPlugin.ts +1 -0
- package/src/plugins/external/aiSubtitleIconPlugin.ts +270 -0
- package/src/plugins/external/aiSubtitlePlugin.ts +452 -0
- package/src/plugins/external/definitionDemotePlugin.ts +591 -0
- package/src/plugins/external/memoryPlay.ts +247 -0
- package/src/plugins/external/mirrorPlugin.ts +141 -0
- package/src/plugins/external/playList/OptionList.ts +204 -0
- package/src/plugins/external/playList/index.ts +743 -0
- package/src/plugins/external/subtitle/index.ts +672 -0
- package/src/plugins/external/subtitle/nativeSubTitle.ts +115 -0
- package/src/plugins/external/timeShiftPlugin.ts +484 -0
- package/src/plugins/external/watermark/dynamicWatermark.less +13 -0
- package/src/plugins/external/watermark/dynamicWatermark.ts +449 -0
- package/src/plugins/external/watermark/dynamicWatermarkPlugin.ts +185 -0
- package/src/plugins/inner/common/autoplayPlugin.ts +435 -0
- package/src/plugins/inner/common/danmu/container.ts +120 -0
- package/src/plugins/inner/common/danmu/index.ts +683 -0
- package/src/plugins/inner/common/danmu/lang.ts +139 -0
- package/src/plugins/inner/common/danmu/panel.ts +20 -0
- package/src/plugins/inner/common/danmu/slider.ts +210 -0
- package/src/plugins/inner/common/danmu/state.ts +118 -0
- package/src/plugins/inner/common/danmu/switch.ts +74 -0
- package/src/plugins/inner/common/definitionBasePlugin.ts +353 -0
- package/src/plugins/inner/common/errorPlugin.ts +544 -0
- package/src/plugins/inner/common/liveLogger.ts +137 -0
- package/src/plugins/inner/common/poster/index.less +66 -0
- package/src/plugins/inner/common/poster/index.ts +178 -0
- package/src/plugins/inner/common/refreshPlugin.ts +88 -0
- package/src/plugins/inner/common/rtmPlugin.ts +62 -0
- package/src/plugins/inner/common/toastPlugin.ts +90 -0
- package/src/plugins/inner/common/unmutePlugin.ts +133 -0
- package/src/plugins/inner/common/vodLogger.ts +80 -0
- package/src/plugins/inner/mobile/DefinitionMobilePlugin.ts +217 -0
- package/src/plugins/inner/mobile/LineMobilePlugins.ts +169 -0
- package/src/plugins/inner/mobile/MoreButtonPlugin.ts +176 -0
- package/src/plugins/inner/mobile/PlaybackRatePlugin.ts +199 -0
- package/src/plugins/inner/pc/definitionPlugin.ts +203 -0
- package/src/plugins/inner/pc/multilinePlugin.ts +93 -0
- package/src/sdkPlugin/abr.ts +67 -0
- package/src/sdkPlugin/adaptRange.ts +49 -0
- package/src/sdkPlugin/authToken.ts +557 -0
- package/src/sdkPlugin/sdkPlugin.ts +125 -0
- package/src/sdkPlugin/sdkPluginManager.ts +157 -0
- package/src/sdkPlugin/strategy.ts +47 -0
- package/src/strategy/index.ts +740 -0
- package/src/strategy/vestrategy-h265-wrapper.ts +34 -0
- package/src/strategy/vestrategy-preload-wrapper.ts +414 -0
- package/src/streamAdapters/base.ts +89 -0
- package/src/streamAdapters/dash.ts +230 -0
- package/src/streamAdapters/default.ts +53 -0
- package/src/streamAdapters/hls.ts +278 -0
- package/src/streamAdapters/index.ts +40 -0
- package/src/streamAdapters/mp4.ts +214 -0
- package/src/style/bytelive/danmu.less +293 -0
- package/src/style/bytelive/definitionIcon.less +80 -0
- package/src/style/bytelive/error.less +165 -0
- package/src/style/bytelive/index.less +62 -0
- package/src/style/bytelive/loading.less +5 -0
- package/src/style/bytelive/mobiePlugin.less +2 -0
- package/src/style/bytelive/mobile.less +76 -0
- package/src/style/bytelive/moreButton.less +79 -0
- package/src/style/bytelive/panel.less +259 -0
- package/src/style/bytelive/pc.less +161 -0
- package/src/style/bytelive/refresh.less +3 -0
- package/src/style/bytelive/reset.less +4 -0
- package/src/style/bytelive/toast.less +61 -0
- package/src/style/bytelive/unmute.less +65 -0
- package/src/style/external/LiveInfoPanel.less +41 -0
- package/src/style/external/aisub.less +139 -0
- package/src/style/external/aisubIcon.less +25 -0
- package/src/style/external/index.less +5 -0
- package/src/style/external/larkWindow.less +36 -0
- package/src/style/external/mirror.less +27 -0
- package/src/style/external/playList.less +258 -0
- package/src/style/external/timeShift.less +102 -0
- package/src/style/external/vttSubtitle.less +25 -0
- package/src/utils/debug.ts +62 -0
- package/src/utils/definition.ts +61 -0
- package/src/utils/escapeHtml.ts +93 -0
- package/src/utils/eventMiddleWare.ts +108 -0
- package/src/utils/index.ts +621 -0
- package/src/utils/intervalTimer.ts +38 -0
- package/src/utils/isHijackBrowser.ts +71 -0
- package/src/utils/proxy.ts +139 -0
- package/src/utils/storage.ts +34 -0
- package/src/utils/time.ts +19 -0
- package/src/utils/toast/index.less +20 -0
- package/src/utils/toast/index.ts +21 -0
- package/src/utils/token.ts +395 -0
- package/src/utils/u8a.ts +4 -0
- package/src/utils/umdLoader.ts +193 -0
- package/src/utils/video.ts +43 -0
- package/src/utils/xhr.ts +160 -0
- package/src/veError/error.ts +301 -0
- package/src/veError/index.ts +681 -0
- package/src/veError/playerProxy.ts +69 -0
- package/tsconfig.json +27 -0
- package/index.d.ts +0 -6874
- package/index.min.css +0 -1
- package/index.min.js +0 -2
- package/plugin/DashAbralgo.js +0 -2
- package/plugin/XGVideo.js +0 -2
- package/plugin/danmuMask.js +0 -2
- package/plugin/danmujs.js +0 -3
- package/plugin/dash.js +0 -2
- package/plugin/flv.js +0 -2
- package/plugin/hls.js +0 -2
- package/plugin/hlsEncrypt.js +0 -2
- package/plugin/mp4Encrypt.js +0 -2
- package/plugin/preloader.js +0 -2
- package/plugin/streamprobe.js +0 -2
- package/plugin/vestrategy.js +0 -1
- package/plugin/vestrategy_adapt_range.js +0 -1
- package/plugin/vestrategy_h265.js +0 -1
- package/plugin/vestrategy_preload.js +0 -1
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { Events, Sniffer } from 'xgplayer';
|
|
2
|
+
import MyProxy from '@/utils/proxy';
|
|
3
|
+
import { IntervalTimer } from '@/utils';
|
|
4
|
+
import { PluginEvents } from '@/constants/event';
|
|
5
|
+
import PlayerData from '@/core/playerData';
|
|
6
|
+
|
|
7
|
+
const AUTO_DEF_DETECT_INTERNAL = 1000;
|
|
8
|
+
|
|
9
|
+
const MixinDefinitionBase = Base =>
|
|
10
|
+
class extends Base {
|
|
11
|
+
_autoRealDefinition; // 自动挡实际播放档位
|
|
12
|
+
_playTimer = null;
|
|
13
|
+
playerData: PlayerData;
|
|
14
|
+
toastInfo: any;
|
|
15
|
+
playListSubscribeId: number;
|
|
16
|
+
definitionSubscribeId: number;
|
|
17
|
+
clientType: 'PC' | 'MOBILE';
|
|
18
|
+
constructor(args) {
|
|
19
|
+
super(args);
|
|
20
|
+
this.clientType = args.clientType;
|
|
21
|
+
this.playerData = args.player.config.playerData;
|
|
22
|
+
this.toastInfo = {};
|
|
23
|
+
this.dataMonitoring();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
afterCreate() {
|
|
27
|
+
super.afterCreate();
|
|
28
|
+
this._autoRealDefinition = undefined;
|
|
29
|
+
this.refreshDefinitionList?.();
|
|
30
|
+
if (
|
|
31
|
+
this.playerData.isOpenABR() ||
|
|
32
|
+
this.playerData.getStreamType()?.toLowerCase() === 'dash'
|
|
33
|
+
) {
|
|
34
|
+
// abr或者dash播放依赖resourceReady事件更新playList
|
|
35
|
+
this.on('resourceReady', this.handleResourceReady);
|
|
36
|
+
}
|
|
37
|
+
if (this.playerData.isOpenABR()) {
|
|
38
|
+
this.on('ABR_AUTO_DESC_CHANGE', this.handleABRDescChange);
|
|
39
|
+
if (
|
|
40
|
+
this.playerData?.adapter?.useNativeAbr?.() ||
|
|
41
|
+
this.player.plugins.dashplugin ||
|
|
42
|
+
this.player.plugins.mp4encryptplayer
|
|
43
|
+
) {
|
|
44
|
+
// native abr 通过轮询的方式获取abr自动挡的真实清晰度
|
|
45
|
+
// mp4 或者 dash 的abr,ABR_AUTO_DESC_CHANGE 事件可能会因为所处的清晰度没有变化过,会不触发。
|
|
46
|
+
this.autoDefDetectTimer = new IntervalTimer();
|
|
47
|
+
this.autoDefDetectTimer.repeat(
|
|
48
|
+
this.getAutoDefRealLevel,
|
|
49
|
+
AUTO_DEF_DETECT_INTERNAL,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
this.on(PluginEvents.PLAY_NEXT_START, () => {
|
|
54
|
+
// 切换播放视频时暂停current、playList变更监听
|
|
55
|
+
if (this.definitionSubscribeId) {
|
|
56
|
+
MyProxy.unsubscribeProperty(
|
|
57
|
+
this.playerData.current,
|
|
58
|
+
'definition',
|
|
59
|
+
this.definitionSubscribeId,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
if (this.playListSubscribeId) {
|
|
63
|
+
MyProxy.unsubscribeProperty(
|
|
64
|
+
this.playerData,
|
|
65
|
+
'playList',
|
|
66
|
+
this.playListSubscribeId,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
this.on(PluginEvents.PLAY_NEXT_END, () => {
|
|
71
|
+
// 播放视频切换完成重新监听current、playList变更
|
|
72
|
+
this.dataMonitoring?.();
|
|
73
|
+
// refresh清晰度列表
|
|
74
|
+
this.refreshDefinitionList?.();
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 各清晰度展示文案
|
|
79
|
+
getShowText(i18n = {}, definitionItem, definition: string) {
|
|
80
|
+
if (!definitionItem) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// 开启ABR&自动挡展示配置文案
|
|
84
|
+
if (
|
|
85
|
+
this.playerData.isOpenABR() &&
|
|
86
|
+
this.playerData.isAutoDefinition(definitionItem.definition)
|
|
87
|
+
) {
|
|
88
|
+
return (
|
|
89
|
+
this.playerData.configs?.autoBitrateOpts?.autoDefinitionText ||
|
|
90
|
+
i18n[definitionItem.definitionTextKey] ||
|
|
91
|
+
definitionItem.definition
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
i18n[definitionItem.definitionTextKey] ||
|
|
97
|
+
definitionItem.definition ||
|
|
98
|
+
definitionItem.definitionTextKey ||
|
|
99
|
+
definition ||
|
|
100
|
+
'HD'
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
getCurrentDefinitionInfo(player) {
|
|
105
|
+
const config = {
|
|
106
|
+
list: [],
|
|
107
|
+
defaultDefinition: '',
|
|
108
|
+
};
|
|
109
|
+
const playerData = player.config.playerData;
|
|
110
|
+
const {
|
|
111
|
+
current: { lineId, definition },
|
|
112
|
+
} = playerData;
|
|
113
|
+
const list = playerData.getDefinitionListByLineId(lineId);
|
|
114
|
+
if (Array.isArray(list) && list.length > 0) {
|
|
115
|
+
config.list = list.map(item => {
|
|
116
|
+
if (!item.text) {
|
|
117
|
+
item.text = this.getShowText(player.i18n, item, item.definition);
|
|
118
|
+
}
|
|
119
|
+
return item;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
config.defaultDefinition = definition;
|
|
124
|
+
return config;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// 清晰度切换toast提示
|
|
128
|
+
showToast(definitionItem, definition) {
|
|
129
|
+
const toast = this.player?.getPlugin('sdkToastPlugin');
|
|
130
|
+
|
|
131
|
+
if (!toast) return;
|
|
132
|
+
const txt = this.getShowText(this.i18n, definitionItem, definition);
|
|
133
|
+
|
|
134
|
+
// toast clear
|
|
135
|
+
if (this.toastInfo) {
|
|
136
|
+
clearTimeout(this.toastInfo.timer);
|
|
137
|
+
toast?.remove?.(this.toastInfo.id);
|
|
138
|
+
this.player.off(Events.AFTER_DEFINITION_CHANGE, this.toastInfo.remove);
|
|
139
|
+
this.player.off(Events.ERROR, this.toastInfo.remove);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
this.toastInfo = {
|
|
143
|
+
id: toast.add(`${(this.langText as any).switching} ${txt}...`, 0, true),
|
|
144
|
+
showTime: Date.now(),
|
|
145
|
+
delayClose: false,
|
|
146
|
+
};
|
|
147
|
+
this.toastInfo.timer = setTimeout(() => {
|
|
148
|
+
toast.remove(this.toastInfo.id);
|
|
149
|
+
clearTimeout(this.toastInfo.timer);
|
|
150
|
+
}, 2000);
|
|
151
|
+
|
|
152
|
+
this.toastInfo.remove = () => {
|
|
153
|
+
if (!this.toastInfo.id) return;
|
|
154
|
+
const now = Date.now();
|
|
155
|
+
if (now - this.toastInfo.showTime > 2000) {
|
|
156
|
+
toast.remove(this.toastInfo.id);
|
|
157
|
+
} else {
|
|
158
|
+
this.toastInfo.delayClose = true;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
this.player.once(Events.AFTER_DEFINITION_CHANGE, this.toastInfo.remove);
|
|
162
|
+
this.player.once(Events.ERROR, this.toastInfo.remove);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
selectDefinition(to: {
|
|
166
|
+
url: string;
|
|
167
|
+
definition: string;
|
|
168
|
+
[propName: string]: any;
|
|
169
|
+
}) {
|
|
170
|
+
const definitionTextKey = this.renderList?.find?.(item =>
|
|
171
|
+
this.playerData.isDefinitionMatch(item.definition, to.definition),
|
|
172
|
+
)?.definitionTextKey;
|
|
173
|
+
if (this.config.showToastOnManualClick) {
|
|
174
|
+
this.showToast(
|
|
175
|
+
{
|
|
176
|
+
...to,
|
|
177
|
+
definitionTextKey,
|
|
178
|
+
},
|
|
179
|
+
to.definition,
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
this.playerData.current.definition = to.definition;
|
|
183
|
+
if (!this.playerData.isAutoDefinition(to.definition)) {
|
|
184
|
+
this._autoRealDefinition = undefined;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
showRealDefinition(item) {
|
|
189
|
+
return (
|
|
190
|
+
item.selected &&
|
|
191
|
+
this.playerData.isAutoDefinition(item.definition) &&
|
|
192
|
+
this.playerData.showRealDefinition() &&
|
|
193
|
+
this._autoRealDefinition &&
|
|
194
|
+
!this.playerData.isAutoDefinition(this._autoRealDefinition)
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
// 更新自动挡实际档位文案,如自动 (360p);
|
|
198
|
+
handleABRDescChange = (...args) => {
|
|
199
|
+
this._autoRealDefinition = args[1] || undefined;
|
|
200
|
+
this.refreshDefinitionList();
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
handleResourceReady = (list = []) => {
|
|
204
|
+
const { list: originPlayList } = this.getCurrentDefinitionInfo(
|
|
205
|
+
this.player,
|
|
206
|
+
);
|
|
207
|
+
const newPlayList = originPlayList.filter(item => {
|
|
208
|
+
const targetDef =
|
|
209
|
+
item &&
|
|
210
|
+
list.find(sub =>
|
|
211
|
+
this.playerData.isDefinitionMatch(sub.definition, item.definition),
|
|
212
|
+
);
|
|
213
|
+
// dash 播放时会改写url为指定的序号,不然changeDefinition时传的url无法切换
|
|
214
|
+
if (
|
|
215
|
+
targetDef &&
|
|
216
|
+
this.playerData.getStreamType()?.toLowerCase() === 'dash'
|
|
217
|
+
) {
|
|
218
|
+
item.url = targetDef.url;
|
|
219
|
+
}
|
|
220
|
+
return targetDef;
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
const curDefinition =
|
|
224
|
+
list.find(item => item?.selected) || this.playerData.current;
|
|
225
|
+
const targetDefinition = newPlayList.find(item =>
|
|
226
|
+
this.playerData.isDefinitionMatch(
|
|
227
|
+
item.definition,
|
|
228
|
+
curDefinition?.definition,
|
|
229
|
+
),
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
// 重置playList
|
|
233
|
+
this.playerData.playList = newPlayList;
|
|
234
|
+
|
|
235
|
+
// 清晰度变化重置清晰度
|
|
236
|
+
if (
|
|
237
|
+
targetDefinition?.definition &&
|
|
238
|
+
this.playerData.current?.definition !== targetDefinition.definition
|
|
239
|
+
) {
|
|
240
|
+
this.playerData.current.definition = targetDefinition?.definition;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
this.refreshDefinitionList?.();
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
// PC、Mobile current、playList改动监听抽取为公共模块
|
|
247
|
+
dataMonitoring() {
|
|
248
|
+
if (!this.playerData) return;
|
|
249
|
+
// 清晰度变更,切换url
|
|
250
|
+
this.definitionSubscribeId = MyProxy.subscribeProperty(
|
|
251
|
+
this.playerData.current,
|
|
252
|
+
'definition',
|
|
253
|
+
(pre: any, cur: any) => {
|
|
254
|
+
if (pre && cur && pre !== cur && this.player) {
|
|
255
|
+
const { list } = this.getCurrentDefinitionInfo(this.player);
|
|
256
|
+
const targetDef = list.find((item: any) => item.definition === cur);
|
|
257
|
+
if (targetDef && targetDef.url) {
|
|
258
|
+
this.player.changeDefinition({
|
|
259
|
+
kid: targetDef.playAuthId,
|
|
260
|
+
...targetDef,
|
|
261
|
+
secretKey: targetDef.secretKey,
|
|
262
|
+
definition: cur,
|
|
263
|
+
url: targetDef.url,
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
if (this.clientType === 'MOBILE') {
|
|
267
|
+
this.updatePanel();
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
this.player.emit(PluginEvents.INNER_DEFINITION_CHANGE, {
|
|
271
|
+
from: pre,
|
|
272
|
+
to: cur,
|
|
273
|
+
url: targetDef.url,
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
this.player.emit(PluginEvents.PlAY_URL_CHANGE, {
|
|
277
|
+
url: targetDef.url,
|
|
278
|
+
from: PluginEvents.INNER_DEFINITION_CHANGE,
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
if (this.clientType === 'PC') {
|
|
282
|
+
this.renderItemList(cur);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (this.player.config.isLive) {
|
|
286
|
+
this._playTimer = setTimeout(() => {
|
|
287
|
+
if (this.player.ended) {
|
|
288
|
+
this.player.replay();
|
|
289
|
+
} else if (this.player.paused) {
|
|
290
|
+
this.player.play();
|
|
291
|
+
}
|
|
292
|
+
}, 1000);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
// 监听playList更新,注意只能监听到直接赋值
|
|
300
|
+
this.playListSubscribeId = MyProxy.subscribeProperty(
|
|
301
|
+
this.playerData,
|
|
302
|
+
'playList',
|
|
303
|
+
() => {
|
|
304
|
+
this.refreshDefinitionList();
|
|
305
|
+
},
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
getAutoDefRealLevel = () => {
|
|
310
|
+
if (
|
|
311
|
+
this.playerData.isAutoDefinition(this.playerData.current?.definition)
|
|
312
|
+
) {
|
|
313
|
+
const { videoWidth, videoHeight } = this.player.media;
|
|
314
|
+
if (videoWidth && videoHeight) {
|
|
315
|
+
const { list = [] } = this.getCurrentDefinitionInfo(this.player);
|
|
316
|
+
const targetDef = list.find(def => {
|
|
317
|
+
const width = def.vwidth || def.width;
|
|
318
|
+
const height = def.vheight || def.height;
|
|
319
|
+
return (
|
|
320
|
+
width && height && width === videoWidth && height === videoHeight
|
|
321
|
+
);
|
|
322
|
+
});
|
|
323
|
+
if (targetDef?.definition) {
|
|
324
|
+
if (this._autoRealDefinition !== targetDef.definition) {
|
|
325
|
+
this._autoRealDefinition = targetDef.definition;
|
|
326
|
+
this.refreshDefinitionList();
|
|
327
|
+
if (Sniffer.device === 'mobile') {
|
|
328
|
+
// mobile 需要更新下panel
|
|
329
|
+
this?.updatePanel();
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
onItemClick(...args) {
|
|
338
|
+
super.onItemClick(...args);
|
|
339
|
+
}
|
|
340
|
+
destroy() {
|
|
341
|
+
clearTimeout(this.toastInfo.timer);
|
|
342
|
+
clearTimeout(this._playTimer);
|
|
343
|
+
if (this.autoDefDetectTimer) {
|
|
344
|
+
this.autoDefDetectTimer.clear();
|
|
345
|
+
this.autoDefDetectTimer = null;
|
|
346
|
+
this.getAutoDefRealLevel = null;
|
|
347
|
+
}
|
|
348
|
+
this.off('resourceReady', this.handleResourceReady);
|
|
349
|
+
this.off('ABR_AUTO_DESC_CHANGE', this.handleABRDescChange);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
export { MixinDefinitionBase };
|