diff --git a/js/page/watch.js b/js/page/watch.js
index e9b3a9185..18bbb97c2 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 || !['running', 'stopped'].includes(status.code) || 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
?
:
-
);
diff --git a/package.json b/package.json
index ff5a89af2..d9d719fc7 100644
--- a/package.json
+++ b/package.json
@@ -27,7 +27,8 @@
"node-sass": "^3.8.0",
"react": "^15.4.0",
"react-dom": "^15.4.0",
- "react-modal": "^1.5.2"
+ "react-modal": "^1.5.2",
+ "videostream": "^2.4.2"
},
"devDependencies": {
"babel": "^6.5.2",
@@ -45,6 +46,7 @@
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.7.1",
"node-sass": "^3.13.0",
- "webpack": "^1.13.3"
+ "webpack": "^1.13.3",
+ "webpack-target-electron-renderer": "^0.4.0"
}
}
diff --git a/webpack.config.js b/webpack.config.js
index 03ccc2372..bdfd83191 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -33,5 +33,6 @@ module.exports = {
}
}
]
- }
+ },
+ target: 'electron-main',
};