@linker-design-plus/mpegtsplayer 1.0.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/LICENSE +21 -0
- package/README.en-US.md +228 -0
- package/README.md +227 -0
- package/dist/MpegtsPlayer.d.ts +156 -0
- package/dist/MpegtsPlayer.d.ts.map +1 -0
- package/dist/index.d.ts +374 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/style.css +1 -0
- package/package.json +48 -0
- package/src/MpegtsPlayer.less +23 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Linker Design Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en-US.md
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# @linker-design-plus/mpegtsplayer
|
|
2
|
+
|
|
3
|
+
A Vue 3 video player component based on mpegts.js for playing FLV streams with enhanced features and controls.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🎥 **FLV Stream Support**: Play FLV video streams using mpegts.js
|
|
8
|
+
- 🔄 **Auto Reload**: Automatically reload video stream on connection loss
|
|
9
|
+
- 👁️ **Visibility Handling**: Handle tab visibility changes with automatic refresh
|
|
10
|
+
- ⚙️ **Custom Controls**: Toggle native video controls on/off
|
|
11
|
+
- 📡 **Live Streaming**: Optimized for live streaming with low latency
|
|
12
|
+
- 🎯 **Error Handling**: Comprehensive error handling and event reporting
|
|
13
|
+
- 📱 **Responsive**: Adapts to container size changes
|
|
14
|
+
- 🎨 **Styled Components**: Built-in loading indicator and clean UI
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Using pnpm (recommended)
|
|
20
|
+
pnpm add @linker-design-plus/mpegtsplayer
|
|
21
|
+
|
|
22
|
+
# Using npm
|
|
23
|
+
npm install @linker-design-plus/mpegtsplayer
|
|
24
|
+
|
|
25
|
+
# Using yarn
|
|
26
|
+
yarn add @linker-design-plus/mpegtsplayer
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### Import Component
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
// In your main.js or entry point
|
|
35
|
+
import { createApp } from 'vue';
|
|
36
|
+
import MpegtsPlayer from '@linker-design-plus/mpegtsplayer';
|
|
37
|
+
import '@linker-design-plus/mpegtsplayer/dist/style.css';
|
|
38
|
+
|
|
39
|
+
const app = createApp(App);
|
|
40
|
+
app.component('MpegtsPlayer', MpegtsPlayer);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Or use it locally in your component:
|
|
44
|
+
|
|
45
|
+
```vue
|
|
46
|
+
<script setup>
|
|
47
|
+
import MpegtsPlayer from '@linker-design-plus/mpegtsplayer';
|
|
48
|
+
import '@linker-design-plus/mpegtsplayer/dist/style.css';
|
|
49
|
+
</script>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Basic Usage
|
|
53
|
+
|
|
54
|
+
```vue
|
|
55
|
+
<template>
|
|
56
|
+
<div style="width: 800px; height: 450px;">
|
|
57
|
+
<MpegtsPlayer
|
|
58
|
+
video-url="http://example.com/stream.flv"
|
|
59
|
+
:is-live="true"
|
|
60
|
+
:controls="true"
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Live Stream Configuration
|
|
67
|
+
|
|
68
|
+
```vue
|
|
69
|
+
<template>
|
|
70
|
+
<div style="width: 100%; height: 100%;">
|
|
71
|
+
<MpegtsPlayer
|
|
72
|
+
video-url="http://example.com/live-stream.flv"
|
|
73
|
+
:is-live="true"
|
|
74
|
+
:auto-reload="true"
|
|
75
|
+
:auto-visibility-change-refresh="true"
|
|
76
|
+
:close-visibility-change-listener="false"
|
|
77
|
+
:controls="true"
|
|
78
|
+
/>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### VOD Configuration
|
|
84
|
+
|
|
85
|
+
```vue
|
|
86
|
+
<template>
|
|
87
|
+
<div style="width: 800px; height: 450px;">
|
|
88
|
+
<MpegtsPlayer
|
|
89
|
+
video-url="http://example.com/video.flv"
|
|
90
|
+
:is-live="false"
|
|
91
|
+
:controls="true"
|
|
92
|
+
:current-time="0"
|
|
93
|
+
/>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## API
|
|
99
|
+
|
|
100
|
+
### Props
|
|
101
|
+
|
|
102
|
+
| Prop | Description | Type | Default |
|
|
103
|
+
|------|-------------|------|---------|
|
|
104
|
+
| videoUrl | Video stream URL | string | "" |
|
|
105
|
+
| closeVisibilityChangeListener | Close visibility change listener | boolean | false |
|
|
106
|
+
| autoVisibilityChangeRefresh | Auto refresh on visibility change | boolean | false |
|
|
107
|
+
| autoReload | Auto reload on error | boolean | false |
|
|
108
|
+
| isLive | Is live stream | boolean | true |
|
|
109
|
+
| controls | Show native controls | boolean | false |
|
|
110
|
+
| currentTime | Current playback time | number | 0 |
|
|
111
|
+
|
|
112
|
+
### Events
|
|
113
|
+
|
|
114
|
+
| Event | Description | Callback Parameters |
|
|
115
|
+
|-------|-------------|-------------------|
|
|
116
|
+
| loadError | Load error | errorInfo: any |
|
|
117
|
+
| playSuccess | Play success | - |
|
|
118
|
+
| loadComplete | Load complete | - |
|
|
119
|
+
| visibilitychange | Visibility change | visibilityState: string |
|
|
120
|
+
| timeupdate | Time update | time: number |
|
|
121
|
+
| playEnded | Play ended | - |
|
|
122
|
+
| playLoading | Play loading | - |
|
|
123
|
+
|
|
124
|
+
### Methods (Exposed via ref)
|
|
125
|
+
|
|
126
|
+
| Method | Description | Parameters |
|
|
127
|
+
|--------|-------------|------------|
|
|
128
|
+
| start() | Start playback | - |
|
|
129
|
+
| pause() | Pause playback | - |
|
|
130
|
+
| destroy() | Destroy player | - |
|
|
131
|
+
| reload() | Reload player | - |
|
|
132
|
+
|
|
133
|
+
### Accessing Methods Example
|
|
134
|
+
|
|
135
|
+
```vue
|
|
136
|
+
<template>
|
|
137
|
+
<div>
|
|
138
|
+
<MpegtsPlayer
|
|
139
|
+
ref="playerRef"
|
|
140
|
+
video-url="http://example.com/stream.flv"
|
|
141
|
+
:is-live="true"
|
|
142
|
+
/>
|
|
143
|
+
<button @click="play">Play</button>
|
|
144
|
+
<button @click="pause">Pause</button>
|
|
145
|
+
<button @click="reload">Reload</button>
|
|
146
|
+
</div>
|
|
147
|
+
</template>
|
|
148
|
+
|
|
149
|
+
<script setup>
|
|
150
|
+
import { ref } from 'vue';
|
|
151
|
+
import MpegtsPlayer from '@linker-design-plus/mpegtsplayer';
|
|
152
|
+
|
|
153
|
+
const playerRef = ref(null);
|
|
154
|
+
|
|
155
|
+
const play = () => {
|
|
156
|
+
playerRef.value.start();
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const pause = () => {
|
|
160
|
+
playerRef.value.pause();
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const reload = () => {
|
|
164
|
+
playerRef.value.reload();
|
|
165
|
+
};
|
|
166
|
+
</script>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Feature Descriptions
|
|
170
|
+
|
|
171
|
+
### Auto Reconnect
|
|
172
|
+
When `autoReload` is enabled, the player will automatically attempt to reconnect to the stream if the connection is lost, trying up to 2 times before emitting an error.
|
|
173
|
+
|
|
174
|
+
### Visibility Handling
|
|
175
|
+
The player can automatically reload when the browser tab becomes visible again after being hidden, controlled by the `autoVisibilityChangeRefresh` prop.
|
|
176
|
+
|
|
177
|
+
### Controls Customization
|
|
178
|
+
The native video controls can be toggled on/off using the `controls` prop. When disabled, custom controls can be implemented using the exposed methods.
|
|
179
|
+
|
|
180
|
+
### Live Stream Optimization
|
|
181
|
+
Optimized settings for live streaming including:
|
|
182
|
+
- Disabled stash buffer for lower latency
|
|
183
|
+
- Disabled lazy loading for continuous streaming
|
|
184
|
+
- Enabled live buffer latency chasing for smooth playback
|
|
185
|
+
|
|
186
|
+
## Style Customization
|
|
187
|
+
|
|
188
|
+
The component includes built-in styling. You can override the default styles by targeting these classes:
|
|
189
|
+
|
|
190
|
+
```css
|
|
191
|
+
.mainContainer {
|
|
192
|
+
/* Container styles */
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.video-container {
|
|
196
|
+
/* Video element styles */
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.meta-data-loading {
|
|
200
|
+
/* Loading spinner styles */
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.no-control {
|
|
204
|
+
/* Class applied when controls are disabled */
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Dependencies
|
|
209
|
+
|
|
210
|
+
- Vue 3.1.0+
|
|
211
|
+
- mpegts.js 1.7.3
|
|
212
|
+
- @arco-design/web-vue 2.56.3
|
|
213
|
+
|
|
214
|
+
## Browser Compatibility
|
|
215
|
+
|
|
216
|
+
- Modern browsers supporting ES2015+
|
|
217
|
+
- Media Source Extensions (MSE) support required for FLV playback
|
|
218
|
+
|
|
219
|
+
## Notes
|
|
220
|
+
|
|
221
|
+
1. For production use, ensure your video stream URL supports CORS
|
|
222
|
+
2. The player is optimized for FLV streams; other formats may not work correctly
|
|
223
|
+
3. For live streaming, latency optimizations are enabled by default
|
|
224
|
+
4. Memory is automatically managed through proper destroy lifecycle
|
|
225
|
+
|
|
226
|
+
## License
|
|
227
|
+
|
|
228
|
+
MIT
|
package/README.md
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# @linker-design-plus/mpegtsplayer
|
|
2
|
+
|
|
3
|
+
一个基于 mpegts.js 的 Vue 3 视频播放器组件,用于播放 FLV 流媒体,具有增强的功能和控件。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- 🎥 **FLV 流媒体支持**:使用 mpegts.js 播放 FLV 视频流
|
|
8
|
+
- 🔄 **自动重载**:连接丢失时自动重新加载视频流
|
|
9
|
+
- 👁️ **可见性处理**:处理标签页可见性变化并自动刷新
|
|
10
|
+
- ⚙️ **自定义控件**:切换原生视频控件的显示/隐藏
|
|
11
|
+
- 📡 **直播流优化**:针对直播流进行了低延迟优化
|
|
12
|
+
- 🎯 **错误处理**:全面的错误处理和事件报告
|
|
13
|
+
- 📱 **响应式设计**:适应容器尺寸变化
|
|
14
|
+
- 🎨 **样式化组件**:内置加载指示器和简洁的界面
|
|
15
|
+
|
|
16
|
+
## 安装
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# 推荐使用 pnpm
|
|
20
|
+
pnpm add @linker-design-plus/mpegtsplayer
|
|
21
|
+
|
|
22
|
+
# 使用 npm
|
|
23
|
+
npm install @linker-design-plus/mpegtsplayer
|
|
24
|
+
|
|
25
|
+
# 使用 yarn
|
|
26
|
+
yarn add @linker-design-plus/mpegtsplayer
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 使用方法
|
|
30
|
+
|
|
31
|
+
### 引入组件
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
// 在 main.js 或入口文件中
|
|
35
|
+
import { createApp } from 'vue';
|
|
36
|
+
import MpegtsPlayer from '@linker-design-plus/mpegtsplayer';
|
|
37
|
+
|
|
38
|
+
const app = createApp(App);
|
|
39
|
+
app.component('MpegtsPlayer', MpegtsPlayer);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
或者在组件中局部使用:
|
|
43
|
+
|
|
44
|
+
```vue
|
|
45
|
+
<script setup>
|
|
46
|
+
import MpegtsPlayer from '@linker-design-plus/mpegtsplayer';
|
|
47
|
+
</script>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 基础用法
|
|
51
|
+
|
|
52
|
+
```vue
|
|
53
|
+
<template>
|
|
54
|
+
<div style="width: 800px; height: 450px;">
|
|
55
|
+
<MpegtsPlayer
|
|
56
|
+
video-url="http://example.com/stream.flv"
|
|
57
|
+
:is-live="true"
|
|
58
|
+
:controls="true"
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 直播流配置
|
|
65
|
+
|
|
66
|
+
```vue
|
|
67
|
+
<template>
|
|
68
|
+
<div style="width: 100%; height: 100%;">
|
|
69
|
+
<MpegtsPlayer
|
|
70
|
+
video-url="http://example.com/live-stream.flv"
|
|
71
|
+
:is-live="true"
|
|
72
|
+
:auto-reload="true"
|
|
73
|
+
:auto-visibility-change-refresh="true"
|
|
74
|
+
:close-visibility-change-listener="false"
|
|
75
|
+
:controls="true"
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 点播视频配置
|
|
82
|
+
|
|
83
|
+
```vue
|
|
84
|
+
<template>
|
|
85
|
+
<div style="width: 800px; height: 450px;">
|
|
86
|
+
<MpegtsPlayer
|
|
87
|
+
video-url="http://example.com/video.flv"
|
|
88
|
+
:is-live="false"
|
|
89
|
+
:controls="true"
|
|
90
|
+
:current-time="0"
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## API
|
|
97
|
+
|
|
98
|
+
### Props
|
|
99
|
+
|
|
100
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
101
|
+
|------|------|------|--------|
|
|
102
|
+
| videoUrl | 视频流 URL | string | "" |
|
|
103
|
+
| closeVisibilityChangeListener | 关闭可见性变化监听器 | boolean | false |
|
|
104
|
+
| autoVisibilityChangeRefresh | 可见性变化时自动刷新 | boolean | false |
|
|
105
|
+
| autoReload | 错误时自动重载 | boolean | false |
|
|
106
|
+
| isLive | 是否为直播流 | boolean | true |
|
|
107
|
+
| controls | 显示原生控件 | boolean | false |
|
|
108
|
+
| currentTime | 当前播放时间 | number | 0 |
|
|
109
|
+
| stallTimeout | 卡顿检测超时时间(毫秒) | number | 5000 |
|
|
110
|
+
|
|
111
|
+
### Events
|
|
112
|
+
|
|
113
|
+
| 事件 | 说明 | 回调参数 |
|
|
114
|
+
|------|------|----------|
|
|
115
|
+
| loadError | 加载错误 | errorInfo: any |
|
|
116
|
+
| playSuccess | 播放成功 | - |
|
|
117
|
+
| loadComplete | 加载完成 | - |
|
|
118
|
+
| visibilitychange | 可见性变化 | visibilityState: string |
|
|
119
|
+
| timeupdate | 时间更新 | time: number |
|
|
120
|
+
| playEnded | 播放结束 | - |
|
|
121
|
+
| playLoading | 播放加载中 | - |
|
|
122
|
+
|
|
123
|
+
### 方法 (通过 ref 暴露)
|
|
124
|
+
|
|
125
|
+
| 方法 | 说明 | 参数 |
|
|
126
|
+
|------|------|------|
|
|
127
|
+
| start() | 开始播放 | - |
|
|
128
|
+
| pause() | 暂停播放 | - |
|
|
129
|
+
| destroy() | 销毁播放器 | - |
|
|
130
|
+
| reload() | 重新加载播放器 | - |
|
|
131
|
+
|
|
132
|
+
### 访问方法示例
|
|
133
|
+
|
|
134
|
+
```vue
|
|
135
|
+
<template>
|
|
136
|
+
<div>
|
|
137
|
+
<MpegtsPlayer
|
|
138
|
+
ref="playerRef"
|
|
139
|
+
video-url="http://example.com/stream.flv"
|
|
140
|
+
:is-live="true"
|
|
141
|
+
/>
|
|
142
|
+
<button @click="play">播放</button>
|
|
143
|
+
<button @click="pause">暂停</button>
|
|
144
|
+
<button @click="reload">重新加载</button>
|
|
145
|
+
</div>
|
|
146
|
+
</template>
|
|
147
|
+
|
|
148
|
+
<script setup>
|
|
149
|
+
import { ref } from 'vue';
|
|
150
|
+
import MpegtsPlayer from '@linker-design-plus/mpegtsplayer';
|
|
151
|
+
|
|
152
|
+
const playerRef = ref(null);
|
|
153
|
+
|
|
154
|
+
const play = () => {
|
|
155
|
+
playerRef.value.start();
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const pause = () => {
|
|
159
|
+
playerRef.value.pause();
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const reload = () => {
|
|
163
|
+
playerRef.value.reload();
|
|
164
|
+
};
|
|
165
|
+
</script>
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## 功能描述
|
|
169
|
+
|
|
170
|
+
### 自动重连
|
|
171
|
+
当启用 `autoReload` 时,如果连接丢失,播放器将自动尝试重新连接到流媒体,最多尝试 2 次后发出错误事件。
|
|
172
|
+
|
|
173
|
+
### 可见性处理
|
|
174
|
+
当浏览器标签页在隐藏后重新可见时,播放器可以自动重新加载,由 `autoVisibilityChangeRefresh` 属性控制。
|
|
175
|
+
|
|
176
|
+
### 控件自定义
|
|
177
|
+
可以使用 `controls` 属性切换原生视频控件的显示/隐藏。禁用时,可以使用暴露的方法实现自定义控件。
|
|
178
|
+
|
|
179
|
+
### 直播流优化
|
|
180
|
+
针对直播流的优化设置包括:
|
|
181
|
+
- 禁用 stash 缓冲区以降低延迟
|
|
182
|
+
- 禁用懒加载以实现连续流媒体播放
|
|
183
|
+
- 启用实时缓冲区延迟追踪以实现流畅播放
|
|
184
|
+
|
|
185
|
+
## 样式自定义
|
|
186
|
+
|
|
187
|
+
组件包含内置样式。您可以通过以下类名覆盖默认样式:
|
|
188
|
+
|
|
189
|
+
```css
|
|
190
|
+
.mainContainer {
|
|
191
|
+
/* 容器样式 */
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.video-container {
|
|
195
|
+
/* 视频元素样式 */
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.meta-data-loading {
|
|
199
|
+
/* 加载旋转图标样式 */
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.no-control {
|
|
203
|
+
/* 控件禁用时应用的类 */
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## 依赖
|
|
208
|
+
|
|
209
|
+
- Vue 3.1.0+
|
|
210
|
+
- mpegts.js 1.7.3
|
|
211
|
+
- @arco-design/web-vue 2.56.3
|
|
212
|
+
|
|
213
|
+
## 浏览器兼容性
|
|
214
|
+
|
|
215
|
+
- 支持 ES2015+ 的现代浏览器
|
|
216
|
+
- FLV 播放需要支持媒体源扩展 (MSE)
|
|
217
|
+
|
|
218
|
+
## 注意事项
|
|
219
|
+
|
|
220
|
+
1. 生产环境中,请确保您的视频流 URL 支持 CORS
|
|
221
|
+
2. 播放器针对 FLV 流进行了优化;其他格式可能无法正常工作
|
|
222
|
+
3. 对于直播流,默认启用了延迟优化
|
|
223
|
+
4. 通过适当的销毁生命周期自动管理内存
|
|
224
|
+
|
|
225
|
+
## 许可证
|
|
226
|
+
|
|
227
|
+
MIT
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { Player } from 'mpegts.js';
|
|
2
|
+
import './MpegtsPlayer.less';
|
|
3
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
videoUrl: {
|
|
5
|
+
type: StringConstructor;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
closeVisibilityChangeListener: {
|
|
9
|
+
type: BooleanConstructor;
|
|
10
|
+
default: boolean;
|
|
11
|
+
};
|
|
12
|
+
autoVisibilityChangeRefresh: {
|
|
13
|
+
type: BooleanConstructor;
|
|
14
|
+
default: boolean;
|
|
15
|
+
};
|
|
16
|
+
autoReload: {
|
|
17
|
+
type: BooleanConstructor;
|
|
18
|
+
default: boolean;
|
|
19
|
+
};
|
|
20
|
+
isLive: {
|
|
21
|
+
type: BooleanConstructor;
|
|
22
|
+
default: boolean;
|
|
23
|
+
};
|
|
24
|
+
controls: {
|
|
25
|
+
type: BooleanConstructor;
|
|
26
|
+
default: boolean;
|
|
27
|
+
};
|
|
28
|
+
currentTime: {
|
|
29
|
+
type: NumberConstructor;
|
|
30
|
+
default: number;
|
|
31
|
+
};
|
|
32
|
+
stallTimeout: {
|
|
33
|
+
type: NumberConstructor;
|
|
34
|
+
default: number;
|
|
35
|
+
};
|
|
36
|
+
}>, {
|
|
37
|
+
flvPlayer: import("vue").Ref<{
|
|
38
|
+
destroy: () => void;
|
|
39
|
+
on: (event: string, listener: (...args: any[]) => void) => void;
|
|
40
|
+
off: (event: string, listener: (...args: any[]) => void) => void;
|
|
41
|
+
attachMediaElement: (mediaElement: HTMLMediaElement) => void;
|
|
42
|
+
detachMediaElement: () => void;
|
|
43
|
+
load: () => void;
|
|
44
|
+
unload: () => void;
|
|
45
|
+
play: () => Promise<void>;
|
|
46
|
+
pause: () => void;
|
|
47
|
+
type: string;
|
|
48
|
+
buffered: {
|
|
49
|
+
readonly length: number;
|
|
50
|
+
end: (index: number) => number;
|
|
51
|
+
start: (index: number) => number;
|
|
52
|
+
};
|
|
53
|
+
duration: number;
|
|
54
|
+
volume: number;
|
|
55
|
+
muted: boolean;
|
|
56
|
+
currentTime: number;
|
|
57
|
+
playbackRate: number;
|
|
58
|
+
readyState: number;
|
|
59
|
+
seeking: boolean;
|
|
60
|
+
paused: boolean;
|
|
61
|
+
ended: boolean;
|
|
62
|
+
networkState: number;
|
|
63
|
+
videoWidth: number;
|
|
64
|
+
videoHeight: number;
|
|
65
|
+
} | null, Player | {
|
|
66
|
+
destroy: () => void;
|
|
67
|
+
on: (event: string, listener: (...args: any[]) => void) => void;
|
|
68
|
+
off: (event: string, listener: (...args: any[]) => void) => void;
|
|
69
|
+
attachMediaElement: (mediaElement: HTMLMediaElement) => void;
|
|
70
|
+
detachMediaElement: () => void;
|
|
71
|
+
load: () => void;
|
|
72
|
+
unload: () => void;
|
|
73
|
+
play: () => Promise<void>;
|
|
74
|
+
pause: () => void;
|
|
75
|
+
type: string;
|
|
76
|
+
buffered: {
|
|
77
|
+
readonly length: number;
|
|
78
|
+
end: (index: number) => number;
|
|
79
|
+
start: (index: number) => number;
|
|
80
|
+
};
|
|
81
|
+
duration: number;
|
|
82
|
+
volume: number;
|
|
83
|
+
muted: boolean;
|
|
84
|
+
currentTime: number;
|
|
85
|
+
playbackRate: number;
|
|
86
|
+
readyState: number;
|
|
87
|
+
seeking: boolean;
|
|
88
|
+
paused: boolean;
|
|
89
|
+
ended: boolean;
|
|
90
|
+
networkState: number;
|
|
91
|
+
videoWidth: number;
|
|
92
|
+
videoHeight: number;
|
|
93
|
+
} | null>;
|
|
94
|
+
videoContainerRef: import("vue").Ref<HTMLVideoElement | null, HTMLVideoElement | null>;
|
|
95
|
+
loadMetaData: import("vue").Ref<boolean, boolean>;
|
|
96
|
+
start: () => Promise<void>;
|
|
97
|
+
pause: () => void;
|
|
98
|
+
destroy: () => void;
|
|
99
|
+
reload: () => void;
|
|
100
|
+
handleCanplay: (e: any) => Promise<void>;
|
|
101
|
+
handleLoadedmetadata: () => void;
|
|
102
|
+
handleTimeupdate: (e: any) => void;
|
|
103
|
+
handlePlayEnded: () => void;
|
|
104
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("loadError" | "playSuccess" | "loadComplete" | "visibilitychange" | "timeupdate" | "playEnded" | "playLoading")[], "loadError" | "playSuccess" | "loadComplete" | "visibilitychange" | "timeupdate" | "playEnded" | "playLoading", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
105
|
+
videoUrl: {
|
|
106
|
+
type: StringConstructor;
|
|
107
|
+
default: string;
|
|
108
|
+
};
|
|
109
|
+
closeVisibilityChangeListener: {
|
|
110
|
+
type: BooleanConstructor;
|
|
111
|
+
default: boolean;
|
|
112
|
+
};
|
|
113
|
+
autoVisibilityChangeRefresh: {
|
|
114
|
+
type: BooleanConstructor;
|
|
115
|
+
default: boolean;
|
|
116
|
+
};
|
|
117
|
+
autoReload: {
|
|
118
|
+
type: BooleanConstructor;
|
|
119
|
+
default: boolean;
|
|
120
|
+
};
|
|
121
|
+
isLive: {
|
|
122
|
+
type: BooleanConstructor;
|
|
123
|
+
default: boolean;
|
|
124
|
+
};
|
|
125
|
+
controls: {
|
|
126
|
+
type: BooleanConstructor;
|
|
127
|
+
default: boolean;
|
|
128
|
+
};
|
|
129
|
+
currentTime: {
|
|
130
|
+
type: NumberConstructor;
|
|
131
|
+
default: number;
|
|
132
|
+
};
|
|
133
|
+
stallTimeout: {
|
|
134
|
+
type: NumberConstructor;
|
|
135
|
+
default: number;
|
|
136
|
+
};
|
|
137
|
+
}>> & Readonly<{
|
|
138
|
+
onLoadError?: ((...args: any[]) => any) | undefined;
|
|
139
|
+
onPlaySuccess?: ((...args: any[]) => any) | undefined;
|
|
140
|
+
onLoadComplete?: ((...args: any[]) => any) | undefined;
|
|
141
|
+
onVisibilitychange?: ((...args: any[]) => any) | undefined;
|
|
142
|
+
onTimeupdate?: ((...args: any[]) => any) | undefined;
|
|
143
|
+
onPlayEnded?: ((...args: any[]) => any) | undefined;
|
|
144
|
+
onPlayLoading?: ((...args: any[]) => any) | undefined;
|
|
145
|
+
}>, {
|
|
146
|
+
videoUrl: string;
|
|
147
|
+
closeVisibilityChangeListener: boolean;
|
|
148
|
+
autoVisibilityChangeRefresh: boolean;
|
|
149
|
+
autoReload: boolean;
|
|
150
|
+
isLive: boolean;
|
|
151
|
+
controls: boolean;
|
|
152
|
+
currentTime: number;
|
|
153
|
+
stallTimeout: number;
|
|
154
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
155
|
+
export default _default;
|
|
156
|
+
//# sourceMappingURL=MpegtsPlayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MpegtsPlayer.d.ts","sourceRoot":"","sources":["../src/MpegtsPlayer.tsx"],"names":[],"mappings":"AACA,OAAc,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uCA6Db,GAAE;wCACoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;uCADzB,GAAE;wCACoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA8IL,GAAG;;0BAwBN,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAlOpC,wBA0TG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import type { App } from 'vue';
|
|
2
|
+
import MpegtsPlayerContainer from './MpegtsPlayer';
|
|
3
|
+
declare const MpegtsPlayer: {
|
|
4
|
+
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("vue").ExtractPropTypes<{
|
|
5
|
+
videoUrl: {
|
|
6
|
+
type: StringConstructor;
|
|
7
|
+
default: string;
|
|
8
|
+
};
|
|
9
|
+
closeVisibilityChangeListener: {
|
|
10
|
+
type: BooleanConstructor;
|
|
11
|
+
default: boolean;
|
|
12
|
+
};
|
|
13
|
+
autoVisibilityChangeRefresh: {
|
|
14
|
+
type: BooleanConstructor;
|
|
15
|
+
default: boolean;
|
|
16
|
+
};
|
|
17
|
+
autoReload: {
|
|
18
|
+
type: BooleanConstructor;
|
|
19
|
+
default: boolean;
|
|
20
|
+
};
|
|
21
|
+
isLive: {
|
|
22
|
+
type: BooleanConstructor;
|
|
23
|
+
default: boolean;
|
|
24
|
+
};
|
|
25
|
+
controls: {
|
|
26
|
+
type: BooleanConstructor;
|
|
27
|
+
default: boolean;
|
|
28
|
+
};
|
|
29
|
+
currentTime: {
|
|
30
|
+
type: NumberConstructor;
|
|
31
|
+
default: number;
|
|
32
|
+
};
|
|
33
|
+
stallTimeout: {
|
|
34
|
+
type: NumberConstructor;
|
|
35
|
+
default: number;
|
|
36
|
+
};
|
|
37
|
+
}>> & Readonly<{
|
|
38
|
+
onLoadError?: ((...args: any[]) => any) | undefined;
|
|
39
|
+
onPlaySuccess?: ((...args: any[]) => any) | undefined;
|
|
40
|
+
onLoadComplete?: ((...args: any[]) => any) | undefined;
|
|
41
|
+
onVisibilitychange?: ((...args: any[]) => any) | undefined;
|
|
42
|
+
onTimeupdate?: ((...args: any[]) => any) | undefined;
|
|
43
|
+
onPlayEnded?: ((...args: any[]) => any) | undefined;
|
|
44
|
+
onPlayLoading?: ((...args: any[]) => any) | undefined;
|
|
45
|
+
}>, {
|
|
46
|
+
flvPlayer: import("vue").Ref<{
|
|
47
|
+
destroy: () => void;
|
|
48
|
+
on: (event: string, listener: (...args: any[]) => void) => void;
|
|
49
|
+
off: (event: string, listener: (...args: any[]) => void) => void;
|
|
50
|
+
attachMediaElement: (mediaElement: HTMLMediaElement) => void;
|
|
51
|
+
detachMediaElement: () => void;
|
|
52
|
+
load: () => void;
|
|
53
|
+
unload: () => void;
|
|
54
|
+
play: () => Promise<void>;
|
|
55
|
+
pause: () => void;
|
|
56
|
+
type: string;
|
|
57
|
+
buffered: {
|
|
58
|
+
readonly length: number;
|
|
59
|
+
end: (index: number) => number;
|
|
60
|
+
start: (index: number) => number;
|
|
61
|
+
};
|
|
62
|
+
duration: number;
|
|
63
|
+
volume: number;
|
|
64
|
+
muted: boolean;
|
|
65
|
+
currentTime: number;
|
|
66
|
+
playbackRate: number;
|
|
67
|
+
readyState: number;
|
|
68
|
+
seeking: boolean;
|
|
69
|
+
paused: boolean;
|
|
70
|
+
ended: boolean;
|
|
71
|
+
networkState: number;
|
|
72
|
+
videoWidth: number;
|
|
73
|
+
videoHeight: number;
|
|
74
|
+
} | null, import("mpegts.js").Player | {
|
|
75
|
+
destroy: () => void;
|
|
76
|
+
on: (event: string, listener: (...args: any[]) => void) => void;
|
|
77
|
+
off: (event: string, listener: (...args: any[]) => void) => void;
|
|
78
|
+
attachMediaElement: (mediaElement: HTMLMediaElement) => void;
|
|
79
|
+
detachMediaElement: () => void;
|
|
80
|
+
load: () => void;
|
|
81
|
+
unload: () => void;
|
|
82
|
+
play: () => Promise<void>;
|
|
83
|
+
pause: () => void;
|
|
84
|
+
type: string;
|
|
85
|
+
buffered: {
|
|
86
|
+
readonly length: number;
|
|
87
|
+
end: (index: number) => number;
|
|
88
|
+
start: (index: number) => number;
|
|
89
|
+
};
|
|
90
|
+
duration: number;
|
|
91
|
+
volume: number;
|
|
92
|
+
muted: boolean;
|
|
93
|
+
currentTime: number;
|
|
94
|
+
playbackRate: number;
|
|
95
|
+
readyState: number;
|
|
96
|
+
seeking: boolean;
|
|
97
|
+
paused: boolean;
|
|
98
|
+
ended: boolean;
|
|
99
|
+
networkState: number;
|
|
100
|
+
videoWidth: number;
|
|
101
|
+
videoHeight: number;
|
|
102
|
+
} | null>;
|
|
103
|
+
videoContainerRef: import("vue").Ref<HTMLVideoElement | null, HTMLVideoElement | null>;
|
|
104
|
+
loadMetaData: import("vue").Ref<boolean, boolean>;
|
|
105
|
+
start: () => Promise<void>;
|
|
106
|
+
pause: () => void;
|
|
107
|
+
destroy: () => void;
|
|
108
|
+
reload: () => void;
|
|
109
|
+
handleCanplay: (e: any) => Promise<void>;
|
|
110
|
+
handleLoadedmetadata: () => void;
|
|
111
|
+
handleTimeupdate: (e: any) => void;
|
|
112
|
+
handlePlayEnded: () => void;
|
|
113
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("loadError" | "playSuccess" | "loadComplete" | "visibilitychange" | "timeupdate" | "playEnded" | "playLoading")[], import("vue").PublicProps, {
|
|
114
|
+
videoUrl: string;
|
|
115
|
+
closeVisibilityChangeListener: boolean;
|
|
116
|
+
autoVisibilityChangeRefresh: boolean;
|
|
117
|
+
autoReload: boolean;
|
|
118
|
+
isLive: boolean;
|
|
119
|
+
controls: boolean;
|
|
120
|
+
currentTime: number;
|
|
121
|
+
stallTimeout: number;
|
|
122
|
+
}, true, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
123
|
+
P: {};
|
|
124
|
+
B: {};
|
|
125
|
+
D: {};
|
|
126
|
+
C: {};
|
|
127
|
+
M: {};
|
|
128
|
+
Defaults: {};
|
|
129
|
+
}, Readonly<import("vue").ExtractPropTypes<{
|
|
130
|
+
videoUrl: {
|
|
131
|
+
type: StringConstructor;
|
|
132
|
+
default: string;
|
|
133
|
+
};
|
|
134
|
+
closeVisibilityChangeListener: {
|
|
135
|
+
type: BooleanConstructor;
|
|
136
|
+
default: boolean;
|
|
137
|
+
};
|
|
138
|
+
autoVisibilityChangeRefresh: {
|
|
139
|
+
type: BooleanConstructor;
|
|
140
|
+
default: boolean;
|
|
141
|
+
};
|
|
142
|
+
autoReload: {
|
|
143
|
+
type: BooleanConstructor;
|
|
144
|
+
default: boolean;
|
|
145
|
+
};
|
|
146
|
+
isLive: {
|
|
147
|
+
type: BooleanConstructor;
|
|
148
|
+
default: boolean;
|
|
149
|
+
};
|
|
150
|
+
controls: {
|
|
151
|
+
type: BooleanConstructor;
|
|
152
|
+
default: boolean;
|
|
153
|
+
};
|
|
154
|
+
currentTime: {
|
|
155
|
+
type: NumberConstructor;
|
|
156
|
+
default: number;
|
|
157
|
+
};
|
|
158
|
+
stallTimeout: {
|
|
159
|
+
type: NumberConstructor;
|
|
160
|
+
default: number;
|
|
161
|
+
};
|
|
162
|
+
}>> & Readonly<{
|
|
163
|
+
onLoadError?: ((...args: any[]) => any) | undefined;
|
|
164
|
+
onPlaySuccess?: ((...args: any[]) => any) | undefined;
|
|
165
|
+
onLoadComplete?: ((...args: any[]) => any) | undefined;
|
|
166
|
+
onVisibilitychange?: ((...args: any[]) => any) | undefined;
|
|
167
|
+
onTimeupdate?: ((...args: any[]) => any) | undefined;
|
|
168
|
+
onPlayEnded?: ((...args: any[]) => any) | undefined;
|
|
169
|
+
onPlayLoading?: ((...args: any[]) => any) | undefined;
|
|
170
|
+
}>, {
|
|
171
|
+
flvPlayer: import("vue").Ref<{
|
|
172
|
+
destroy: () => void;
|
|
173
|
+
on: (event: string, listener: (...args: any[]) => void) => void;
|
|
174
|
+
off: (event: string, listener: (...args: any[]) => void) => void;
|
|
175
|
+
attachMediaElement: (mediaElement: HTMLMediaElement) => void;
|
|
176
|
+
detachMediaElement: () => void;
|
|
177
|
+
load: () => void;
|
|
178
|
+
unload: () => void;
|
|
179
|
+
play: () => Promise<void>;
|
|
180
|
+
pause: () => void;
|
|
181
|
+
type: string;
|
|
182
|
+
buffered: {
|
|
183
|
+
readonly length: number;
|
|
184
|
+
end: (index: number) => number;
|
|
185
|
+
start: (index: number) => number;
|
|
186
|
+
};
|
|
187
|
+
duration: number;
|
|
188
|
+
volume: number;
|
|
189
|
+
muted: boolean;
|
|
190
|
+
currentTime: number;
|
|
191
|
+
playbackRate: number;
|
|
192
|
+
readyState: number;
|
|
193
|
+
seeking: boolean;
|
|
194
|
+
paused: boolean;
|
|
195
|
+
ended: boolean;
|
|
196
|
+
networkState: number;
|
|
197
|
+
videoWidth: number;
|
|
198
|
+
videoHeight: number;
|
|
199
|
+
} | null, import("mpegts.js").Player | {
|
|
200
|
+
destroy: () => void;
|
|
201
|
+
on: (event: string, listener: (...args: any[]) => void) => void;
|
|
202
|
+
off: (event: string, listener: (...args: any[]) => void) => void;
|
|
203
|
+
attachMediaElement: (mediaElement: HTMLMediaElement) => void;
|
|
204
|
+
detachMediaElement: () => void;
|
|
205
|
+
load: () => void;
|
|
206
|
+
unload: () => void;
|
|
207
|
+
play: () => Promise<void>;
|
|
208
|
+
pause: () => void;
|
|
209
|
+
type: string;
|
|
210
|
+
buffered: {
|
|
211
|
+
readonly length: number;
|
|
212
|
+
end: (index: number) => number;
|
|
213
|
+
start: (index: number) => number;
|
|
214
|
+
};
|
|
215
|
+
duration: number;
|
|
216
|
+
volume: number;
|
|
217
|
+
muted: boolean;
|
|
218
|
+
currentTime: number;
|
|
219
|
+
playbackRate: number;
|
|
220
|
+
readyState: number;
|
|
221
|
+
seeking: boolean;
|
|
222
|
+
paused: boolean;
|
|
223
|
+
ended: boolean;
|
|
224
|
+
networkState: number;
|
|
225
|
+
videoWidth: number;
|
|
226
|
+
videoHeight: number;
|
|
227
|
+
} | null>;
|
|
228
|
+
videoContainerRef: import("vue").Ref<HTMLVideoElement | null, HTMLVideoElement | null>;
|
|
229
|
+
loadMetaData: import("vue").Ref<boolean, boolean>;
|
|
230
|
+
start: () => Promise<void>;
|
|
231
|
+
pause: () => void;
|
|
232
|
+
destroy: () => void;
|
|
233
|
+
reload: () => void;
|
|
234
|
+
handleCanplay: (e: any) => Promise<void>;
|
|
235
|
+
handleLoadedmetadata: () => void;
|
|
236
|
+
handleTimeupdate: (e: any) => void;
|
|
237
|
+
handlePlayEnded: () => void;
|
|
238
|
+
}, {}, {}, {}, {
|
|
239
|
+
videoUrl: string;
|
|
240
|
+
closeVisibilityChangeListener: boolean;
|
|
241
|
+
autoVisibilityChangeRefresh: boolean;
|
|
242
|
+
autoReload: boolean;
|
|
243
|
+
isLive: boolean;
|
|
244
|
+
controls: boolean;
|
|
245
|
+
currentTime: number;
|
|
246
|
+
stallTimeout: number;
|
|
247
|
+
}>;
|
|
248
|
+
__isFragment?: never;
|
|
249
|
+
__isTeleport?: never;
|
|
250
|
+
__isSuspense?: never;
|
|
251
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
252
|
+
videoUrl: {
|
|
253
|
+
type: StringConstructor;
|
|
254
|
+
default: string;
|
|
255
|
+
};
|
|
256
|
+
closeVisibilityChangeListener: {
|
|
257
|
+
type: BooleanConstructor;
|
|
258
|
+
default: boolean;
|
|
259
|
+
};
|
|
260
|
+
autoVisibilityChangeRefresh: {
|
|
261
|
+
type: BooleanConstructor;
|
|
262
|
+
default: boolean;
|
|
263
|
+
};
|
|
264
|
+
autoReload: {
|
|
265
|
+
type: BooleanConstructor;
|
|
266
|
+
default: boolean;
|
|
267
|
+
};
|
|
268
|
+
isLive: {
|
|
269
|
+
type: BooleanConstructor;
|
|
270
|
+
default: boolean;
|
|
271
|
+
};
|
|
272
|
+
controls: {
|
|
273
|
+
type: BooleanConstructor;
|
|
274
|
+
default: boolean;
|
|
275
|
+
};
|
|
276
|
+
currentTime: {
|
|
277
|
+
type: NumberConstructor;
|
|
278
|
+
default: number;
|
|
279
|
+
};
|
|
280
|
+
stallTimeout: {
|
|
281
|
+
type: NumberConstructor;
|
|
282
|
+
default: number;
|
|
283
|
+
};
|
|
284
|
+
}>> & Readonly<{
|
|
285
|
+
onLoadError?: ((...args: any[]) => any) | undefined;
|
|
286
|
+
onPlaySuccess?: ((...args: any[]) => any) | undefined;
|
|
287
|
+
onLoadComplete?: ((...args: any[]) => any) | undefined;
|
|
288
|
+
onVisibilitychange?: ((...args: any[]) => any) | undefined;
|
|
289
|
+
onTimeupdate?: ((...args: any[]) => any) | undefined;
|
|
290
|
+
onPlayEnded?: ((...args: any[]) => any) | undefined;
|
|
291
|
+
onPlayLoading?: ((...args: any[]) => any) | undefined;
|
|
292
|
+
}>, {
|
|
293
|
+
flvPlayer: import("vue").Ref<{
|
|
294
|
+
destroy: () => void;
|
|
295
|
+
on: (event: string, listener: (...args: any[]) => void) => void;
|
|
296
|
+
off: (event: string, listener: (...args: any[]) => void) => void;
|
|
297
|
+
attachMediaElement: (mediaElement: HTMLMediaElement) => void;
|
|
298
|
+
detachMediaElement: () => void;
|
|
299
|
+
load: () => void;
|
|
300
|
+
unload: () => void;
|
|
301
|
+
play: () => Promise<void>;
|
|
302
|
+
pause: () => void;
|
|
303
|
+
type: string;
|
|
304
|
+
buffered: {
|
|
305
|
+
readonly length: number;
|
|
306
|
+
end: (index: number) => number;
|
|
307
|
+
start: (index: number) => number;
|
|
308
|
+
};
|
|
309
|
+
duration: number;
|
|
310
|
+
volume: number;
|
|
311
|
+
muted: boolean;
|
|
312
|
+
currentTime: number;
|
|
313
|
+
playbackRate: number;
|
|
314
|
+
readyState: number;
|
|
315
|
+
seeking: boolean;
|
|
316
|
+
paused: boolean;
|
|
317
|
+
ended: boolean;
|
|
318
|
+
networkState: number;
|
|
319
|
+
videoWidth: number;
|
|
320
|
+
videoHeight: number;
|
|
321
|
+
} | null, import("mpegts.js").Player | {
|
|
322
|
+
destroy: () => void;
|
|
323
|
+
on: (event: string, listener: (...args: any[]) => void) => void;
|
|
324
|
+
off: (event: string, listener: (...args: any[]) => void) => void;
|
|
325
|
+
attachMediaElement: (mediaElement: HTMLMediaElement) => void;
|
|
326
|
+
detachMediaElement: () => void;
|
|
327
|
+
load: () => void;
|
|
328
|
+
unload: () => void;
|
|
329
|
+
play: () => Promise<void>;
|
|
330
|
+
pause: () => void;
|
|
331
|
+
type: string;
|
|
332
|
+
buffered: {
|
|
333
|
+
readonly length: number;
|
|
334
|
+
end: (index: number) => number;
|
|
335
|
+
start: (index: number) => number;
|
|
336
|
+
};
|
|
337
|
+
duration: number;
|
|
338
|
+
volume: number;
|
|
339
|
+
muted: boolean;
|
|
340
|
+
currentTime: number;
|
|
341
|
+
playbackRate: number;
|
|
342
|
+
readyState: number;
|
|
343
|
+
seeking: boolean;
|
|
344
|
+
paused: boolean;
|
|
345
|
+
ended: boolean;
|
|
346
|
+
networkState: number;
|
|
347
|
+
videoWidth: number;
|
|
348
|
+
videoHeight: number;
|
|
349
|
+
} | null>;
|
|
350
|
+
videoContainerRef: import("vue").Ref<HTMLVideoElement | null, HTMLVideoElement | null>;
|
|
351
|
+
loadMetaData: import("vue").Ref<boolean, boolean>;
|
|
352
|
+
start: () => Promise<void>;
|
|
353
|
+
pause: () => void;
|
|
354
|
+
destroy: () => void;
|
|
355
|
+
reload: () => void;
|
|
356
|
+
handleCanplay: (e: any) => Promise<void>;
|
|
357
|
+
handleLoadedmetadata: () => void;
|
|
358
|
+
handleTimeupdate: (e: any) => void;
|
|
359
|
+
handlePlayEnded: () => void;
|
|
360
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("loadError" | "playSuccess" | "loadComplete" | "visibilitychange" | "timeupdate" | "playEnded" | "playLoading")[], "loadError" | "playSuccess" | "loadComplete" | "visibilitychange" | "timeupdate" | "playEnded" | "playLoading", {
|
|
361
|
+
videoUrl: string;
|
|
362
|
+
closeVisibilityChangeListener: boolean;
|
|
363
|
+
autoVisibilityChangeRefresh: boolean;
|
|
364
|
+
autoReload: boolean;
|
|
365
|
+
isLive: boolean;
|
|
366
|
+
controls: boolean;
|
|
367
|
+
currentTime: number;
|
|
368
|
+
stallTimeout: number;
|
|
369
|
+
}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & {
|
|
370
|
+
install: (app: App) => void;
|
|
371
|
+
};
|
|
372
|
+
export type MpegtsPlayerInstance = InstanceType<typeof MpegtsPlayerContainer>;
|
|
373
|
+
export default MpegtsPlayer;
|
|
374
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE/B,OAAO,qBAAqB,MAAM,gBAAgB,CAAC;AAEnD,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAUs+B,GAAG;4CAA+D,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAArE,GAAG;4CAA+D,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAArE,GAAG;4CAA+D,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAArE,GAAG;4CAA+D,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uCAArE,GAAG;wCAA+D,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;uCAArE,GAAG;wCAA+D,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAT5iC,GAAG;CAIlB,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE9E,eAAe,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const o=require("vue"),u=require("mpegts.js"),O=Symbol("ArcoConfigProvider"),I="arco",N="$arco",x=e=>{var n,t,s;const c=o.getCurrentInstance(),d=o.inject(O,void 0),i=(s=(t=d==null?void 0:d.prefixCls)!=null?t:(n=c==null?void 0:c.appContext.config.globalProperties[N])==null?void 0:n.classPrefix)!=null?s:I;return e?`${i}-${e}`:i},z=Object.prototype.toString;function D(e){return z.call(e)==="[object Number]"&&e===e}var F=(e,n)=>{for(const[t,s]of n)e[t]=s;return e};const j=o.defineComponent({name:"IconLoading",props:{size:{type:[Number,String]},strokeWidth:{type:Number,default:4},strokeLinecap:{type:String,default:"butt",validator:e=>["butt","round","square"].includes(e)},strokeLinejoin:{type:String,default:"miter",validator:e=>["arcs","bevel","miter","miter-clip","round"].includes(e)},rotate:Number,spin:Boolean},emits:{click:e=>!0},setup(e,{emit:n}){const t=x("icon"),s=o.computed(()=>[t,`${t}-loading`,{[`${t}-spin`]:e.spin}]),c=o.computed(()=>{const i={};return e.size&&(i.fontSize=D(e.size)?`${e.size}px`:e.size),e.rotate&&(i.transform=`rotate(${e.rotate}deg)`),i});return{cls:s,innerStyle:c,onClick:i=>{n("click",i)}}}}),A=["stroke-width","stroke-linecap","stroke-linejoin"],V=o.createElementVNode("path",{d:"M42 24c0 9.941-8.059 18-18 18S6 33.941 6 24 14.059 6 24 6"},null,-1),U=[V];function G(e,n,t,s,c,d){return o.openBlock(),o.createElementBlock("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",class:o.normalizeClass(e.cls),style:o.normalizeStyle(e.innerStyle),"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin,onClick:n[0]||(n[0]=(...i)=>e.onClick&&e.onClick(...i))},U,14,A)}var y=F(j,[["render",G]]);const W=Object.assign(y,{install:(e,n)=>{var t;const s=(t=n==null?void 0:n.iconPrefix)!=null?t:"";e.component(s+y.name,y)}});const g=o.defineComponent({name:"MpegtsPlayer",props:{videoUrl:{type:String,default:""},closeVisibilityChangeListener:{type:Boolean,default:!1},autoVisibilityChangeRefresh:{type:Boolean,default:!1},autoReload:{type:Boolean,default:!1},isLive:{type:Boolean,default:!0},controls:{type:Boolean,default:!1},currentTime:{type:Number,default:0},stallTimeout:{type:Number,default:5e3}},emits:["loadError","playSuccess","loadComplete","visibilitychange","timeupdate","playEnded","playLoading"],setup(e,{emit:n}){const t=o.ref(null),s=o.ref(null),c=o.ref(!0),d=o.ref(!1),i=o.ref(0);let p=0,m=Date.now();const h=()=>{const a=s.value;t.value=u.createPlayer({type:"flv",isLive:e.isLive,hasAudio:!1,cors:!0,url:e.videoUrl},{enableWorker:!1,enableWorkerForMSE:!1,enableStashBuffer:!e.isLive,stashInitialSize:128,lazyLoad:!1,lazyLoadMaxDuration:.2,deferLoadAfterSourceOpen:!1,liveBufferLatencyChasing:!!e.isLive,liveBufferLatencyMaxLatency:1,liveBufferLatencyMinRemain:.5,autoCleanupSourceBuffer:!0,autoCleanupMinBackwardDuration:30,autoCleanupMaxBackwardDuration:60}),t.value.attachMediaElement(a),c.value=!0,k(),S()},k=async()=>{try{t.value.load()}catch(a){console.log(a),n("loadError",a)}},S=()=>{t.value.on(u.Events.ERROR,C),t.value.on(u.Events.LOADING_COMPLETE,L),t.value.on(u.Events.STATISTICS_INFO,P)},C=(a,l,r)=>{console.log(`类型:${JSON.stringify(a)}`,`报错内容${l}`,"报错信息",r),n("loadError",l)},L=(a,l,r)=>{console.log(`类型:${JSON.stringify(a)}`,`报错内容${l}`,"报错信息",r),console.log("直播已结束"),n("loadComplete"),e.autoReload&&M()},P=a=>{const l=a.decodedFrames,r=Date.now();l===p&&l!==0?r-m>e.stallTimeout&&(console.log(`解码帧数超过 ${e.stallTimeout/1e3} 秒没有更新,可能卡顿了`),n("playLoading")):(p=l,m=r)},M=()=>{console.log("自动加载",i.value),i.value++,i.value<=2?v():i.value=0},v=()=>{t.value!=null&&f(),h()},$=()=>t.value.play(),R=()=>t.value.pause(),f=()=>{var a,l,r,E;t.value&&(t.value.off(u.Events.ERROR,C),t.value.off(u.Events.LOADING_COMPLETE,L),(a=t.value)==null||a.pause(),(l=t.value)==null||l.unload(),(r=t.value)==null||r.detachMediaElement(),(E=t.value)==null||E.destroy(),t.value=null)},B=async a=>{var l;if(!(!((l=a.target)!=null&&l.paused)||!c.value)){c.value=!1,console.log("handleCanplay",a.target.paused),i.value=0,d.value=!1;try{await t.value.play(),console.log(t.value),n("playSuccess")}catch(r){console.log("play error",r),n("loadError",r)}}},T=()=>{d.value=!0},_=a=>{var l;n("timeupdate",((l=a==null?void 0:a.target)==null?void 0:l.currentTime)??0)},w=()=>{n("playEnded")},b=()=>{document.visibilityState==="visible"?(n("visibilitychange",document.visibilityState),e.autoVisibilityChangeRefresh&&v()):f()};return o.watch(()=>e.videoUrl,a=>{a&&o.nextTick(()=>{t.value!=null&&f(),console.log(`isSupported: ${u.isSupported()}`),console.log(`是否支持点播视频:${u.getFeatureList().msePlayback}`),console.log(`是否支持httpflv直播流:${u.getFeatureList().mseLivePlayback}`),h()})},{immediate:!0}),o.onMounted(()=>{e.closeVisibilityChangeListener||document.addEventListener("visibilitychange",b)}),o.onUnmounted(()=>{f(),e.closeVisibilityChangeListener||document.removeEventListener("visibilitychange",b)}),{flvPlayer:t,videoContainerRef:s,loadMetaData:d,start:$,pause:R,destroy:f,reload:v,handleCanplay:B,handleLoadedmetadata:T,handleTimeupdate:_,handlePlayEnded:w}},render(){return React.createElement("div",{class:"mainContainer"},React.createElement("video",{class:"video-container",ref:"videoContainerRef",muted:!0,controls:this.controls,onClick:e=>e.preventDefault(),onCanplay:this.handleCanplay,onLoadedmetadata:this.handleLoadedmetadata,onTimeupdate:this.handleTimeupdate,onEnded:this.handlePlayEnded},"Your browser is too old which doesn't support HTML5 video."),this.loadMetaData&&React.createElement(W,{class:"meta-data-loading"}))}}),q=Object.assign(g,{install:e=>{e.component(g.name,g)}});module.exports=q;
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.mainContainer{display:block;width:100%;height:100%;margin-left:auto;margin-right:auto;position:relative}.meta-data-loading{position:absolute;top:50%;left:50%;margin-top:-20px;margin-left:-20px;font-size:40px;color:rgb(var(--primary-6))}.video-container{width:100%;height:100%}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@linker-design-plus/mpegtsplayer",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A player base on mpegts.js",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"registry": "https://registry.npmjs.org/",
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"src/MpegtsPlayer.less"
|
|
15
|
+
],
|
|
16
|
+
"keywords": [
|
|
17
|
+
"vue",
|
|
18
|
+
"mpegts",
|
|
19
|
+
"mpegts-player"
|
|
20
|
+
],
|
|
21
|
+
"author": "Linker Design Team",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"vue": "^3.1.0",
|
|
25
|
+
"mpegts.js": "1.7.3",
|
|
26
|
+
"@arco-design/web-vue": "2.56.3"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"vue": "^3.1.0",
|
|
30
|
+
"@arco-design/web-vue": "^2.0.0",
|
|
31
|
+
"mpegts.js": "1.7.3"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^18.0.0",
|
|
35
|
+
"rimraf": "^5.0.0",
|
|
36
|
+
"typescript": "^5.0.0",
|
|
37
|
+
"vite": "^4.0.0"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"startup": "pnpm build",
|
|
41
|
+
"dev": "node scripts/build.mjs -w",
|
|
42
|
+
"build": "pnpm clean && pnpm build:bundle && pnpm build:types",
|
|
43
|
+
"build:types": "tsc -p ./tsconfig.json --emitDeclarationOnly",
|
|
44
|
+
"build:bundle": "node scripts/build.mjs",
|
|
45
|
+
"build:dev": "tsc",
|
|
46
|
+
"clean": "rimraf ./dist"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.mainContainer {
|
|
2
|
+
display: block;
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 100%;
|
|
5
|
+
margin-left: auto;
|
|
6
|
+
margin-right: auto;
|
|
7
|
+
position: relative;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.meta-data-loading {
|
|
11
|
+
position: absolute;
|
|
12
|
+
top: 50%;
|
|
13
|
+
left: 50%;
|
|
14
|
+
margin-top: -20px; /* 子元素高度的一半 */
|
|
15
|
+
margin-left: -20px; /* 子元素宽度的一半 */
|
|
16
|
+
font-size: 40px;
|
|
17
|
+
color: rgb(var(--primary-6));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.video-container {
|
|
21
|
+
width: 100%;
|
|
22
|
+
height: 100%;
|
|
23
|
+
}
|