@linker-design-plus/mpegtsplayer 1.0.0 → 1.0.2

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 CHANGED
@@ -1,21 +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.
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 CHANGED
@@ -1,228 +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
-
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
228
  MIT