diff --git a/ui/js/component/video/internal/loading-screen.jsx b/ui/js/component/video/internal/loading-screen.jsx index e7974c986..06dd7ff6b 100644 --- a/ui/js/component/video/internal/loading-screen.jsx +++ b/ui/js/component/video/internal/loading-screen.jsx @@ -4,7 +4,7 @@ const LoadingScreen = ({ statusMessage }) =>
-
+
{statusMessage}
; diff --git a/ui/js/component/video/internal/play-button.jsx b/ui/js/component/video/internal/play-button.jsx new file mode 100644 index 000000000..5eb98726f --- /dev/null +++ b/ui/js/component/video/internal/play-button.jsx @@ -0,0 +1,93 @@ +import React from "react"; +import FilePrice from "component/filePrice"; +import Link from "component/link"; +import Modal from "component/modal"; + +class VideoPlayButton extends React.Component { + onPurchaseConfirmed() { + this.props.closeModal(); + this.props.startPlaying(); + this.props.loadVideo(this.props.uri); + } + + onWatchClick() { + this.props.purchaseUri(this.props.uri).then(() => { + if (!this.props.modal) { + this.props.startPlaying(); + } + }); + } + + render() { + const { + button, + label, + className, + metadata, + metadata: { title }, + uri, + modal, + closeModal, + isLoading, + costInfo, + fileInfo, + mediaType, + } = this.props; + + /* + title={ + isLoading ? "Video is Loading" : + !costInfo ? "Waiting on cost info..." : + fileInfo === undefined ? "Waiting on file info..." : "" + } + */ + + const disabled = + isLoading || + fileInfo === undefined || + (fileInfo === null && (!costInfo || costInfo.cost === undefined)); + const icon = ["audio", "video"].indexOf(mediaType) !== -1 + ? "icon-play" + : "icon-folder-o"; + + return ( +
+ + + {__("You don't have enough LBRY credits to pay for this stream.")} + + + {__("This will purchase")} {title} {__("for")} + {" "} + {" "}{__("credits")}. + + + {__("Sorry, your download timed out :(")} + +
+ ); + } +} + +export default VideoPlayButton; diff --git a/ui/js/component/video/internal/player.jsx b/ui/js/component/video/internal/player.jsx new file mode 100644 index 000000000..f6416b5f9 --- /dev/null +++ b/ui/js/component/video/internal/player.jsx @@ -0,0 +1,36 @@ +import React from "react"; +import { Thumbnail } from "component/common"; +import player from "render-media"; +import fs from "fs"; +// const from = require("from2"); + +class VideoPlayer extends React.Component { + componentDidMount() { + const elem = this.refs.media; + const { downloadPath, filename } = this.props; + const file = { + name: filename, + createReadStream: opts => { + return fs.createReadStream(downloadPath, opts); + }, + }; + player.append(file, elem, { + autoplay: true, + controls: true, + }); + } + + render() { + const { downloadPath, mediaType, poster } = this.props; + + return ( +
+ {["audio", "application"].indexOf(mediaType) !== -1 && + } +
+
+ ); + } +} + +export default VideoPlayer; diff --git a/ui/js/component/video/view.jsx b/ui/js/component/video/view.jsx index 95c306cb0..ec2468dd9 100644 --- a/ui/js/component/video/view.jsx +++ b/ui/js/component/video/view.jsx @@ -1,98 +1,9 @@ import React from "react"; -import FilePrice from "component/filePrice"; -import Link from "component/link"; -import Modal from "component/modal"; import lbry from "lbry"; -import { Thumbnail } from "component/common"; +import VideoPlayer from "./internal/player"; +import VideoPlayButton from "./internal/play-button"; import LoadingScreen from "./internal/loading-screen"; -class VideoPlayButton extends React.Component { - onPurchaseConfirmed() { - this.props.closeModal(); - this.props.startPlaying(); - this.props.loadVideo(this.props.uri); - } - - onWatchClick() { - this.props.purchaseUri(this.props.uri).then(() => { - if (!this.props.modal) { - this.props.startPlaying(); - } - }); - } - - render() { - const { - button, - label, - className, - metadata, - metadata: { title }, - uri, - modal, - closeModal, - isLoading, - costInfo, - fileInfo, - mediaType, - } = this.props; - - /* - title={ - isLoading ? "Video is Loading" : - !costInfo ? "Waiting on cost info..." : - fileInfo === undefined ? "Waiting on file info..." : "" - } - */ - - const disabled = - isLoading || - fileInfo === undefined || - (fileInfo === null && (!costInfo || costInfo.cost === undefined)); - const icon = ["audio", "video"].indexOf(mediaType) !== -1 - ? "icon-play" - : "icon-folder-o"; - - return ( -
- - - {__("You don't have enough LBRY credits to pay for this stream.")} - - - {__("This will purchase")} {title} {__("for")} - {" "} - {" "}{__("credits")}. - - - {__("Sorry, your download timed out :(")} - -
- ); - } -} - class Video extends React.Component { constructor(props) { super(props); @@ -175,37 +86,4 @@ class Video extends React.Component { } } -const from = require("from2"); -const player = require("render-media"); -const fs = require("fs"); - -class VideoPlayer extends React.Component { - componentDidMount() { - const elem = this.refs.media; - const { downloadPath, filename } = this.props; - const file = { - name: filename, - createReadStream: opts => { - return fs.createReadStream(downloadPath, opts); - }, - }; - player.append(file, elem, { - autoplay: true, - controls: true, - }); - } - - render() { - const { downloadPath, mediaType, poster } = this.props; - - return ( -
- {["audio", "application"].indexOf(mediaType) !== -1 && - } -
-
- ); - } -} - export default Video; diff --git a/ui/scss/component/_video.scss b/ui/scss/component/_video.scss index 752c394d1..b854763fc 100644 --- a/ui/scss/component/_video.scss +++ b/ui/scss/component/_video.scss @@ -45,6 +45,10 @@ video { to { transform: rotate(-360deg) } } } + + .video--loading--status { + color: white; + } } .plyr {