xgplayer-mp3 3.0.27 → 3.0.28-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/README.md +13 -19
- package/README.zh-CN.md +4 -10
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/mp3.js +1 -1
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
English | [简体中文](./README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
`xgplayer-mp3` is an
|
|
6
|
-
|
|
7
|
-
for CBR and indexed VBR files. When the runtime or input is unsupported,
|
|
8
|
-
|
|
5
|
+
`xgplayer-mp3` is an MSE streaming plugin for xgplayer that loads standalone
|
|
6
|
+
MP3 files on demand. It uses HTTP Range requests and provides MSE-based seeking
|
|
7
|
+
for CBR and indexed VBR files. When the runtime or input is unsupported, it
|
|
8
|
+
falls back to native `<audio>` handling by default.
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
@@ -13,12 +13,6 @@ plugin falls back to native `<audio>` playback by default.
|
|
|
13
13
|
npm install xgplayer xgplayer-mp3
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
Or:
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
yarn add xgplayer xgplayer-mp3
|
|
20
|
-
```
|
|
21
|
-
|
|
22
16
|
## Basic usage
|
|
23
17
|
|
|
24
18
|
```html
|
|
@@ -56,12 +50,12 @@ Access-Control-Expose-Headers: Content-Range, Content-Length, Accept-Ranges
|
|
|
56
50
|
```
|
|
57
51
|
|
|
58
52
|
If the server ignores the Range header and returns the complete file with
|
|
59
|
-
`200`,
|
|
60
|
-
memory.
|
|
53
|
+
`200`, the file still loads, but the entire response is downloaded and retained
|
|
54
|
+
in memory.
|
|
61
55
|
|
|
62
56
|
For a `206` response, JavaScript must be able to read a `Content-Range` header
|
|
63
57
|
that contains the complete file size. Otherwise, the plugin falls back to
|
|
64
|
-
native
|
|
58
|
+
native audio handling.
|
|
65
59
|
|
|
66
60
|
## Configuration
|
|
67
61
|
|
|
@@ -92,7 +86,7 @@ Common options:
|
|
|
92
86
|
| `retryDelay` | `1000` | Delay between retries, in milliseconds |
|
|
93
87
|
| `timeout` | `5000` | Timeout for one network request, in milliseconds |
|
|
94
88
|
| `reqOptions` | `null` | Request options such as method, headers, and credentials |
|
|
95
|
-
| `closeDowngrade` | `false` | Disable fallback to native
|
|
89
|
+
| `closeDowngrade` | `false` | Disable fallback to native audio after a fatal plugin error |
|
|
96
90
|
|
|
97
91
|
Advanced options:
|
|
98
92
|
|
|
@@ -141,7 +135,7 @@ if (MP3Plugin.isSupported()) {
|
|
|
141
135
|
```
|
|
142
136
|
|
|
143
137
|
Manual detection is usually unnecessary. The plugin restores the original URL
|
|
144
|
-
and
|
|
138
|
+
and media state, then delegates to native `<audio>` when:
|
|
145
139
|
|
|
146
140
|
- The runtime does not support `audio/mpeg` MSE.
|
|
147
141
|
- The file is unsupported or has no reliable seek mapping.
|
|
@@ -176,10 +170,10 @@ families such as MPEG-4.
|
|
|
176
170
|
|
|
177
171
|
## How it works
|
|
178
172
|
|
|
179
|
-

|
|
180
174
|
|
|
181
175
|
The plugin probes ID3 data, MP3 frames, and Xing/Info/VBRI indexes. It then maps
|
|
182
|
-
|
|
176
|
+
media time to byte positions and loads frame-aligned data through HTTP Range
|
|
183
177
|
requests.
|
|
184
178
|
|
|
185
179
|
`xgplayer-mp3` follows the
|
|
@@ -197,5 +191,5 @@ Fatal errors are reported through the `playCatch` event:
|
|
|
197
191
|
| `MP3_1` | Before the first data append completes |
|
|
198
192
|
| `MP3_2` | After the first data append completes |
|
|
199
193
|
|
|
200
|
-
With the default configuration, the plugin proceeds with native
|
|
201
|
-
|
|
194
|
+
With the default configuration, the plugin proceeds with native fallback after
|
|
195
|
+
emitting the event.
|
package/README.zh-CN.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[English](./README.md) | 简体中文
|
|
4
4
|
|
|
5
|
-
`xgplayer-mp3`
|
|
6
|
-
Range
|
|
7
|
-
当运行环境或文件不满足要求时,默认交由浏览器原生 `<audio>`
|
|
5
|
+
`xgplayer-mp3` 是面向 xgplayer 的 MSE 流式插件,用于按需加载独立 MP3 文件。
|
|
6
|
+
它通过 HTTP Range 加载,并为 CBR 和带索引的 VBR 文件提供基于 MSE 的 seek 能力。
|
|
7
|
+
当运行环境或文件不满足要求时,默认交由浏览器原生 `<audio>` 处理。
|
|
8
8
|
|
|
9
9
|
## 安装
|
|
10
10
|
|
|
@@ -12,12 +12,6 @@ Range 按需加载,并为 CBR 和带索引的 VBR 文件提供基于 MSE 的 s
|
|
|
12
12
|
npm install xgplayer xgplayer-mp3
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
或者:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
yarn add xgplayer xgplayer-mp3
|
|
19
|
-
```
|
|
20
|
-
|
|
21
15
|
## 基础用法
|
|
22
16
|
|
|
23
17
|
```html
|
|
@@ -167,7 +161,7 @@ MPEG Audio Version 与 Layer 是两个独立维度:
|
|
|
167
161
|
|
|
168
162
|
## 工作原理
|
|
169
163
|
|
|
170
|
-

|
|
171
165
|
|
|
172
166
|
插件首先探测 ID3、MP3 帧和 Xing/Info/VBRI 索引,再将播放时间映射到文件字节
|
|
173
167
|
位置,通过 HTTP Range 加载帧对齐的数据。
|