@video-lab/player-core 4.1.0 → 4.1.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.
- package/dist/index.cjs +25 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +25 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -120,6 +120,27 @@ function detectEnv(input) {
|
|
|
120
120
|
requiresHls: isIOS || isWeChat || isUC || isQuark || !input.hasMediaSource
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
+
/** flv.js `isSupported()` 用的同一句基线:连它都报不支持,hls.js / flv.js 都不会开始播放 */
|
|
124
|
+
const MSE_BASELINE_TYPE = "video/mp4; codecs=\"avc1.42E01E,mp4a.40.2\"";
|
|
125
|
+
/**
|
|
126
|
+
* 标准 MSE 是否**可用**,而不只是存在(ADR-135)。
|
|
127
|
+
*
|
|
128
|
+
* 小米浏览器(MiuiBrowser 20.28)暴露了 `MediaSource`,但 `isTypeSupported` 对所有
|
|
129
|
+
* H.264/AAC 组合都回 false —— 实际 `addSourceBuffer` 能成功,是它报错了能力。
|
|
130
|
+
* hls.js 信了前者,对声明了 CODECS 的主清单报 `manifestIncompatibleCodecsError`(不可重试)。
|
|
131
|
+
* 按基线判为不可用后,SourceRouter 走原生 HLS,而该浏览器原生 HLS 播放、拖动都正常。
|
|
132
|
+
*
|
|
133
|
+
* 没有 `isTypeSupported` 的实现仍按「存在即可用」,只收紧「明确报不支持」这一种情况。
|
|
134
|
+
*/
|
|
135
|
+
function hasUsableMediaSource(mediaSource) {
|
|
136
|
+
if (typeof mediaSource === "undefined") return false;
|
|
137
|
+
if (typeof mediaSource.isTypeSupported !== "function") return true;
|
|
138
|
+
try {
|
|
139
|
+
return mediaSource.isTypeSupported(MSE_BASELINE_TYPE);
|
|
140
|
+
} catch {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
123
144
|
/**
|
|
124
145
|
* 从当前浏览器读环境。SSR 场景(没有 window / navigator)返回一个保守的默认值:
|
|
125
146
|
* 当作没有 MSE,于是强制走 HLS —— 宁可保守也不要在服务端渲染时误判成能播 FLV。
|
|
@@ -132,7 +153,7 @@ function detectEnvFromGlobals() {
|
|
|
132
153
|
});
|
|
133
154
|
return detectEnv({
|
|
134
155
|
userAgent: navigator.userAgent,
|
|
135
|
-
hasMediaSource:
|
|
156
|
+
hasMediaSource: hasUsableMediaSource(window.MediaSource),
|
|
136
157
|
hasManagedMediaSource: typeof window.ManagedMediaSource !== "undefined"
|
|
137
158
|
});
|
|
138
159
|
}
|
|
@@ -4199,6 +4220,9 @@ function buildXgplayerConfig(options, routed, normalized, emit, env, playableSta
|
|
|
4199
4220
|
const lowLatencyMode = normalized.hls?.lowLatencyMode === true;
|
|
4200
4221
|
return {
|
|
4201
4222
|
el: options.el,
|
|
4223
|
+
...options.fullscreenTarget ? { fullscreenTarget: options.fullscreenTarget } : {},
|
|
4224
|
+
width: "100%",
|
|
4225
|
+
height: "100%",
|
|
4202
4226
|
url: routed.chosen.url,
|
|
4203
4227
|
isLive: live,
|
|
4204
4228
|
ignores: [
|
package/dist/index.d.cts
CHANGED
|
@@ -78,6 +78,12 @@ declare function detectEnvFromGlobals(): Env;
|
|
|
78
78
|
interface CreatePlayerOptions {
|
|
79
79
|
/** 挂载容器 */
|
|
80
80
|
el: HTMLElement;
|
|
81
|
+
/**
|
|
82
|
+
* 原生全屏目标(ADR-133)。装配层传入同时包含播放器与 SDK 覆盖层的外层容器,
|
|
83
|
+
* 覆盖层才会进入 `document.fullscreenElement` 子树、在全屏期间可见。
|
|
84
|
+
* 不传时沿用 xgplayer 默认(播放器根元素)。内部装配参数,不属于 `PlayerConfig`。
|
|
85
|
+
*/
|
|
86
|
+
fullscreenTarget?: HTMLElement;
|
|
81
87
|
/** 宿主网页全屏布局;不经可序列化配置传递。 */
|
|
82
88
|
pageFullscreen?: PageFullscreenAdapter;
|
|
83
89
|
/** iframe 内部使用:等待宿主协商后开放入口。 */
|
package/dist/index.d.mts
CHANGED
|
@@ -78,6 +78,12 @@ declare function detectEnvFromGlobals(): Env;
|
|
|
78
78
|
interface CreatePlayerOptions {
|
|
79
79
|
/** 挂载容器 */
|
|
80
80
|
el: HTMLElement;
|
|
81
|
+
/**
|
|
82
|
+
* 原生全屏目标(ADR-133)。装配层传入同时包含播放器与 SDK 覆盖层的外层容器,
|
|
83
|
+
* 覆盖层才会进入 `document.fullscreenElement` 子树、在全屏期间可见。
|
|
84
|
+
* 不传时沿用 xgplayer 默认(播放器根元素)。内部装配参数,不属于 `PlayerConfig`。
|
|
85
|
+
*/
|
|
86
|
+
fullscreenTarget?: HTMLElement;
|
|
81
87
|
/** 宿主网页全屏布局;不经可序列化配置传递。 */
|
|
82
88
|
pageFullscreen?: PageFullscreenAdapter;
|
|
83
89
|
/** iframe 内部使用:等待宿主协商后开放入口。 */
|
package/dist/index.mjs
CHANGED
|
@@ -94,6 +94,27 @@ function detectEnv(input) {
|
|
|
94
94
|
requiresHls: isIOS || isWeChat || isUC || isQuark || !input.hasMediaSource
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
+
/** flv.js `isSupported()` 用的同一句基线:连它都报不支持,hls.js / flv.js 都不会开始播放 */
|
|
98
|
+
const MSE_BASELINE_TYPE = "video/mp4; codecs=\"avc1.42E01E,mp4a.40.2\"";
|
|
99
|
+
/**
|
|
100
|
+
* 标准 MSE 是否**可用**,而不只是存在(ADR-135)。
|
|
101
|
+
*
|
|
102
|
+
* 小米浏览器(MiuiBrowser 20.28)暴露了 `MediaSource`,但 `isTypeSupported` 对所有
|
|
103
|
+
* H.264/AAC 组合都回 false —— 实际 `addSourceBuffer` 能成功,是它报错了能力。
|
|
104
|
+
* hls.js 信了前者,对声明了 CODECS 的主清单报 `manifestIncompatibleCodecsError`(不可重试)。
|
|
105
|
+
* 按基线判为不可用后,SourceRouter 走原生 HLS,而该浏览器原生 HLS 播放、拖动都正常。
|
|
106
|
+
*
|
|
107
|
+
* 没有 `isTypeSupported` 的实现仍按「存在即可用」,只收紧「明确报不支持」这一种情况。
|
|
108
|
+
*/
|
|
109
|
+
function hasUsableMediaSource(mediaSource) {
|
|
110
|
+
if (typeof mediaSource === "undefined") return false;
|
|
111
|
+
if (typeof mediaSource.isTypeSupported !== "function") return true;
|
|
112
|
+
try {
|
|
113
|
+
return mediaSource.isTypeSupported(MSE_BASELINE_TYPE);
|
|
114
|
+
} catch {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
97
118
|
/**
|
|
98
119
|
* 从当前浏览器读环境。SSR 场景(没有 window / navigator)返回一个保守的默认值:
|
|
99
120
|
* 当作没有 MSE,于是强制走 HLS —— 宁可保守也不要在服务端渲染时误判成能播 FLV。
|
|
@@ -106,7 +127,7 @@ function detectEnvFromGlobals() {
|
|
|
106
127
|
});
|
|
107
128
|
return detectEnv({
|
|
108
129
|
userAgent: navigator.userAgent,
|
|
109
|
-
hasMediaSource:
|
|
130
|
+
hasMediaSource: hasUsableMediaSource(window.MediaSource),
|
|
110
131
|
hasManagedMediaSource: typeof window.ManagedMediaSource !== "undefined"
|
|
111
132
|
});
|
|
112
133
|
}
|
|
@@ -4173,6 +4194,9 @@ function buildXgplayerConfig(options, routed, normalized, emit, env, playableSta
|
|
|
4173
4194
|
const lowLatencyMode = normalized.hls?.lowLatencyMode === true;
|
|
4174
4195
|
return {
|
|
4175
4196
|
el: options.el,
|
|
4197
|
+
...options.fullscreenTarget ? { fullscreenTarget: options.fullscreenTarget } : {},
|
|
4198
|
+
width: "100%",
|
|
4199
|
+
height: "100%",
|
|
4176
4200
|
url: routed.chosen.url,
|
|
4177
4201
|
isLive: live,
|
|
4178
4202
|
ignores: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@video-lab/player-core",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"sideEffects": false,
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"xgplayer": "3.0.26",
|
|
34
|
-
"hls.js": "1.6.
|
|
34
|
+
"hls.js": "1.6.19",
|
|
35
35
|
"xgplayer-flv.js": "3.0.26",
|
|
36
|
-
"@video-lab/protocol": "4.1.
|
|
36
|
+
"@video-lab/protocol": "4.1.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"jsdom": "^24.0.0",
|