@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/umd/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}
|
|
@@ -13710,7 +13710,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13710
13710
|
* @brief Retrieve the player SDK version number.
|
|
13711
13711
|
*/
|
|
13712
13712
|
get playerVersion() {
|
|
13713
|
-
return "2.5.
|
|
13713
|
+
return "2.5.2-rc.0";
|
|
13714
13714
|
}
|
|
13715
13715
|
/** {zh}
|
|
13716
13716
|
* @brief 获取当前播放视频的清晰度唯一标识(definition)。
|
|
@@ -14194,25 +14194,27 @@ var __publicField = (obj, key, value) => {
|
|
|
14194
14194
|
* @hidden
|
|
14195
14195
|
*/
|
|
14196
14196
|
async prepare(url) {
|
|
14197
|
-
var _a, _b;
|
|
14197
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
14198
14198
|
const result = await ((_a = this._preparePlugins) == null ? void 0 : _a.call(this, url));
|
|
14199
|
-
const
|
|
14200
|
-
|
|
14201
|
-
|
|
14202
|
-
)
|
|
14203
|
-
|
|
14204
|
-
|
|
14205
|
-
|
|
14206
|
-
}
|
|
14199
|
+
const newUrl = ((_b = result == null ? void 0 : result.options) == null ? void 0 : _b.url) ?? url;
|
|
14200
|
+
const oldUrl = (_d = (_c = this._player) == null ? void 0 : _c.config) == null ? void 0 : _d.url;
|
|
14201
|
+
const isSameProtocol = oldUrl && getStreamType(newUrl) === getStreamType(oldUrl);
|
|
14202
|
+
if (!isSameProtocol) {
|
|
14203
|
+
(_f = (_e = this._previousPrepareResult) == null ? void 0 : _e.plugins) == null ? void 0 : _f.forEach((plugin) => {
|
|
14204
|
+
this._player.unRegisterPlugin(plugin.pluginName);
|
|
14205
|
+
});
|
|
14206
|
+
}
|
|
14207
14207
|
this._previousPrepareResult = result;
|
|
14208
14208
|
if (result == null ? void 0 : result.options) {
|
|
14209
14209
|
this._player.setConfig(result.options);
|
|
14210
14210
|
}
|
|
14211
14211
|
return {
|
|
14212
|
-
plugins:
|
|
14212
|
+
plugins: isSameProtocol ? [] : (_g = result == null ? void 0 : result.plugins) == null ? void 0 : _g.map((plugin) => {
|
|
14213
14213
|
return this._player.registerPlugin(plugin);
|
|
14214
14214
|
}),
|
|
14215
|
-
options: result == null ? void 0 : result.options
|
|
14215
|
+
options: result == null ? void 0 : result.options,
|
|
14216
|
+
isSameProtocol,
|
|
14217
|
+
useSrc: result == null ? void 0 : result.useSrc
|
|
14216
14218
|
};
|
|
14217
14219
|
}
|
|
14218
14220
|
async _handleFallback(err) {
|
|
@@ -14255,81 +14257,105 @@ var __publicField = (obj, key, value) => {
|
|
|
14255
14257
|
async _switch(targetDefinition) {
|
|
14256
14258
|
var _a, _b, _c, _d, _e, _f;
|
|
14257
14259
|
const preDefinition = clonedeep(this._sourceManager.definition);
|
|
14258
|
-
const
|
|
14260
|
+
const isPaused = this._player.paused && !this._player.isError;
|
|
14261
|
+
const {
|
|
14262
|
+
plugins: newPlugins,
|
|
14263
|
+
options,
|
|
14264
|
+
isSameProtocol,
|
|
14265
|
+
useSrc
|
|
14266
|
+
} = await this.prepare(targetDefinition.url) || {};
|
|
14259
14267
|
if (options == null ? void 0 : options.url) {
|
|
14260
14268
|
targetDefinition.url = options == null ? void 0 : options.url;
|
|
14261
14269
|
}
|
|
14262
14270
|
this._sourceManager.switch(targetDefinition);
|
|
14263
14271
|
(_b = (_a = this._player) == null ? void 0 : _a.plugins) == null ? void 0 : _b.sources.renderItemList();
|
|
14264
14272
|
(_d = (_c = this._player) == null ? void 0 : _c.plugins) == null ? void 0 : _d.definition.renderItemList();
|
|
14265
|
-
|
|
14266
|
-
|
|
14267
|
-
|
|
14268
|
-
|
|
14269
|
-
|
|
14270
|
-
|
|
14271
|
-
|
|
14273
|
+
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);
|
|
14274
|
+
this._player.config.url = targetDefinition.url;
|
|
14275
|
+
if (isSameProtocol) {
|
|
14276
|
+
if (isSourceSwitching) {
|
|
14277
|
+
this.emit(Events.SOURCE_CHANGE);
|
|
14278
|
+
this._player.switchURL(targetDefinition.url);
|
|
14279
|
+
} else {
|
|
14280
|
+
this._player.changeDefinition(targetDefinition, preDefinition);
|
|
14281
|
+
}
|
|
14272
14282
|
} else {
|
|
14273
|
-
this.
|
|
14283
|
+
this.emit(
|
|
14284
|
+
isSourceSwitching ? Events.SOURCE_CHANGE : Events.DEFINITION_CHANGE
|
|
14285
|
+
);
|
|
14286
|
+
await this._switchDifferentProtocolUrl(
|
|
14287
|
+
newPlugins,
|
|
14288
|
+
targetDefinition.url,
|
|
14289
|
+
isPaused,
|
|
14290
|
+
useSrc
|
|
14291
|
+
);
|
|
14292
|
+
!isSourceSwitching && this.emit(Events.AFTER_DEFINITION_CHANGE);
|
|
14274
14293
|
}
|
|
14275
14294
|
}
|
|
14295
|
+
async _switchDifferentProtocolUrl(plugins, url, isPaused, useSrc) {
|
|
14296
|
+
var _a, _b;
|
|
14297
|
+
if (useSrc && this._player.media) {
|
|
14298
|
+
if ((_a = this._player.config) == null ? void 0 : _a.preProcessUrl) {
|
|
14299
|
+
url = (_b = this._player.config) == null ? void 0 : _b.preProcessUrl(url).url;
|
|
14300
|
+
}
|
|
14301
|
+
this._player.media.src = url;
|
|
14302
|
+
}
|
|
14303
|
+
if (plugins == null ? void 0 : plugins.length) {
|
|
14304
|
+
await this._callBeforePlayerInitForUrl(plugins);
|
|
14305
|
+
}
|
|
14306
|
+
return new Promise((resolve) => {
|
|
14307
|
+
const curTime = this._player.currentTime;
|
|
14308
|
+
const _canplay = () => {
|
|
14309
|
+
console.log("canplay canplay");
|
|
14310
|
+
this._player.currentTime = curTime;
|
|
14311
|
+
if (isPaused) {
|
|
14312
|
+
this._player.once(CANPLAY, () => {
|
|
14313
|
+
this._player.pause();
|
|
14314
|
+
});
|
|
14315
|
+
}
|
|
14316
|
+
resolve();
|
|
14317
|
+
};
|
|
14318
|
+
if (sniffer.os.isAndroid) {
|
|
14319
|
+
this.once(TIME_UPDATE, () => {
|
|
14320
|
+
_canplay();
|
|
14321
|
+
});
|
|
14322
|
+
} else {
|
|
14323
|
+
this.once(CANPLAY, () => {
|
|
14324
|
+
_canplay();
|
|
14325
|
+
});
|
|
14326
|
+
}
|
|
14327
|
+
this._player.play();
|
|
14328
|
+
});
|
|
14329
|
+
}
|
|
14276
14330
|
async _switchUrl(url, config) {
|
|
14277
|
-
const
|
|
14331
|
+
const isPaused = this._player.paused && !this._player.isError;
|
|
14332
|
+
const {
|
|
14333
|
+
plugins: newPlugins,
|
|
14334
|
+
options,
|
|
14335
|
+
isSameProtocol,
|
|
14336
|
+
useSrc
|
|
14337
|
+
} = await this.prepare(url) || {};
|
|
14278
14338
|
const newUrl = (options == null ? void 0 : options.url) ?? url;
|
|
14279
14339
|
this._sourceManager.url = newUrl;
|
|
14280
|
-
|
|
14281
|
-
|
|
14282
|
-
} else {
|
|
14340
|
+
this._player.config.url = newUrl;
|
|
14341
|
+
if (isSameProtocol) {
|
|
14283
14342
|
const res = this._player.switchURL(newUrl, {
|
|
14284
14343
|
seamless: config == null ? void 0 : config.seamless
|
|
14285
14344
|
});
|
|
14286
|
-
const curTime = this._player.currentTime;
|
|
14287
14345
|
if (res && res.then) {
|
|
14288
14346
|
return res;
|
|
14289
|
-
} else {
|
|
14290
|
-
return new Promise((resolve) => {
|
|
14291
|
-
const isPaused = this._player.paused && !this._player.isError;
|
|
14292
|
-
const _canplay = () => {
|
|
14293
|
-
this._player.currentTime = curTime;
|
|
14294
|
-
if (isPaused) {
|
|
14295
|
-
this._player.once(CANPLAY, () => {
|
|
14296
|
-
this._player.pause();
|
|
14297
|
-
});
|
|
14298
|
-
}
|
|
14299
|
-
resolve();
|
|
14300
|
-
};
|
|
14301
|
-
if (sniffer.os.isAndroid) {
|
|
14302
|
-
this.once(TIME_UPDATE, () => {
|
|
14303
|
-
_canplay();
|
|
14304
|
-
});
|
|
14305
|
-
} else {
|
|
14306
|
-
this.once(CANPLAY, () => {
|
|
14307
|
-
_canplay();
|
|
14308
|
-
});
|
|
14309
|
-
}
|
|
14310
|
-
this._player.play();
|
|
14311
|
-
});
|
|
14312
14347
|
}
|
|
14348
|
+
} else {
|
|
14349
|
+
return this._switchDifferentProtocolUrl(
|
|
14350
|
+
newPlugins,
|
|
14351
|
+
newUrl,
|
|
14352
|
+
isPaused,
|
|
14353
|
+
useSrc
|
|
14354
|
+
);
|
|
14313
14355
|
}
|
|
14314
14356
|
}
|
|
14315
|
-
|
|
14316
|
-
_diffPlugins(previousPlugins, newPlugins) {
|
|
14317
|
-
const previousPluginNames = previousPlugins.map((item) => item.pluginName);
|
|
14318
|
-
const newPluginNames = newPlugins.map((item) => item.pluginName);
|
|
14319
|
-
const removedPlugins = previousPluginNames.filter(
|
|
14320
|
-
(name) => !newPluginNames.includes(name)
|
|
14321
|
-
);
|
|
14322
|
-
const addedPlugins = newPlugins.filter(
|
|
14323
|
-
(name) => !previousPluginNames.includes(name.pluginName)
|
|
14324
|
-
);
|
|
14325
|
-
return {
|
|
14326
|
-
removedPlugins,
|
|
14327
|
-
addedPlugins
|
|
14328
|
-
};
|
|
14329
|
-
}
|
|
14330
|
-
_callBeforePlayerInitForUrl(newPlugins, url) {
|
|
14357
|
+
_callBeforePlayerInitForUrl(newPlugins) {
|
|
14331
14358
|
return new Promise((resolve) => {
|
|
14332
|
-
this._player.config.url = url;
|
|
14333
14359
|
newPlugins == null ? void 0 : newPlugins.forEach((plugin) => {
|
|
14334
14360
|
plugin.beforePlayerInit();
|
|
14335
14361
|
});
|