|
@@ -58,6 +58,7 @@ export default {
|
|
|
error: false,
|
|
|
message: "",
|
|
|
},
|
|
|
+ lastDecodedFrames: 0,
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
@@ -75,7 +76,13 @@ export default {
|
|
|
methods: {
|
|
|
initVideo() {
|
|
|
if (!this.liveUrl) return;
|
|
|
- if (!flvjs.isSupported()) return;
|
|
|
+ if (!flvjs.isSupported()) {
|
|
|
+ this.result = {
|
|
|
+ error: true,
|
|
|
+ message: "不支持播放",
|
|
|
+ };
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.loading = true;
|
|
|
|
|
|
this.flvPlayer = flvjs.createPlayer(
|
|
@@ -96,8 +103,26 @@ export default {
|
|
|
this.flvPlayer.on(flvjs.Events.ERROR, this.playError);
|
|
|
this.flvPlayer.on(flvjs.Events.METADATA_ARRIVED, () => {
|
|
|
this.loading = false;
|
|
|
+ console.log("正常播放");
|
|
|
this.retryCount = 0;
|
|
|
});
|
|
|
+ this.flvPlayer.on(
|
|
|
+ flvjs.Events.STATISTICS_INFO,
|
|
|
+ this.statisticsInfoEventHandle
|
|
|
+ );
|
|
|
+ },
|
|
|
+ statisticsInfoEventHandle(res) {
|
|
|
+ if (this.lastDecodedFrames === 0) {
|
|
|
+ this.lastDecodedFrames = res.decodedFrames;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.lastDecodedFrames !== res.decodedFrames) {
|
|
|
+ this.lastDecodedFrames = res.decodedFrames;
|
|
|
+ } else {
|
|
|
+ this.lastDecodedFrames = 0;
|
|
|
+ console.log("卡住了,准备重试!");
|
|
|
+ this.retryPlay();
|
|
|
+ }
|
|
|
},
|
|
|
playError(errorType) {
|
|
|
switch (errorType) {
|