@linker-design-plus/mpegtsplayer 1.0.1 → 1.0.3
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 +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +114 -135
- package/dist/style.css +1 -1
- package/package.json +5 -3
- package/src/MpegtsPlayer.less +3 -3
package/README.md
CHANGED
|
@@ -34,6 +34,7 @@ yarn add @linker-design-plus/mpegtsplayer
|
|
|
34
34
|
// 在 main.js 或入口文件中
|
|
35
35
|
import { createApp } from 'vue';
|
|
36
36
|
import MpegtsPlayer from '@linker-design-plus/mpegtsplayer';
|
|
37
|
+
import '@linker-design-plus/mpegtsplayer/dist/style.css';
|
|
37
38
|
|
|
38
39
|
const app = createApp(App);
|
|
39
40
|
app.component('MpegtsPlayer', MpegtsPlayer);
|
|
@@ -44,6 +45,7 @@ app.component('MpegtsPlayer', MpegtsPlayer);
|
|
|
44
45
|
```vue
|
|
45
46
|
<script setup>
|
|
46
47
|
import MpegtsPlayer from '@linker-design-plus/mpegtsplayer';
|
|
48
|
+
import '@linker-design-plus/mpegtsplayer/dist/style.css';
|
|
47
49
|
</script>
|
|
48
50
|
```
|
|
49
51
|
|
|
@@ -148,6 +150,7 @@ import MpegtsPlayer from '@linker-design-plus/mpegtsplayer';
|
|
|
148
150
|
<script setup>
|
|
149
151
|
import { ref } from 'vue';
|
|
150
152
|
import MpegtsPlayer from '@linker-design-plus/mpegtsplayer';
|
|
153
|
+
import '@linker-design-plus/mpegtsplayer/dist/style.css';
|
|
151
154
|
|
|
152
155
|
const playerRef = ref(null);
|
|
153
156
|
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CAUw9B,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAT9hC,GAAG;CAIlB,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE9E,eAAe,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const n=require("vue"),u=require("mpegts.js"),O=Symbol("ArcoConfigProvider"),R="arco",I="$arco",x=e=>{var a,t,s;const c=n.getCurrentInstance(),d=n.inject(O,void 0),i=(s=(t=d==null?void 0:d.prefixCls)!=null?t:(a=c==null?void 0:c.appContext.config.globalProperties[I])==null?void 0:a.classPrefix)!=null?s:R;return e?`${i}-${e}`:i},z=Object.prototype.toString;function D(e){return z.call(e)==="[object Number]"&&e===e}var V=(e,a)=>{for(const[t,s]of a)e[t]=s;return e};const F=n.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:a}){const t=x("icon"),s=n.computed(()=>[t,`${t}-loading`,{[`${t}-spin`]:e.spin}]),c=n.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=>{a("click",i)}}}}),j=["stroke-width","stroke-linecap","stroke-linejoin"],A=n.createElementVNode("path",{d:"M42 24c0 9.941-8.059 18-18 18S6 33.941 6 24 14.059 6 24 6"},null,-1),U=[A];function G(e,a,t,s,c,d){return n.openBlock(),n.createElementBlock("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",class:n.normalizeClass(e.cls),style:n.normalizeStyle(e.innerStyle),"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin,onClick:a[0]||(a[0]=(...i)=>e.onClick&&e.onClick(...i))},U,14,j)}var y=V(F,[["render",G]]);const W=Object.assign(y,{install:(e,a)=>{var t;const s=(t=a==null?void 0:a.iconPrefix)!=null?t:"";e.component(s+y.name,y)}});const p=n.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:a}){const t=n.ref(null),s=n.ref(null),c=n.ref(!0),d=n.ref(!1),i=n.ref(0);let g=0,m=Date.now();const h=()=>{const o=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(o),c.value=!0,E(),S()},E=async()=>{try{t.value.load()}catch(o){console.log(o),a("loadError",o)}},S=()=>{t.value.on(u.Events.ERROR,L),t.value.on(u.Events.LOADING_COMPLETE,C),t.value.on(u.Events.STATISTICS_INFO,P)},L=(o,l,r)=>{console.log(`类型:${JSON.stringify(o)}`,`报错内容${l}`,"报错信息",r),a("loadError",l)},C=(o,l,r)=>{console.log(`类型:${JSON.stringify(o)}`,`报错内容${l}`,"报错信息",r),console.log("直播已结束"),a("loadComplete"),e.autoReload&&M()},P=o=>{const l=o.decodedFrames,r=Date.now();l===g&&l!==0?r-m>e.stallTimeout&&(console.log(`解码帧数超过 ${e.stallTimeout/1e3} 秒没有更新,可能卡顿了`),a("playLoading")):(g=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(),N=()=>t.value.pause(),f=()=>{var o,l,r,k;t.value&&(t.value.off(u.Events.ERROR,L),t.value.off(u.Events.LOADING_COMPLETE,C),(o=t.value)==null||o.pause(),(l=t.value)==null||l.unload(),(r=t.value)==null||r.detachMediaElement(),(k=t.value)==null||k.destroy(),t.value=null)},T=async o=>{var l;if(!(!((l=o.target)!=null&&l.paused)||!c.value)){c.value=!1,console.log("handleCanplay",o.target.paused),i.value=0,d.value=!1;try{await t.value.play(),console.log(t.value),a("playSuccess")}catch(r){console.log("play error",r),a("loadError",r)}}},B=()=>{d.value=!0},_=o=>{var l;a("timeupdate",((l=o==null?void 0:o.target)==null?void 0:l.currentTime)??0)},w=()=>{a("playEnded")},b=()=>{document.visibilityState==="visible"?(a("visibilitychange",document.visibilityState),e.autoVisibilityChangeRefresh&&v()):f()};return n.watch(()=>e.videoUrl,o=>{o&&n.nextTick(()=>{t.value!=null&&f(),console.log(`isSupported: ${u.isSupported()}`),console.log(`是否支持点播视频:${u.getFeatureList().msePlayback}`),console.log(`是否支持httpflv直播流:${u.getFeatureList().mseLivePlayback}`),h()})},{immediate:!0}),n.onMounted(()=>{e.closeVisibilityChangeListener||document.addEventListener("visibilitychange",b)}),n.onUnmounted(()=>{f(),e.closeVisibilityChangeListener||document.removeEventListener("visibilitychange",b)}),{flvPlayer:t,videoContainerRef:s,loadMetaData:d,start:$,pause:N,destroy:f,reload:v,handleCanplay:T,handleLoadedmetadata:B,handleTimeupdate:_,handlePlayEnded:w}},render(){return n.createVNode("div",{class:"mpegts-player-container"},[n.createVNode("video",{class:"mpegts-player-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},[n.createTextVNode("Your browser is too old which doesn't support HTML5 video.")]),this.loadMetaData&&n.createVNode(W,{class:"mpegts-player-loading"},null)])}}),q=Object.assign(p,{install:e=>{e.component(p.name,p)}});module.exports=q;
|
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { getCurrentInstance as
|
|
1
|
+
import { getCurrentInstance as x, inject as z, defineComponent as P, computed as S, openBlock as D, createElementBlock as F, normalizeClass as j, normalizeStyle as A, createElementVNode as V, ref as f, watch as U, nextTick as G, onMounted as W, onUnmounted as J, createVNode as y, createTextVNode as q } from "vue";
|
|
2
2
|
import c from "mpegts.js";
|
|
3
|
-
const
|
|
3
|
+
const H = Symbol("ArcoConfigProvider"), K = "arco", X = "$arco", Y = (e) => {
|
|
4
4
|
var a, t, i;
|
|
5
|
-
const r =
|
|
5
|
+
const r = x(), u = z(H, void 0), l = (i = (t = u == null ? void 0 : u.prefixCls) != null ? t : (a = r == null ? void 0 : r.appContext.config.globalProperties[X]) == null ? void 0 : a.classPrefix) != null ? i : K;
|
|
6
6
|
return e ? `${l}-${e}` : l;
|
|
7
|
-
},
|
|
8
|
-
function
|
|
9
|
-
return
|
|
7
|
+
}, Q = Object.prototype.toString;
|
|
8
|
+
function Z(e) {
|
|
9
|
+
return Q.call(e) === "[object Number]" && e === e;
|
|
10
10
|
}
|
|
11
|
-
var
|
|
11
|
+
var ee = (e, a) => {
|
|
12
12
|
for (const [t, i] of a)
|
|
13
13
|
e[t] = i;
|
|
14
14
|
return e;
|
|
15
15
|
};
|
|
16
|
-
const
|
|
16
|
+
const te = P({
|
|
17
17
|
name: "IconLoading",
|
|
18
18
|
props: {
|
|
19
19
|
size: {
|
|
@@ -40,9 +40,9 @@ const Z = S({
|
|
|
40
40
|
click: (e) => !0
|
|
41
41
|
},
|
|
42
42
|
setup(e, { emit: a }) {
|
|
43
|
-
const t =
|
|
43
|
+
const t = Y("icon"), i = S(() => [t, `${t}-loading`, { [`${t}-spin`]: e.spin }]), r = S(() => {
|
|
44
44
|
const l = {};
|
|
45
|
-
return e.size && (l.fontSize =
|
|
45
|
+
return e.size && (l.fontSize = Z(e.size) ? `${e.size}px` : e.size), e.rotate && (l.transform = `rotate(${e.rotate}deg)`), l;
|
|
46
46
|
});
|
|
47
47
|
return {
|
|
48
48
|
cls: i,
|
|
@@ -52,32 +52,32 @@ const Z = S({
|
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
}),
|
|
56
|
-
|
|
55
|
+
}), ae = ["stroke-width", "stroke-linecap", "stroke-linejoin"], ne = /* @__PURE__ */ V("path", { d: "M42 24c0 9.941-8.059 18-18 18S6 33.941 6 24 14.059 6 24 6" }, null, -1), oe = [
|
|
56
|
+
ne
|
|
57
57
|
];
|
|
58
|
-
function
|
|
59
|
-
return
|
|
58
|
+
function le(e, a, t, i, r, u) {
|
|
59
|
+
return D(), F("svg", {
|
|
60
60
|
viewBox: "0 0 48 48",
|
|
61
61
|
fill: "none",
|
|
62
62
|
xmlns: "http://www.w3.org/2000/svg",
|
|
63
63
|
stroke: "currentColor",
|
|
64
|
-
class:
|
|
65
|
-
style:
|
|
64
|
+
class: j(e.cls),
|
|
65
|
+
style: A(e.innerStyle),
|
|
66
66
|
"stroke-width": e.strokeWidth,
|
|
67
67
|
"stroke-linecap": e.strokeLinecap,
|
|
68
68
|
"stroke-linejoin": e.strokeLinejoin,
|
|
69
69
|
onClick: a[0] || (a[0] = (...l) => e.onClick && e.onClick(...l))
|
|
70
|
-
},
|
|
70
|
+
}, oe, 14, ae);
|
|
71
71
|
}
|
|
72
|
-
var
|
|
73
|
-
const
|
|
72
|
+
var p = /* @__PURE__ */ ee(te, [["render", le]]);
|
|
73
|
+
const ie = Object.assign(p, {
|
|
74
74
|
install: (e, a) => {
|
|
75
75
|
var t;
|
|
76
76
|
const i = (t = a == null ? void 0 : a.iconPrefix) != null ? t : "";
|
|
77
|
-
e.component(i +
|
|
77
|
+
e.component(i + p.name, p);
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
|
-
const
|
|
80
|
+
const g = /* @__PURE__ */ P({
|
|
81
81
|
name: "MpegtsPlayer",
|
|
82
82
|
props: {
|
|
83
83
|
videoUrl: {
|
|
@@ -113,95 +113,76 @@ const m = S({
|
|
|
113
113
|
default: 5e3
|
|
114
114
|
}
|
|
115
115
|
},
|
|
116
|
-
emits: [
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"visibilitychange",
|
|
121
|
-
"timeupdate",
|
|
122
|
-
"playEnded",
|
|
123
|
-
"playLoading"
|
|
124
|
-
],
|
|
125
|
-
setup(e, { emit: a }) {
|
|
116
|
+
emits: ["loadError", "playSuccess", "loadComplete", "visibilitychange", "timeupdate", "playEnded", "playLoading"],
|
|
117
|
+
setup(e, {
|
|
118
|
+
emit: a
|
|
119
|
+
}) {
|
|
126
120
|
const t = f(null), i = f(null), r = f(!0), u = f(!1), l = f(0);
|
|
127
|
-
let
|
|
128
|
-
const
|
|
121
|
+
let m = 0, h = Date.now();
|
|
122
|
+
const L = () => {
|
|
129
123
|
const n = i.value;
|
|
130
|
-
t.value = c.createPlayer(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
), t.value.attachMediaElement(n), r.value = !0, P(), M();
|
|
172
|
-
}, P = async () => {
|
|
124
|
+
t.value = c.createPlayer({
|
|
125
|
+
type: "flv",
|
|
126
|
+
// 指定视频类型
|
|
127
|
+
isLive: e.isLive,
|
|
128
|
+
// 开启直播
|
|
129
|
+
hasAudio: !1,
|
|
130
|
+
// 关闭声音
|
|
131
|
+
cors: !0,
|
|
132
|
+
// 开启跨域访问
|
|
133
|
+
url: e.videoUrl
|
|
134
|
+
// 指定流链接
|
|
135
|
+
}, {
|
|
136
|
+
enableWorker: !1,
|
|
137
|
+
// 启用分离的线程进行转换(如果不想看到控制台频繁报错把它设置为false,官方的回答是这个属性还不稳定,所以要测试实时视频流的话设置为true控制台经常报错)
|
|
138
|
+
// @ts-ignore
|
|
139
|
+
enableWorkerForMSE: !1,
|
|
140
|
+
enableStashBuffer: !e.isLive,
|
|
141
|
+
// 关闭IO隐藏缓冲区(如果需要最小延迟,则设置为false,此项设置针对直播视频流)
|
|
142
|
+
stashInitialSize: 128,
|
|
143
|
+
// 减少首帧等待时长(针对实时视频流)
|
|
144
|
+
lazyLoad: !1,
|
|
145
|
+
// 关闭懒加载模式(针对实时视频流)
|
|
146
|
+
lazyLoadMaxDuration: 0.2,
|
|
147
|
+
// 懒加载的最大时长。单位:秒。建议针对直播:调整为200毫秒
|
|
148
|
+
deferLoadAfterSourceOpen: !1,
|
|
149
|
+
// 在MediaSource sourceopen事件触发后加载。在Chrome上,在后台打开的标签页可能不会触发sourceopen事件,除非切换到该标签页。
|
|
150
|
+
liveBufferLatencyChasing: !!e.isLive,
|
|
151
|
+
// 追踪内部缓冲区导致的实时流延迟
|
|
152
|
+
liveBufferLatencyMaxLatency: 1,
|
|
153
|
+
// HTMLMediaElement 中可接受的最大缓冲区延迟(以秒为单位)之前使用flv.js发现延时严重,还有延时累加的问题,而mpegts.js对此做了优化,不需要我们自己设置快进追帧了
|
|
154
|
+
liveBufferLatencyMinRemain: 0.5,
|
|
155
|
+
// HTMLMediaElement 中可接受的最小缓冲区延迟(以秒为单位)
|
|
156
|
+
autoCleanupSourceBuffer: !0,
|
|
157
|
+
// 自动清理SourceBuffer,防止缓冲区溢出。
|
|
158
|
+
autoCleanupMinBackwardDuration: 30,
|
|
159
|
+
// 自动清理时保留的最小回溯时长。
|
|
160
|
+
autoCleanupMaxBackwardDuration: 60
|
|
161
|
+
// 自动清理时的最大回溯时长。
|
|
162
|
+
}), t.value.attachMediaElement(n), r.value = !0, M(), $();
|
|
163
|
+
}, M = async () => {
|
|
173
164
|
try {
|
|
174
165
|
t.value.load();
|
|
175
166
|
} catch (n) {
|
|
176
167
|
console.log(n), a("loadError", n);
|
|
177
168
|
}
|
|
178
|
-
},
|
|
179
|
-
t.value.on(c.Events.ERROR,
|
|
180
|
-
}, L = (n, o, s) => {
|
|
181
|
-
console.log(
|
|
182
|
-
`类型:${JSON.stringify(n)}`,
|
|
183
|
-
`报错内容${o}`,
|
|
184
|
-
"报错信息",
|
|
185
|
-
s
|
|
186
|
-
), a("loadError", o);
|
|
169
|
+
}, $ = () => {
|
|
170
|
+
t.value.on(c.Events.ERROR, C), t.value.on(c.Events.LOADING_COMPLETE, b), t.value.on(c.Events.STATISTICS_INFO, T);
|
|
187
171
|
}, C = (n, o, s) => {
|
|
188
|
-
console.log(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
s
|
|
193
|
-
), console.log("直播已结束"), a("loadComplete"), e.autoReload && R();
|
|
194
|
-
}, $ = (n) => {
|
|
172
|
+
console.log(`类型:${JSON.stringify(n)}`, `报错内容${o}`, "报错信息", s), a("loadError", o);
|
|
173
|
+
}, b = (n, o, s) => {
|
|
174
|
+
console.log(`类型:${JSON.stringify(n)}`, `报错内容${o}`, "报错信息", s), console.log("直播已结束"), a("loadComplete"), e.autoReload && B();
|
|
175
|
+
}, T = (n) => {
|
|
195
176
|
const o = n.decodedFrames, s = Date.now();
|
|
196
|
-
o ===
|
|
197
|
-
},
|
|
177
|
+
o === m && o !== 0 ? s - h > e.stallTimeout && (console.log(`解码帧数超过 ${e.stallTimeout / 1e3} 秒没有更新,可能卡顿了`), a("playLoading")) : (m = o, h = s);
|
|
178
|
+
}, B = () => {
|
|
198
179
|
console.log("自动加载", l.value), l.value++, l.value <= 2 ? v() : l.value = 0;
|
|
199
180
|
}, v = () => {
|
|
200
|
-
t.value != null && d(),
|
|
201
|
-
},
|
|
181
|
+
t.value != null && d(), L();
|
|
182
|
+
}, N = () => t.value.play(), _ = () => t.value.pause(), d = () => {
|
|
202
183
|
var n, o, s, E;
|
|
203
|
-
t.value && (t.value.off(c.Events.ERROR,
|
|
204
|
-
},
|
|
184
|
+
t.value && (t.value.off(c.Events.ERROR, C), t.value.off(c.Events.LOADING_COMPLETE, b), (n = t.value) == null || n.pause(), (o = t.value) == null || o.unload(), (s = t.value) == null || s.detachMediaElement(), (E = t.value) == null || E.destroy(), t.value = null);
|
|
185
|
+
}, w = async (n) => {
|
|
205
186
|
var o;
|
|
206
187
|
if (!(!((o = n.target) != null && o.paused) || !r.value)) {
|
|
207
188
|
r.value = !1, console.log("handleCanplay", n.target.paused), l.value = 0, u.value = !1;
|
|
@@ -211,64 +192,62 @@ const m = S({
|
|
|
211
192
|
console.log("play error", s), a("loadError", s);
|
|
212
193
|
}
|
|
213
194
|
}
|
|
214
|
-
},
|
|
195
|
+
}, O = () => {
|
|
215
196
|
u.value = !0;
|
|
216
|
-
},
|
|
197
|
+
}, R = (n) => {
|
|
217
198
|
var o;
|
|
218
199
|
a("timeupdate", ((o = n == null ? void 0 : n.target) == null ? void 0 : o.currentTime) ?? 0);
|
|
219
200
|
}, I = () => {
|
|
220
201
|
a("playEnded");
|
|
221
|
-
},
|
|
202
|
+
}, k = () => {
|
|
222
203
|
document.visibilityState === "visible" ? (a("visibilitychange", document.visibilityState), e.autoVisibilityChangeRefresh && v()) : d();
|
|
223
204
|
};
|
|
224
|
-
return
|
|
225
|
-
() =>
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
},
|
|
231
|
-
{ immediate: !0 }
|
|
232
|
-
), G(() => {
|
|
233
|
-
e.closeVisibilityChangeListener || document.addEventListener("visibilitychange", b);
|
|
205
|
+
return U(() => e.videoUrl, (n) => {
|
|
206
|
+
n && G(() => {
|
|
207
|
+
t.value != null && d(), console.log(`isSupported: ${c.isSupported()}`), console.log(`是否支持点播视频:${c.getFeatureList().msePlayback}`), console.log(`是否支持httpflv直播流:${c.getFeatureList().mseLivePlayback}`), L();
|
|
208
|
+
});
|
|
209
|
+
}, {
|
|
210
|
+
immediate: !0
|
|
234
211
|
}), W(() => {
|
|
235
|
-
|
|
212
|
+
e.closeVisibilityChangeListener || document.addEventListener("visibilitychange", k);
|
|
213
|
+
}), J(() => {
|
|
214
|
+
d(), e.closeVisibilityChangeListener || document.removeEventListener("visibilitychange", k);
|
|
236
215
|
}), {
|
|
237
216
|
flvPlayer: t,
|
|
238
217
|
videoContainerRef: i,
|
|
239
218
|
loadMetaData: u,
|
|
240
|
-
start:
|
|
241
|
-
pause:
|
|
219
|
+
start: N,
|
|
220
|
+
pause: _,
|
|
242
221
|
destroy: d,
|
|
243
222
|
reload: v,
|
|
244
|
-
handleCanplay:
|
|
245
|
-
handleLoadedmetadata:
|
|
246
|
-
handleTimeupdate:
|
|
223
|
+
handleCanplay: w,
|
|
224
|
+
handleLoadedmetadata: O,
|
|
225
|
+
handleTimeupdate: R,
|
|
247
226
|
handlePlayEnded: I
|
|
248
227
|
};
|
|
249
228
|
},
|
|
250
229
|
render() {
|
|
251
|
-
return
|
|
252
|
-
"
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
230
|
+
return y("div", {
|
|
231
|
+
class: "mpegts-player-container"
|
|
232
|
+
}, [y("video", {
|
|
233
|
+
class: "mpegts-player-video-container",
|
|
234
|
+
ref: "videoContainerRef",
|
|
235
|
+
muted: !0,
|
|
236
|
+
controls: this.controls,
|
|
237
|
+
onClick: (e) => e.preventDefault(),
|
|
238
|
+
onCanplay: this.handleCanplay,
|
|
239
|
+
onLoadedmetadata: this.handleLoadedmetadata,
|
|
240
|
+
onTimeupdate: this.handleTimeupdate,
|
|
241
|
+
onEnded: this.handlePlayEnded
|
|
242
|
+
}, [q("Your browser is too old which doesn't support HTML5 video.")]), this.loadMetaData && y(ie, {
|
|
243
|
+
class: "mpegts-player-loading"
|
|
244
|
+
}, null)]);
|
|
266
245
|
}
|
|
267
|
-
}),
|
|
246
|
+
}), ce = Object.assign(g, {
|
|
268
247
|
install: (e) => {
|
|
269
|
-
e.component(
|
|
248
|
+
e.component(g.name, g);
|
|
270
249
|
}
|
|
271
250
|
});
|
|
272
251
|
export {
|
|
273
|
-
|
|
252
|
+
ce as default
|
|
274
253
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
.mpegts-player-container{display:block;width:100%;height:100%;margin-left:auto;margin-right:auto;position:relative}.mpegts-player-loading{position:absolute;top:50%;left:50%;margin-top:-20px;margin-left:-20px;font-size:40px;color:rgb(var(--primary-6))}.mpegts-player-video-container{width:100%;height:100%}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linker-design-plus/mpegtsplayer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "A player base on mpegts.js",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -43,6 +43,8 @@
|
|
|
43
43
|
"@types/node": "^18.0.0",
|
|
44
44
|
"rimraf": "^5.0.0",
|
|
45
45
|
"typescript": "^5.0.0",
|
|
46
|
-
"vite": "^4.0.0"
|
|
46
|
+
"vite": "^4.0.0",
|
|
47
|
+
"@vitejs/plugin-vue": "^4.0.0",
|
|
48
|
+
"@vitejs/plugin-vue-jsx": "^3.0.0"
|
|
47
49
|
}
|
|
48
|
-
}
|
|
50
|
+
}
|
package/src/MpegtsPlayer.less
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.
|
|
1
|
+
.mpegts-player-container {
|
|
2
2
|
display: block;
|
|
3
3
|
width: 100%;
|
|
4
4
|
height: 100%;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
position: relative;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
.
|
|
10
|
+
.mpegts-player-loading {
|
|
11
11
|
position: absolute;
|
|
12
12
|
top: 50%;
|
|
13
13
|
left: 50%;
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
color: rgb(var(--primary-6));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
.video-container {
|
|
20
|
+
.mpegts-player-video-container {
|
|
21
21
|
width: 100%;
|
|
22
22
|
height: 100%;
|
|
23
23
|
}
|