VideoJS doesn´t play after pause RTMP live stream

徘徊边缘 提交于 2019-12-05 01:28:28

问题


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>

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

EDIT: 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>

回答1:


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();
};

it should be changed to say:

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

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



来源:https://stackoverflow.com/questions/25446868/videojs-doesn%c2%b4t-play-after-pause-rtmp-live-stream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!