@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,199 @@
|
|
|
1
|
+
import { Events, Plugin, Util } from 'xgplayer';
|
|
2
|
+
import RateIconSVG from '../../../assets/icons/mobile/playbackrate.svg';
|
|
3
|
+
import isObject from 'lodash-es/isObject';
|
|
4
|
+
import { RATE_CHANGE } from 'xgplayer/es/events';
|
|
5
|
+
import PlayerData from '@/core/playerData';
|
|
6
|
+
|
|
7
|
+
const { POSITIONS } = Plugin;
|
|
8
|
+
|
|
9
|
+
export default class PlaybackRateMobilePlugin extends Plugin {
|
|
10
|
+
static get pluginName() {
|
|
11
|
+
return 'PlaybackRateMobilePlugin';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static get textTips() {
|
|
15
|
+
return {
|
|
16
|
+
jp: '倍速',
|
|
17
|
+
en: 'PlaybackRate',
|
|
18
|
+
zh: '倍速',
|
|
19
|
+
'zh-hk': '倍速',
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static get defaultConfig() {
|
|
24
|
+
return {
|
|
25
|
+
position: POSITIONS.CONTROLS_RIGHT,
|
|
26
|
+
index: 2.9,
|
|
27
|
+
list: [2, 1.5, 1.25, 1, 0.75, 0.5],
|
|
28
|
+
default: 1,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public playerData: PlayerData;
|
|
33
|
+
public state: any = {
|
|
34
|
+
currentRate: 1,
|
|
35
|
+
isSupport: true,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
constructor(args: any) {
|
|
39
|
+
super(args);
|
|
40
|
+
this.playerData = args.player.config.playerData;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
registerIcons() {
|
|
44
|
+
return {
|
|
45
|
+
playbackRate: {
|
|
46
|
+
icon: RateIconSVG,
|
|
47
|
+
class: 'xgplayer-rate-svg',
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
registerLanguageTexts() {
|
|
53
|
+
return {
|
|
54
|
+
rate: {
|
|
55
|
+
jp: '倍速',
|
|
56
|
+
en: 'PlaybackRate',
|
|
57
|
+
zh: '倍速',
|
|
58
|
+
'zh-hk': '倍速',
|
|
59
|
+
},
|
|
60
|
+
rateSelect: {
|
|
61
|
+
jp: '倍速選ぶ',
|
|
62
|
+
en: 'PlaybackRate',
|
|
63
|
+
zh: '倍速选择',
|
|
64
|
+
'zh-hk': '倍速選擇',
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
afterCreate() {
|
|
70
|
+
this.appendChild('.xgplayer-icon', (this.icons as any).playbackRate);
|
|
71
|
+
this.initEvents();
|
|
72
|
+
// 默认值取player的playbackRate
|
|
73
|
+
this.state.currentRate = this.player.playbackRate || 1;
|
|
74
|
+
this.changeIconText();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
afterPlayerInit() {
|
|
78
|
+
// 播放器调用start初始化播放源之后的逻辑
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
initEvents() {
|
|
82
|
+
this.bind(['click'], this.renderList.bind(this));
|
|
83
|
+
this.on(Events.RATE_CHANGE, () => {
|
|
84
|
+
// 监听playbackRate的set设置,更新state.currentRate
|
|
85
|
+
if (this.state.currentRate === this.player.playbackRate) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this.state.currentRate = this.player.playbackRate;
|
|
89
|
+
// 如果展示了列表panel,则更新panel
|
|
90
|
+
if ((this.player as any)?.panel?.isShow) {
|
|
91
|
+
this.updatePanel();
|
|
92
|
+
}
|
|
93
|
+
this.changeIconText();
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
renderList() {
|
|
98
|
+
const children = this.renderItemList();
|
|
99
|
+
this.renderPanel(children);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
renderItemList() {
|
|
103
|
+
const $content = Util.createDom(
|
|
104
|
+
'div',
|
|
105
|
+
'',
|
|
106
|
+
{},
|
|
107
|
+
'playbackRate-panel-content',
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
this.config.list.forEach((item: any) => {
|
|
111
|
+
const $item = this.renderItem(item);
|
|
112
|
+
$content.appendChild($item);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
return $content;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
renderItem(item: { textKey: string; value: number } | number) {
|
|
119
|
+
const itemObj: { textKey: string; value: number } = isObject(item)
|
|
120
|
+
? item
|
|
121
|
+
: { textKey: item + 'X', value: item };
|
|
122
|
+
const $item = Util.createDom(
|
|
123
|
+
'div',
|
|
124
|
+
'',
|
|
125
|
+
{},
|
|
126
|
+
`panel-Item ${
|
|
127
|
+
this.state.currentRate === itemObj.value ? 'select-in' : ''
|
|
128
|
+
}`,
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
$item.innerHTML = this.i18n[itemObj.textKey] || itemObj.textKey;
|
|
132
|
+
|
|
133
|
+
$item.addEventListener('click', e => {
|
|
134
|
+
e.stopPropagation();
|
|
135
|
+
e.preventDefault();
|
|
136
|
+
const props = {
|
|
137
|
+
playbackRate: {
|
|
138
|
+
from: this.player.playbackRate,
|
|
139
|
+
to: itemObj.value,
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
this.emitUserAction(e, 'change_rate', { props });
|
|
143
|
+
this.state.currentRate = itemObj.value;
|
|
144
|
+
this.player.playbackRate = itemObj.value;
|
|
145
|
+
this.updatePanel();
|
|
146
|
+
this.changeIconText();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
return $item;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
renderPanel(children: any) {
|
|
153
|
+
(this.player as any)?.panel?.showPanel(
|
|
154
|
+
children,
|
|
155
|
+
(this.langText as any).rateSelect,
|
|
156
|
+
true,
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
updatePanel() {
|
|
161
|
+
const children = this.renderItemList();
|
|
162
|
+
(this.player as any)?.panel.updatePanel(children);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
changeIconText() {
|
|
166
|
+
let scaleNum;
|
|
167
|
+
const rate: number = this.state.currentRate;
|
|
168
|
+
const rateText = rate % 1 === 0 ? rate.toFixed(1) : rate + '';
|
|
169
|
+
switch (rateText.length) {
|
|
170
|
+
case 1:
|
|
171
|
+
case 2:
|
|
172
|
+
case 3:
|
|
173
|
+
scaleNum = 0.7;
|
|
174
|
+
break;
|
|
175
|
+
case 4:
|
|
176
|
+
scaleNum = 0.5;
|
|
177
|
+
break;
|
|
178
|
+
default:
|
|
179
|
+
scaleNum = 0.7;
|
|
180
|
+
}
|
|
181
|
+
const iconTextDom = this.find('.icon-text');
|
|
182
|
+
iconTextDom.style.transform = `scale(${scaleNum})`;
|
|
183
|
+
iconTextDom.innerHTML = rateText;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
destroy() {
|
|
187
|
+
this.unbind(['click'], this.renderList.bind(this));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
render() {
|
|
191
|
+
return `
|
|
192
|
+
<xg-icon class="xgplayer-mobile-playBackRate">
|
|
193
|
+
<div class="xgplayer-icon">
|
|
194
|
+
<div class="icon-text"></div>
|
|
195
|
+
</div>
|
|
196
|
+
</xg-icon>
|
|
197
|
+
`;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { Plugin, Util } from 'xgplayer';
|
|
2
|
+
import OptionsIcon from 'xgplayer/es/plugins/common/optionsIcon';
|
|
3
|
+
import type { Stream, IPluginConfig } from '@/interface';
|
|
4
|
+
|
|
5
|
+
import { CONTROL_ICON_INDEX } from '@/constants/plugin';
|
|
6
|
+
import throttle from 'lodash-es/throttle';
|
|
7
|
+
import { MixinDefinitionBase } from '@/plugins/inner/common/definitionBasePlugin';
|
|
8
|
+
|
|
9
|
+
export interface ISdkDefinitionPluginConfig extends IPluginConfig {
|
|
10
|
+
list?: Stream[];
|
|
11
|
+
defaultDefinition?: string;
|
|
12
|
+
hidePortrait?: boolean;
|
|
13
|
+
showToastOnManualClick?: true;
|
|
14
|
+
className?: string;
|
|
15
|
+
isShowIcon?: boolean;
|
|
16
|
+
isNeedAuto?: boolean;
|
|
17
|
+
allowedSize?: null;
|
|
18
|
+
alwaysShowDefinition?: boolean; // 是否一直显示list,即list长度为1时也显示
|
|
19
|
+
}
|
|
20
|
+
export default class DefinitionPlugin extends MixinDefinitionBase(OptionsIcon) {
|
|
21
|
+
public renderList: any[];
|
|
22
|
+
public config: ISdkDefinitionPluginConfig;
|
|
23
|
+
// 插件的名称,将作为插件实例的唯一key值
|
|
24
|
+
static get pluginName() {
|
|
25
|
+
return 'sdkDefinitionPlugin';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static get defaultConfig(): ISdkDefinitionPluginConfig {
|
|
29
|
+
return {
|
|
30
|
+
// 挂载在controls的右侧,如果不指定则默认挂载在播放器根节点上
|
|
31
|
+
position: Plugin.POSITIONS.CONTROLS_RIGHT,
|
|
32
|
+
index: CONTROL_ICON_INDEX.sdkDefinitionPlugin,
|
|
33
|
+
list: [],
|
|
34
|
+
defaultDefinition: '',
|
|
35
|
+
hidePortrait: false,
|
|
36
|
+
disable: false,
|
|
37
|
+
showToastOnManualClick: true,
|
|
38
|
+
className: 'xgplayer-definition xgplayer-definition-plugin-pc',
|
|
39
|
+
isShowIcon: true,
|
|
40
|
+
isNeedAuto: true,
|
|
41
|
+
allowedSize: null,
|
|
42
|
+
alwaysShowDefinition: false, // 是否一直显示list,即list长度为1时也显示
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
constructor(args: any) {
|
|
47
|
+
const _className = args.config.className;
|
|
48
|
+
super({
|
|
49
|
+
...args,
|
|
50
|
+
config: {
|
|
51
|
+
...args.config,
|
|
52
|
+
// 若用户主动设置className,追加xgplayer-definition-plugin-pc
|
|
53
|
+
...(_className
|
|
54
|
+
? {
|
|
55
|
+
className: `${_className} xgplayer-definition-plugin-pc`,
|
|
56
|
+
}
|
|
57
|
+
: {}),
|
|
58
|
+
},
|
|
59
|
+
clientType: 'PC',
|
|
60
|
+
});
|
|
61
|
+
this.onItemClick = throttle(this.onItemClick.bind(this), 1000, {
|
|
62
|
+
trailing: true,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
registerLanguageTexts() {
|
|
67
|
+
return {
|
|
68
|
+
switching: {
|
|
69
|
+
jp: 'に切り替える',
|
|
70
|
+
en: 'Switching to',
|
|
71
|
+
zh: '正在切换至',
|
|
72
|
+
'zh-hk': '正在切換至',
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
afterCreate() {
|
|
78
|
+
super.afterCreate();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// 清晰度列表渲染
|
|
82
|
+
refreshDefinitionList() {
|
|
83
|
+
if (this.player.config?.alwaysShowDefinition) {
|
|
84
|
+
this.config.alwaysShowDefinition = true;
|
|
85
|
+
}
|
|
86
|
+
const { defaultDefinition, list } = this.getCurrentDefinitionInfo(
|
|
87
|
+
this.player,
|
|
88
|
+
);
|
|
89
|
+
this.config.defaultDefinition = defaultDefinition;
|
|
90
|
+
this.config.list = list.map((item, index) => ({
|
|
91
|
+
...item,
|
|
92
|
+
itemIndex: index,
|
|
93
|
+
}));
|
|
94
|
+
if (this.config.list && this.config.list.length > 0) {
|
|
95
|
+
if (this.config.list.length < 2) {
|
|
96
|
+
if (this.config.alwaysShowDefinition) {
|
|
97
|
+
this.renderItemList();
|
|
98
|
+
this.show();
|
|
99
|
+
} else {
|
|
100
|
+
this.hide();
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
this.renderItemList();
|
|
104
|
+
this.show();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
show() {
|
|
109
|
+
if (
|
|
110
|
+
!this.config.list ||
|
|
111
|
+
(this.config.list?.length < 2 && !this.config.alwaysShowDefinition)
|
|
112
|
+
) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
Util.addClass(this.root, 'show');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
afterPlayerInit() {
|
|
120
|
+
// 播放器调用start初始化播放源之后的逻辑
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
renderItemList(curDefinition?: string) {
|
|
124
|
+
if (Array.isArray(curDefinition)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const { list, defaultDefinition } = this.config;
|
|
128
|
+
let curIndex = 0;
|
|
129
|
+
const items = list.map((item: any, index: any) => {
|
|
130
|
+
const showItem = {
|
|
131
|
+
url: item.url,
|
|
132
|
+
definition: item.definition || '',
|
|
133
|
+
definitionTextKey: item.definitionTextKey,
|
|
134
|
+
showText: this.getShowText(this.i18n, item, item.definition),
|
|
135
|
+
isCurrent: false,
|
|
136
|
+
selected: false,
|
|
137
|
+
isDefinitionAuto: false,
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const definitionMatch =
|
|
141
|
+
typeof curDefinition === 'string'
|
|
142
|
+
? item.definition === curDefinition
|
|
143
|
+
: typeof curDefinition === 'undefined'
|
|
144
|
+
? item.definition === defaultDefinition
|
|
145
|
+
: false;
|
|
146
|
+
if (!Util.isUndefined(item.definition) && definitionMatch) {
|
|
147
|
+
showItem.isCurrent = true;
|
|
148
|
+
showItem.selected = true;
|
|
149
|
+
curIndex = index;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// 自动挡展示当前实际清晰度
|
|
153
|
+
if (this.showRealDefinition(showItem)) {
|
|
154
|
+
const _def = this.renderList?.find(item =>
|
|
155
|
+
this.playerData.isDefinitionMatch(
|
|
156
|
+
item?.definition,
|
|
157
|
+
this._autoRealDefinition,
|
|
158
|
+
),
|
|
159
|
+
);
|
|
160
|
+
const text = this.getShowText(this.i18n, _def, _def?.definition);
|
|
161
|
+
showItem.showText = text
|
|
162
|
+
? `${showItem.showText}(${text})`
|
|
163
|
+
: showItem.showText;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
showItem.isDefinitionAuto = this.playerData.isAutoDefinition(
|
|
167
|
+
item.definition,
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
return showItem;
|
|
171
|
+
});
|
|
172
|
+
// 记录最新的renderList
|
|
173
|
+
this.renderList = items;
|
|
174
|
+
super.renderItemList(items, curIndex);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
onItemClick(e: any, data: any) {
|
|
178
|
+
if (data.to.definition !== this.playerData.current.definition) {
|
|
179
|
+
const from = this.playerData.getCurrentStreams()?.[0];
|
|
180
|
+
this.emitUserAction(e, 'change_definition', { from, to: data.to });
|
|
181
|
+
this.selectDef(data.to);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
selectDef(to: { url: string; definition: string; [propName: string]: any }) {
|
|
186
|
+
this.selectDefinition(to);
|
|
187
|
+
// 平板点击后自动关闭列表
|
|
188
|
+
'ontouchstart' in window && this.optionsList.hide();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
changeDefinition(definition: string) {
|
|
192
|
+
const to = this.renderList.find(item =>
|
|
193
|
+
this.playerData.isDefinitionMatch(item.definition, definition),
|
|
194
|
+
);
|
|
195
|
+
if (to) {
|
|
196
|
+
this.selectDef(to);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
destroy() {
|
|
201
|
+
super.destroy();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Plugin, Util } from 'xgplayer';
|
|
2
|
+
import OptionsIcon from 'xgplayer/es/plugins/common/optionsIcon';
|
|
3
|
+
import { PluginEvents, SDKEvents } from '../../../constants/event';
|
|
4
|
+
import { CONTROL_ICON_INDEX } from '@/constants/plugin';
|
|
5
|
+
import PlayerData from '@/core/playerData';
|
|
6
|
+
|
|
7
|
+
export default class MultilinePlugin extends OptionsIcon {
|
|
8
|
+
// 播放器值
|
|
9
|
+
public playerData: PlayerData;
|
|
10
|
+
|
|
11
|
+
// 插件的名称,将作为插件实例的唯一key值
|
|
12
|
+
static get pluginName() {
|
|
13
|
+
return 'sdkMultilinePlugin';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static get defaultConfig() {
|
|
17
|
+
return {
|
|
18
|
+
// 挂载在controls的右侧,如果不指定则默认挂载在播放器根节点上
|
|
19
|
+
position: Plugin.POSITIONS.CONTROLS_RIGHT,
|
|
20
|
+
index: CONTROL_ICON_INDEX.sdkMultilinePlugin,
|
|
21
|
+
list: [],
|
|
22
|
+
defaultLine: 0,
|
|
23
|
+
className: 'xgplayer-multiline',
|
|
24
|
+
hidePortrait: false,
|
|
25
|
+
isShowIcon: true,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
beforeCreate(args: any) {
|
|
30
|
+
const playerData = args.player.config.playerData;
|
|
31
|
+
const list = playerData.getLineList();
|
|
32
|
+
const {
|
|
33
|
+
current: { lineId },
|
|
34
|
+
} = playerData;
|
|
35
|
+
if (Array.isArray(list) && list.length > 0) {
|
|
36
|
+
args.config.list = list.map(item => {
|
|
37
|
+
item.text = args.player.i18n[item.lineTextKey] || item.lineTextKey;
|
|
38
|
+
return item;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
args.config.defaultLine = lineId;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
constructor(args: any) {
|
|
45
|
+
super(args);
|
|
46
|
+
this.playerData = this.playerConfig.playerData;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
afterCreate() {
|
|
50
|
+
super.afterCreate();
|
|
51
|
+
if (this.config.list.length < 2) {
|
|
52
|
+
this.hide();
|
|
53
|
+
} else {
|
|
54
|
+
this.renderItemList();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
afterPlayerInit() {
|
|
59
|
+
// 播放器调用start初始化播放源之后的逻辑
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
renderItemList() {
|
|
63
|
+
const { list, defaultLine } = this.config;
|
|
64
|
+
let curIndex = 0;
|
|
65
|
+
const items = list.map((item: any, index: any) => {
|
|
66
|
+
const showItem = {
|
|
67
|
+
lineId: item.lineId || '',
|
|
68
|
+
showText: this.i18n[item.lineTextKey] || item.lineTextKey,
|
|
69
|
+
isCurrent: false,
|
|
70
|
+
selected: false,
|
|
71
|
+
};
|
|
72
|
+
if (
|
|
73
|
+
!Util.isUndefined(item.lineId) &&
|
|
74
|
+
item.lineId?.toString() === defaultLine?.toString()
|
|
75
|
+
) {
|
|
76
|
+
showItem.isCurrent = true;
|
|
77
|
+
showItem.selected = true;
|
|
78
|
+
curIndex = index;
|
|
79
|
+
}
|
|
80
|
+
return showItem;
|
|
81
|
+
});
|
|
82
|
+
super.renderItemList(items, curIndex);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
onItemClick(e: any, data: any) {
|
|
86
|
+
this.player.emit(PluginEvents.LINE_CHANGE, {
|
|
87
|
+
from: this.playerData.current.lineId,
|
|
88
|
+
to: data.to.lineId,
|
|
89
|
+
});
|
|
90
|
+
this.playerData.current.lineId = data.to.lineId;
|
|
91
|
+
this.player.emit(SDKEvents.PLAYER_REBUILD);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import SdkPlugin from '@/sdkPlugin/sdkPlugin';
|
|
2
|
+
|
|
3
|
+
class Abr extends SdkPlugin {
|
|
4
|
+
static get pluginName() {
|
|
5
|
+
return 'Abr';
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
constructor(args) {
|
|
9
|
+
super(args);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static get defaultConfig() {
|
|
13
|
+
return {
|
|
14
|
+
autoDefiText: '', //自动切换清晰度对应显示文案
|
|
15
|
+
isOpenAutoDefi: false, //是否开启功能,默认为false
|
|
16
|
+
interval: 1000, //调用算法频率
|
|
17
|
+
hurryThreshold: 0.25,
|
|
18
|
+
lowThreshold: 0.4,
|
|
19
|
+
highThreshold: 0.7,
|
|
20
|
+
noStallCheckTime: 5, //多久后算消费视频,单位秒
|
|
21
|
+
isOpenHint: false, //是否开启消费视频阶段降码率提示文案,默认false
|
|
22
|
+
method: 31,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async beforePlayerCreate() {
|
|
27
|
+
return await this.prepareAbrModule();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private async prepareAbrModule() {
|
|
31
|
+
return this.sdk.playerData?.adapter?.prepareAbrModule(
|
|
32
|
+
this.playerData,
|
|
33
|
+
this.sdk.sdkUmdLoader,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
adaptAbrOptions() {
|
|
38
|
+
const autoBitrateOpts = this.playerData.configs?.autoBitrateOpts;
|
|
39
|
+
// 只要用户有设置autoBitrateOpts参数即返回ABR完整参数
|
|
40
|
+
if (autoBitrateOpts) {
|
|
41
|
+
const defaultDefinition = this.playerData.defaultDefinition;
|
|
42
|
+
|
|
43
|
+
// 西瓜ABR消费配置
|
|
44
|
+
return {
|
|
45
|
+
...Abr.defaultConfig,
|
|
46
|
+
...autoBitrateOpts,
|
|
47
|
+
autoDefiText: autoBitrateOpts.autoDefinitionText || '',
|
|
48
|
+
isOpenAutoDefi: this.playerData.isOpenABR(),
|
|
49
|
+
isPlayAutoDefi: this.playerData.isPlayAutoDefinition(defaultDefinition),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
applyAbrConfig(finalOptions) {
|
|
55
|
+
const autoBitrateOpts = this.adaptAbrOptions();
|
|
56
|
+
if (!autoBitrateOpts) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
// 追加ABR配置
|
|
60
|
+
this.sdk.playerData?.adapter?.applyAbrPluginConfig(
|
|
61
|
+
finalOptions,
|
|
62
|
+
autoBitrateOpts,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default Abr;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import SdkPlugin from '@/sdkPlugin/sdkPlugin';
|
|
2
|
+
import { LicenseFeature } from '@/license';
|
|
3
|
+
|
|
4
|
+
class AdaptRange extends SdkPlugin {
|
|
5
|
+
static get pluginName() {
|
|
6
|
+
return 'AdaptRange';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
constructor(args) {
|
|
10
|
+
super(args);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
adaptRangeOptions() {
|
|
14
|
+
const _range = this.playerData.configs?.adaptRange ?? undefined;
|
|
15
|
+
// adaptRange配置开启,且当前StreamType&环境支持adaptRange
|
|
16
|
+
if (
|
|
17
|
+
!_range?.enable ||
|
|
18
|
+
!this.playerData.adapter?.canAdaptRangeEnable?.() ||
|
|
19
|
+
!this.playerData.configs?.licensSupportModuleList.includes[
|
|
20
|
+
LicenseFeature.ADAPT_RANGE
|
|
21
|
+
]
|
|
22
|
+
) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const _opts = this.playerData.adapter.adaptRangeDefaultOptions();
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
...(_opts ?? {}),
|
|
30
|
+
..._range,
|
|
31
|
+
minTargetCacheDur: _range.minCacheDuration ?? _opts?.minTargetCacheDur,
|
|
32
|
+
maxTargetCacheDur: _range.maxCacheDuration ?? _opts?.maxTargetCacheDur,
|
|
33
|
+
rangeMinDuration: _range.minRangeDuration ?? _opts?.rangeMinDuration,
|
|
34
|
+
rangeMaxDuration: _range.maxRangeDuration ?? _opts?.rangeMaxDuration,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
applyRangeConfig(finalOptions) {
|
|
39
|
+
const adaptRangeOptions = this.adaptRangeOptions();
|
|
40
|
+
if (adaptRangeOptions && finalOptions) {
|
|
41
|
+
this.playerData.adapter.applyAdaptRangePluginConfig(
|
|
42
|
+
finalOptions,
|
|
43
|
+
adaptRangeOptions,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default AdaptRange;
|