From e5e4802143f66ef8c7b145c23074a93a371f761f Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Thu, 5 May 2016 08:10:19 -0400 Subject: [PATCH] Add fallback routine to call .load() every 15 seconds if a video fails to load --- js/page/watch.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/page/watch.js b/js/page/watch.js index ed77944d0..4928a84b7 100644 --- a/js/page/watch.js +++ b/js/page/watch.js @@ -18,6 +18,15 @@ var WatchPage = React.createClass({ componentDidMount: function() { lbry.getStream(this.props.name); this.updateLoadStatus(); + setTimeout(() => { this.reloadIfNeeded() }, 15000); + }, + reloadIfNeeded: function() { + // Fallback option for loading problems: every 15 seconds, if the video hasn't reported being + // playable yet, ask it to reload. + if (!this.state.readyToPlay) { + console.log("Trying again"); + this._video.load() + } }, onCanPlay: function() { this.setState({ @@ -39,6 +48,7 @@ var WatchPage = React.createClass({ loadStatusMessage: "Buffering", downloadStarted: true, }); + setTimeout(() => { this.reloadIfNeeded() }, 15000); } }); }, @@ -50,7 +60,7 @@ var WatchPage = React.createClass({ // When the video is actually ready to play, the loading text is hidden and the video shown. var video =