pr-player 0.2.3 → 0.2.4
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 +29 -36
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# 对 flv 格式的地址进行解析 并输出
|
|
1
|
+
# 对 flv 格式的地址进行解析 并输出 MediaStream,提供 demuxer 层(info、chunk、sei)回调、 decoder 层(audio、video)回调 ,提供 cut 等相关能力,以支持根据业务层 SEI 对视频进行剪切渲染。
|
|
2
2
|
|
|
3
3
|
## 立即开始
|
|
4
4
|
|
|
@@ -13,31 +13,44 @@ npm i pr-player
|
|
|
13
13
|
```js
|
|
14
14
|
import { PrPlayer } from 'pr-player'
|
|
15
15
|
|
|
16
|
-
// 除此之外 如果你需要自定义扩展 为你提供了独立的 Demuxer、Decoder、Render
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
16
|
+
// 除此之外 如果你需要自定义扩展 为你提供了独立的 Demuxer、Decoder、Render
|
|
17
|
+
import { DemuxerWorker } from '../../src/index'
|
|
18
|
+
import { DecoderWorker } from '../../src/index'
|
|
19
|
+
import { RenderWorker } from '../../src/index'
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
## 快速使用
|
|
23
23
|
|
|
24
24
|
```js
|
|
25
25
|
const player = new PrPlayer()
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
const player = new PrPlayer({ debug: true })
|
|
27
|
+
|
|
28
|
+
// 如果你只需要复解器相关的能力 可以拿到复解后的所有回调
|
|
29
|
+
{
|
|
30
|
+
player.on.demuxer.info = (info) => {
|
|
31
|
+
console.log('\x1b[38;2;0;151;255m%c%s\x1b[0m', 'color:#0097ff;', `------->Breathe: info`, info)
|
|
32
|
+
}
|
|
33
|
+
player.on.demuxer.chunk = (chunk) => {
|
|
34
|
+
console.log('\x1b[38;2;0;151;255m%c%s\x1b[0m', 'color:#0097ff;', `------->Breathe: chunk`, chunk)
|
|
35
|
+
}
|
|
36
|
+
player.on.demuxer.sei = (sei) => {
|
|
37
|
+
console.log('\x1b[38;2;0;151;255m%c%s\x1b[0m', 'color:#0097ff;', `------->Breathe: sei`, sei)
|
|
34
38
|
}
|
|
39
|
+
}
|
|
35
40
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
// 如果你只需要解码器相关的能力 可以拿到解码后的所有回调
|
|
42
|
+
{
|
|
43
|
+
player.on.decoder.audio = (audio) => {
|
|
44
|
+
console.log('\x1b[38;2;0;151;255m%c%s\x1b[0m', 'color:#0097ff;', `------->Breathe: audio`, audio)
|
|
45
|
+
}
|
|
46
|
+
player.on.decoder.video = (video) => {
|
|
47
|
+
console.log('\x1b[38;2;0;151;255m%c%s\x1b[0m', 'color:#0097ff;', `------->Breathe: video`, video)
|
|
39
48
|
}
|
|
40
49
|
}
|
|
50
|
+
|
|
51
|
+
await player.start('https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/flv/xgplayer-demo-720p.flv')
|
|
52
|
+
player.setMute(false) // 默认都是静音 所以主动开启
|
|
53
|
+
const stream = player.getStream()
|
|
41
54
|
```
|
|
42
55
|
|
|
43
56
|
### 暂停渲染
|
|
@@ -46,14 +59,6 @@ const play = async () => {
|
|
|
46
59
|
player.setPause(true)
|
|
47
60
|
```
|
|
48
61
|
|
|
49
|
-
### 设置渲染模式
|
|
50
|
-
|
|
51
|
-
- 默认只开启 'stream' 如果需要同时使用 'canvas' 、'stream' 则需要手动设置
|
|
52
|
-
|
|
53
|
-
```js
|
|
54
|
-
player.setShader(['canvas', 'stream'])
|
|
55
|
-
```
|
|
56
|
-
|
|
57
62
|
### 停止
|
|
58
63
|
|
|
59
64
|
```js
|
|
@@ -68,10 +73,6 @@ player.stop()
|
|
|
68
73
|
|
|
69
74
|
```js
|
|
70
75
|
player.cut.create('cut-any-key', { sx: width * 0.25, sy: height * 0.4, sw: width * 0.5, sh: height * 0.5 })
|
|
71
|
-
|
|
72
|
-
const canvas = player.cut.getCanvas('cut-any-key')
|
|
73
|
-
|
|
74
|
-
// 渲染方式二
|
|
75
76
|
const stream = player.cut.getStream('cut-any-key')
|
|
76
77
|
```
|
|
77
78
|
|
|
@@ -81,14 +82,6 @@ const stream = player.cut.getStream('cut-any-key')
|
|
|
81
82
|
player.cut.setPause('cut-any-key', true)
|
|
82
83
|
```
|
|
83
84
|
|
|
84
|
-
### 设置渲染模式
|
|
85
|
-
|
|
86
|
-
- 默认只开启 'stream' 如果需要同时使用 'canvas' 、'stream' 则需要手动设置
|
|
87
|
-
|
|
88
|
-
```js
|
|
89
|
-
player.cut.setShader('cut-any-key', ['canvas', 'stream'])
|
|
90
|
-
```
|
|
91
|
-
|
|
92
85
|
### 移除剪切
|
|
93
86
|
|
|
94
87
|
```js
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pr-player",
|
|
3
|
-
"description": "对 flv 格式的地址进行解析 并输出
|
|
4
|
-
"version": "0.2.
|
|
3
|
+
"description": "对 flv 格式的地址进行解析 并输出 MediaStream,提供 demuxer 层(info、chunk、sei)回调、 decoder 层(audio、video)回调 ,提供 cut 等相关能力,以支持根据业务层 SEI 对视频进行剪切渲染。",
|
|
4
|
+
"version": "0.2.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|