From 925586f6b18fe05e99d8632a19fad83111d81260 Mon Sep 17 00:00:00 2001 From: 6ea86b96 <6ea86b96@gmail.com> Date: Thu, 27 Apr 2017 14:05:41 +0700 Subject: [PATCH] Playing videos actually working now --- ui/js/actions/content.js | 29 +++++++++++++++++------------ ui/js/component/video/index.js | 5 ++--- ui/js/page/showPage/view.jsx | 2 +- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/ui/js/actions/content.js b/ui/js/actions/content.js index 0cd0d529e..8dad326a9 100644 --- a/ui/js/actions/content.js +++ b/ui/js/actions/content.js @@ -59,7 +59,7 @@ export function doFetchCurrentUriFileInfo() { } }) - lbry.file_list({ outpoint }).then(([fileInfo]) => { + lbry.file_list({ outpoint: outpoint, full_status: true }).then(([fileInfo]) => { dispatch({ type: types.FETCH_FILE_INFO_COMPLETED, data: { @@ -274,17 +274,22 @@ export function doWatchVideo() { const costInfo = selectCurrentUriCostInfo(state) const { cost } = costInfo - // TODO does > 0 mean the file is downloaded? We don't have the total_bytes - if (fileInfo.written_bytes > 0) { - dispatch(doPlayVideo(uri)) - } else { - if (cost > balance) { - dispatch(doOpenModal('notEnoughCredits')) - } else if (cost <= 0.01) { - dispatch(doLoadVideo()) - } else { - dispatch(doOpenModal('affirmPurchase')) - } + // NOTE: we have to check written bytes because a file may be "completed" + // but then deleted on the file system. In which case we are going to need + // to dispatch a load event again to redownload it + if (fileInfo.completed && fileInfo.written_bytes > 0) { + return Promise.resolve() } + + if (cost > balance) { + dispatch(doOpenModal('notEnoughCredits')) + } + else if (cost <= 0.01) { + dispatch(doLoadVideo()) + } else { + dispatch(doOpenModal('affirmPurchase')) + } + + return Promise.resolve() } } diff --git a/ui/js/component/video/index.js b/ui/js/component/video/index.js index 667b7a883..379778930 100644 --- a/ui/js/component/video/index.js +++ b/ui/js/component/video/index.js @@ -26,12 +26,11 @@ const select = (state) => ({ modal: selectCurrentModal(state), isLoading: selectLoadingCurrentUri(state), readyToPlay: selectCurrentUriFileReadyToPlay(state), - isDownloading: ntUri(state), + isDownloading: selectDownloadingCurrentUri(state), }) const perform = (dispatch) => ({ - loadVideo: () => dispatch(doLoadVideo()), - play: () => dispatch(doPlayVideo()), + play: () => dispatch(doLoadVideo()), watchVideo: (elem) => dispatch(doWatchVideo()), closeModal: () => dispatch(doCloseModal()), }) diff --git a/ui/js/page/showPage/view.jsx b/ui/js/page/showPage/view.jsx index 81096317f..8ff3b9ca9 100644 --- a/ui/js/page/showPage/view.jsx +++ b/ui/js/page/showPage/view.jsx @@ -2,7 +2,7 @@ import React from 'react'; import lbry from 'lbry.js'; import lighthouse from 'lighthouse.js'; import lbryuri from 'lbryuri.js'; -import Video from 'page/video' +import Video from 'component/video' import { TruncatedText, Thumbnail,