diff --git a/js/page/watch.js b/js/page/watch.js index b145f1a65..642272023 100644 --- a/js/page/watch.js +++ b/js/page/watch.js @@ -2,6 +2,10 @@ import React from 'react'; import lbry from '../lbry.js'; import LoadScreen from '../component/load_screen.js' +const fs = require('fs'); +const VideoStream = require('videostream'); + + var WatchPage = React.createClass({ propTypes: { name: React.PropTypes.string, @@ -22,6 +26,7 @@ var WatchPage = React.createClass({ lbry.getFileStatus(this.props.name, (status) => { if (!status || status.code != 'running' || status.written_bytes == 0) { // Download hasn't started yet, so update status message (if available) then try again + // TODO: Would be nice to check if we have the MOOV before starting playing if (status) { this.setState({ loadStatusMessage: status.message @@ -33,11 +38,17 @@ var WatchPage = React.createClass({ readyToPlay: true, mimeType: status.mime_type, }) - var player = new MediaElementPlayer(this.refs.player, { - mode: 'shim', - plugins: ['flash'], - setDimensions: false, - }); + const mediaFile = { + createReadStream: function (opts) { + // Return a readable stream that provides the bytes + // between offsets "start" and "end" inclusive + console.log('Stream between ' + opts.start + ' and ' + opts.end + '.'); + return fs.createReadStream(status.download_path, opts) + } + } + var elem = this.refs.video; + var videostream = VideoStream(mediaFile, elem); + elem.play(); } }); }, @@ -46,8 +57,7 @@ var WatchPage = React.createClass({ !this.state.readyToPlay ? :
-