暂停RTMP直播后,VideoJS无法播放 [英] VideoJS doesn´t play after pause RTMP live stream

查看:4152
本文介绍了暂停RTMP直播后,VideoJS无法播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VideoJS从Wowza服务器获取实时流,但是当我暂停播放器并且我再次播放时,播放器无法恢复流。我需要重新加载网页才能再次开始播放。

I´m using VideoJS for a live stream from Wowza server but when I pause the player and them I play again the player does not recover the stream. I need to reload the webpage to start the stream again.

<video id="videoID" class="video-js vjs-default-skin vjs-big-play-centered" poster="/images/image.png"  controls="controls" width="320" height="240" data-setup='{"techOrder": ["flash"]}'>
<source src="rtmp://www.myhost.com:1935/live/live.stream" type="rtmp/mp4" />
</video>

当暂停事件出现时,有什么方法可以停止或重新加载VideoJS吗?

There are any method to do stop or VideoJS reload when the paused event appear?

编辑:我使用此脚本遇到了解决方案:

I've encountered the solution using this script:

<script type="text/javascript">
var myPlayer = videojs('videoID');
videojs("videoID").ready(function(){
var myPlayer = this;
myPlayer.on("pause", function () {
myPlayer.on("play", function () { myPlayer.load (); myPlayer.off("play"); });
});
});
</script>


推荐答案

好的,我找到了解决方案。您不需要从播放器中剥离所有播放事件,而是需要在7337行(我认为版本为4.11.4)中编辑video.dev.js中的flash播放事件。这条线说:

Ok so i found a solution. Instead of stripping all of the play events form the player you actually just need to edit the flash play event inside of video.dev.js on line 7337 (in version 4.11.4 i think). this is the line that says:

vjs.Flash.prototype.play = function(){
    this.el_.vjs_play();
};

应更改为:

vjs.Flash.prototype.play = function(){
    this.el_.vjs_load();
    this.el_.vjs_play();
};

以便在播放事件之前调用load事件。

so that the load event is called before the play event.

这篇关于暂停RTMP直播后,VideoJS无法播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆