@volcengine/veplayer 2.5.1-rc.2 → 2.5.2-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.d.ts +34 -10
- package/esm/veplayer.biz.live.development.js +89 -50
- package/esm/veplayer.biz.live.production.js +1 -1
- package/esm/veplayer.d.ts +156 -56
- package/esm/veplayer.development.js +163 -110
- package/esm/veplayer.live.d.ts +156 -56
- package/esm/veplayer.live.development.js +163 -110
- package/esm/veplayer.live.production.js +3 -5
- package/esm/veplayer.production.js +3 -5
- package/esm/veplayer.vod.d.ts +34 -10
- package/esm/veplayer.vod.development.js +92 -66
- package/esm/veplayer.vod.production.js +3 -5
- package/package.json +1 -1
- package/umd/index.d.ts +34 -10
- package/umd/veplayer.biz.live.development.js +110 -258
- package/umd/veplayer.biz.live.production.js +1 -1
- package/umd/veplayer.d.ts +156 -56
- package/umd/veplayer.development.js +163 -110
- package/umd/veplayer.live.d.ts +156 -56
- package/umd/veplayer.live.development.js +165 -115
- package/umd/veplayer.live.production.js +1 -1
- package/umd/veplayer.production.js +1 -1
- package/umd/veplayer.vod.d.ts +34 -10
- package/umd/veplayer.vod.development.js +92 -66
- package/umd/veplayer.vod.production.js +1 -1
- package/veplayer.d.ts +156 -56
- package/veplayer.live.d.ts +156 -56
- package/veplayer.vod.d.ts +34 -10
package/esm/veplayer.vod.d.ts
CHANGED
|
@@ -419,7 +419,14 @@ declare enum Level {
|
|
|
419
419
|
/** {en}
|
|
420
420
|
* @brief Error.
|
|
421
421
|
*/
|
|
422
|
-
Error = "Error"
|
|
422
|
+
Error = "Error",
|
|
423
|
+
/** {zh}
|
|
424
|
+
* @brief 提示。
|
|
425
|
+
*/
|
|
426
|
+
/** {en}
|
|
427
|
+
* @brief Warn.
|
|
428
|
+
*/
|
|
429
|
+
Warn = "Warn"
|
|
423
430
|
}
|
|
424
431
|
declare enum ErrorCode {
|
|
425
432
|
/** {zh}
|
|
@@ -1501,15 +1508,16 @@ type PrepareResult = {
|
|
|
1501
1508
|
options?: Partial<VePlayerBaseOptions>;
|
|
1502
1509
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1503
1510
|
plugins?: any[];
|
|
1511
|
+
useSrc?: boolean;
|
|
1504
1512
|
};
|
|
1505
1513
|
type PreparePlugins = (url: string) => Promise<PrepareResult> | undefined;
|
|
1506
1514
|
/** {zh}
|
|
1507
1515
|
* @detail option
|
|
1508
|
-
* @brief 视频的实际编码格式。如果您在degradation 设置了 SoftFirst 属性(即硬解不支持降级软解),建议您传入该参数,省去探测实际编码格式的操作。
|
|
1516
|
+
* @brief 视频的实际编码格式。如果您在 degradation 设置了 SoftFirst 属性(即硬解不支持降级软解),建议您传入该参数,省去探测实际编码格式的操作。
|
|
1509
1517
|
*/
|
|
1510
1518
|
/** {en}
|
|
1511
1519
|
* @detail option
|
|
1512
|
-
* @brief The actual codec of the video.
|
|
1520
|
+
* @brief The actual codec of the video. If you set the SoftFirst property in degradation (that is, hard solutions do not support downgrading soft solutions), it is recommended that you pass this parameter to save the operation of probing the actual encoding format.
|
|
1513
1521
|
*/
|
|
1514
1522
|
declare enum Codec {
|
|
1515
1523
|
/** {zh}
|
|
@@ -2147,16 +2155,17 @@ declare class VePlayerBase {
|
|
|
2147
2155
|
* @hidden
|
|
2148
2156
|
*/
|
|
2149
2157
|
prepare(url: string): Promise<{
|
|
2150
|
-
plugins: any[];
|
|
2158
|
+
plugins: any[] | undefined;
|
|
2151
2159
|
options: Partial<VePlayerBaseOptions> | undefined;
|
|
2160
|
+
isSameProtocol: boolean | "";
|
|
2161
|
+
useSrc: boolean | undefined;
|
|
2152
2162
|
}>;
|
|
2153
2163
|
private _handleFallback;
|
|
2154
2164
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2155
2165
|
private _transformEvent;
|
|
2156
2166
|
private _switch;
|
|
2167
|
+
private _switchDifferentProtocolUrl;
|
|
2157
2168
|
private _switchUrl;
|
|
2158
|
-
// 获取需要卸载和需要注册的播放插件
|
|
2159
|
-
private _diffPlugins;
|
|
2160
2169
|
private _callBeforePlayerInitForUrl;
|
|
2161
2170
|
}
|
|
2162
2171
|
declare const enum State {
|
|
@@ -2679,7 +2688,14 @@ declare namespace strategy {
|
|
|
2679
2688
|
/** {en}
|
|
2680
2689
|
* @brief Error.
|
|
2681
2690
|
*/
|
|
2682
|
-
Error = "Error"
|
|
2691
|
+
Error = "Error",
|
|
2692
|
+
/** {zh}
|
|
2693
|
+
* @brief 提示。
|
|
2694
|
+
*/
|
|
2695
|
+
/** {en}
|
|
2696
|
+
* @brief Warn.
|
|
2697
|
+
*/
|
|
2698
|
+
Warn = "Warn"
|
|
2683
2699
|
}
|
|
2684
2700
|
enum ErrorCode {
|
|
2685
2701
|
/** {zh}
|
|
@@ -3824,15 +3840,16 @@ declare namespace strategy {
|
|
|
3824
3840
|
options?: Partial<VePlayerBaseOptions>;
|
|
3825
3841
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3826
3842
|
plugins?: any[];
|
|
3843
|
+
useSrc?: boolean;
|
|
3827
3844
|
};
|
|
3828
3845
|
type PreparePlugins = (url: string) => Promise<PrepareResult> | undefined;
|
|
3829
3846
|
/** {zh}
|
|
3830
3847
|
* @detail option
|
|
3831
|
-
* @brief 视频的实际编码格式。如果您在degradation 设置了 SoftFirst 属性(即硬解不支持降级软解),建议您传入该参数,省去探测实际编码格式的操作。
|
|
3848
|
+
* @brief 视频的实际编码格式。如果您在 degradation 设置了 SoftFirst 属性(即硬解不支持降级软解),建议您传入该参数,省去探测实际编码格式的操作。
|
|
3832
3849
|
*/
|
|
3833
3850
|
/** {en}
|
|
3834
3851
|
* @detail option
|
|
3835
|
-
* @brief The actual codec of the video.
|
|
3852
|
+
* @brief The actual codec of the video. If you set the SoftFirst property in degradation (that is, hard solutions do not support downgrading soft solutions), it is recommended that you pass this parameter to save the operation of probing the actual encoding format.
|
|
3836
3853
|
*/
|
|
3837
3854
|
enum Codec {
|
|
3838
3855
|
/** {zh}
|
|
@@ -4172,7 +4189,14 @@ declare namespace error {
|
|
|
4172
4189
|
/** {en}
|
|
4173
4190
|
* @brief Error.
|
|
4174
4191
|
*/
|
|
4175
|
-
Error = "Error"
|
|
4192
|
+
Error = "Error",
|
|
4193
|
+
/** {zh}
|
|
4194
|
+
* @brief 提示。
|
|
4195
|
+
*/
|
|
4196
|
+
/** {en}
|
|
4197
|
+
* @brief Warn.
|
|
4198
|
+
*/
|
|
4199
|
+
Warn = "Warn"
|
|
4176
4200
|
}
|
|
4177
4201
|
enum ErrorCode {
|
|
4178
4202
|
/** {zh}
|
|
@@ -13706,7 +13706,7 @@ class VePlayerBase {
|
|
|
13706
13706
|
* @brief Retrieve the player SDK version number.
|
|
13707
13707
|
*/
|
|
13708
13708
|
get playerVersion() {
|
|
13709
|
-
return "2.5.
|
|
13709
|
+
return "2.5.2-rc.0";
|
|
13710
13710
|
}
|
|
13711
13711
|
/** {zh}
|
|
13712
13712
|
* @brief 获取当前播放视频的清晰度唯一标识(definition)。
|
|
@@ -14190,25 +14190,27 @@ class VePlayerBase {
|
|
|
14190
14190
|
* @hidden
|
|
14191
14191
|
*/
|
|
14192
14192
|
async prepare(url) {
|
|
14193
|
-
var _a, _b;
|
|
14193
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
14194
14194
|
const result = await ((_a = this._preparePlugins) == null ? void 0 : _a.call(this, url));
|
|
14195
|
-
const
|
|
14196
|
-
|
|
14197
|
-
|
|
14198
|
-
)
|
|
14199
|
-
|
|
14200
|
-
|
|
14201
|
-
|
|
14202
|
-
}
|
|
14195
|
+
const newUrl = ((_b = result == null ? void 0 : result.options) == null ? void 0 : _b.url) ?? url;
|
|
14196
|
+
const oldUrl = (_d = (_c = this._player) == null ? void 0 : _c.config) == null ? void 0 : _d.url;
|
|
14197
|
+
const isSameProtocol = oldUrl && getStreamType(newUrl) === getStreamType(oldUrl);
|
|
14198
|
+
if (!isSameProtocol) {
|
|
14199
|
+
(_f = (_e = this._previousPrepareResult) == null ? void 0 : _e.plugins) == null ? void 0 : _f.forEach((plugin) => {
|
|
14200
|
+
this._player.unRegisterPlugin(plugin.pluginName);
|
|
14201
|
+
});
|
|
14202
|
+
}
|
|
14203
14203
|
this._previousPrepareResult = result;
|
|
14204
14204
|
if (result == null ? void 0 : result.options) {
|
|
14205
14205
|
this._player.setConfig(result.options);
|
|
14206
14206
|
}
|
|
14207
14207
|
return {
|
|
14208
|
-
plugins:
|
|
14208
|
+
plugins: isSameProtocol ? [] : (_g = result == null ? void 0 : result.plugins) == null ? void 0 : _g.map((plugin) => {
|
|
14209
14209
|
return this._player.registerPlugin(plugin);
|
|
14210
14210
|
}),
|
|
14211
|
-
options: result == null ? void 0 : result.options
|
|
14211
|
+
options: result == null ? void 0 : result.options,
|
|
14212
|
+
isSameProtocol,
|
|
14213
|
+
useSrc: result == null ? void 0 : result.useSrc
|
|
14212
14214
|
};
|
|
14213
14215
|
}
|
|
14214
14216
|
async _handleFallback(err) {
|
|
@@ -14251,81 +14253,105 @@ class VePlayerBase {
|
|
|
14251
14253
|
async _switch(targetDefinition) {
|
|
14252
14254
|
var _a, _b, _c, _d, _e, _f;
|
|
14253
14255
|
const preDefinition = clonedeep(this._sourceManager.definition);
|
|
14254
|
-
const
|
|
14256
|
+
const isPaused = this._player.paused && !this._player.isError;
|
|
14257
|
+
const {
|
|
14258
|
+
plugins: newPlugins,
|
|
14259
|
+
options,
|
|
14260
|
+
isSameProtocol,
|
|
14261
|
+
useSrc
|
|
14262
|
+
} = await this.prepare(targetDefinition.url) || {};
|
|
14255
14263
|
if (options == null ? void 0 : options.url) {
|
|
14256
14264
|
targetDefinition.url = options == null ? void 0 : options.url;
|
|
14257
14265
|
}
|
|
14258
14266
|
this._sourceManager.switch(targetDefinition);
|
|
14259
14267
|
(_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.sources.renderItemList();
|
|
14260
14268
|
(_d = (_c = this._player) == null ? void 0 : _c.plugins) == null ? void 0 : _d.definition.renderItemList();
|
|
14261
|
-
|
|
14262
|
-
|
|
14263
|
-
|
|
14264
|
-
|
|
14265
|
-
|
|
14266
|
-
|
|
14267
|
-
|
|
14269
|
+
const isSourceSwitching = ((_e = targetDefinition == null ? void 0 : targetDefinition.source) == null ? void 0 : _e.name) !== ((_f = preDefinition == null ? void 0 : preDefinition.source) == null ? void 0 : _f.name);
|
|
14270
|
+
this._player.config.url = targetDefinition.url;
|
|
14271
|
+
if (isSameProtocol) {
|
|
14272
|
+
if (isSourceSwitching) {
|
|
14273
|
+
this.emit(Events.SOURCE_CHANGE);
|
|
14274
|
+
this._player.switchURL(targetDefinition.url);
|
|
14275
|
+
} else {
|
|
14276
|
+
this._player.changeDefinition(targetDefinition, preDefinition);
|
|
14277
|
+
}
|
|
14268
14278
|
} else {
|
|
14269
|
-
this.
|
|
14279
|
+
this.emit(
|
|
14280
|
+
isSourceSwitching ? Events.SOURCE_CHANGE : Events.DEFINITION_CHANGE
|
|
14281
|
+
);
|
|
14282
|
+
await this._switchDifferentProtocolUrl(
|
|
14283
|
+
newPlugins,
|
|
14284
|
+
targetDefinition.url,
|
|
14285
|
+
isPaused,
|
|
14286
|
+
useSrc
|
|
14287
|
+
);
|
|
14288
|
+
!isSourceSwitching && this.emit(Events.AFTER_DEFINITION_CHANGE);
|
|
14270
14289
|
}
|
|
14271
14290
|
}
|
|
14291
|
+
async _switchDifferentProtocolUrl(plugins, url, isPaused, useSrc) {
|
|
14292
|
+
var _a, _b;
|
|
14293
|
+
if (useSrc && this._player.media) {
|
|
14294
|
+
if ((_a = this._player.config) == null ? void 0 : _a.preProcessUrl) {
|
|
14295
|
+
url = (_b = this._player.config) == null ? void 0 : _b.preProcessUrl(url).url;
|
|
14296
|
+
}
|
|
14297
|
+
this._player.media.src = url;
|
|
14298
|
+
}
|
|
14299
|
+
if (plugins == null ? void 0 : plugins.length) {
|
|
14300
|
+
await this._callBeforePlayerInitForUrl(plugins);
|
|
14301
|
+
}
|
|
14302
|
+
return new Promise((resolve) => {
|
|
14303
|
+
const curTime = this._player.currentTime;
|
|
14304
|
+
const _canplay = () => {
|
|
14305
|
+
console.log("canplay canplay");
|
|
14306
|
+
this._player.currentTime = curTime;
|
|
14307
|
+
if (isPaused) {
|
|
14308
|
+
this._player.once(CANPLAY, () => {
|
|
14309
|
+
this._player.pause();
|
|
14310
|
+
});
|
|
14311
|
+
}
|
|
14312
|
+
resolve();
|
|
14313
|
+
};
|
|
14314
|
+
if (sniffer.os.isAndroid) {
|
|
14315
|
+
this.once(TIME_UPDATE, () => {
|
|
14316
|
+
_canplay();
|
|
14317
|
+
});
|
|
14318
|
+
} else {
|
|
14319
|
+
this.once(CANPLAY, () => {
|
|
14320
|
+
_canplay();
|
|
14321
|
+
});
|
|
14322
|
+
}
|
|
14323
|
+
this._player.play();
|
|
14324
|
+
});
|
|
14325
|
+
}
|
|
14272
14326
|
async _switchUrl(url, config) {
|
|
14273
|
-
const
|
|
14327
|
+
const isPaused = this._player.paused && !this._player.isError;
|
|
14328
|
+
const {
|
|
14329
|
+
plugins: newPlugins,
|
|
14330
|
+
options,
|
|
14331
|
+
isSameProtocol,
|
|
14332
|
+
useSrc
|
|
14333
|
+
} = await this.prepare(url) || {};
|
|
14274
14334
|
const newUrl = (options == null ? void 0 : options.url) ?? url;
|
|
14275
14335
|
this._sourceManager.url = newUrl;
|
|
14276
|
-
|
|
14277
|
-
|
|
14278
|
-
} else {
|
|
14336
|
+
this._player.config.url = newUrl;
|
|
14337
|
+
if (isSameProtocol) {
|
|
14279
14338
|
const res = this._player.switchURL(newUrl, {
|
|
14280
14339
|
seamless: config == null ? void 0 : config.seamless
|
|
14281
14340
|
});
|
|
14282
|
-
const curTime = this._player.currentTime;
|
|
14283
14341
|
if (res && res.then) {
|
|
14284
14342
|
return res;
|
|
14285
|
-
} else {
|
|
14286
|
-
return new Promise((resolve) => {
|
|
14287
|
-
const isPaused = this._player.paused && !this._player.isError;
|
|
14288
|
-
const _canplay = () => {
|
|
14289
|
-
this._player.currentTime = curTime;
|
|
14290
|
-
if (isPaused) {
|
|
14291
|
-
this._player.once(CANPLAY, () => {
|
|
14292
|
-
this._player.pause();
|
|
14293
|
-
});
|
|
14294
|
-
}
|
|
14295
|
-
resolve();
|
|
14296
|
-
};
|
|
14297
|
-
if (sniffer.os.isAndroid) {
|
|
14298
|
-
this.once(TIME_UPDATE, () => {
|
|
14299
|
-
_canplay();
|
|
14300
|
-
});
|
|
14301
|
-
} else {
|
|
14302
|
-
this.once(CANPLAY, () => {
|
|
14303
|
-
_canplay();
|
|
14304
|
-
});
|
|
14305
|
-
}
|
|
14306
|
-
this._player.play();
|
|
14307
|
-
});
|
|
14308
14343
|
}
|
|
14344
|
+
} else {
|
|
14345
|
+
return this._switchDifferentProtocolUrl(
|
|
14346
|
+
newPlugins,
|
|
14347
|
+
newUrl,
|
|
14348
|
+
isPaused,
|
|
14349
|
+
useSrc
|
|
14350
|
+
);
|
|
14309
14351
|
}
|
|
14310
14352
|
}
|
|
14311
|
-
|
|
14312
|
-
_diffPlugins(previousPlugins, newPlugins) {
|
|
14313
|
-
const previousPluginNames = previousPlugins.map((item) => item.pluginName);
|
|
14314
|
-
const newPluginNames = newPlugins.map((item) => item.pluginName);
|
|
14315
|
-
const removedPlugins = previousPluginNames.filter(
|
|
14316
|
-
(name) => !newPluginNames.includes(name)
|
|
14317
|
-
);
|
|
14318
|
-
const addedPlugins = newPlugins.filter(
|
|
14319
|
-
(name) => !previousPluginNames.includes(name.pluginName)
|
|
14320
|
-
);
|
|
14321
|
-
return {
|
|
14322
|
-
removedPlugins,
|
|
14323
|
-
addedPlugins
|
|
14324
|
-
};
|
|
14325
|
-
}
|
|
14326
|
-
_callBeforePlayerInitForUrl(newPlugins, url) {
|
|
14353
|
+
_callBeforePlayerInitForUrl(newPlugins) {
|
|
14327
14354
|
return new Promise((resolve) => {
|
|
14328
|
-
this._player.config.url = url;
|
|
14329
14355
|
newPlugins == null ? void 0 : newPlugins.forEach((plugin) => {
|
|
14330
14356
|
plugin.beforePlayerInit();
|
|
14331
14357
|
});
|