【发布时间】:2020-03-26 18:57:47
【问题描述】:
我想将视频添加到 node.js 服务器,但是当我将它加载到服务器时,控件无法运行,为什么? (请尽量减少代码...以便理解)
//html5 video loading
<video width="320" height="240" controls>
<source src="cat.mp4" type="video/mp4">
</video>
//未加载
<video width="320" height="240" controls>
<source src="http://localhost:8080" type="video/mp4">
</video>
//my node js code is
var http = require ("http");
var fs = require ("fs");
var server = http.createServer(function(req,res)
{
console.log ('request was made:'+req.url);
res.writeHead(200,{'Content-Type':'text/html'});
var myReadStream = fs.createReadStream(__dirname+ '/index.html','utf8');
myReadStream.pipe(res);
});
server.listen(8080,'127.0.0.1');
console.log('YO BOSS');
【问题讨论】:
-
我在考虑 video.js 是否可行?
-
Video.js的使用与否与这里的问题无关。
标签: javascript node.js server video-streaming html5-video