Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 尝试从Node.js以Angular格式流式传输视频_Javascript_Node.js_Angular_Typescript_Express - Fatal编程技术网

Javascript 尝试从Node.js以Angular格式流式传输视频

Javascript 尝试从Node.js以Angular格式流式传输视频,javascript,node.js,angular,typescript,express,Javascript,Node.js,Angular,Typescript,Express,我正在从Node.js/Express.js向我的Angular前端应用程序发送视频。数据正在分块发送,我想在Angular应用程序中播放视频。不幸的是,有些东西似乎不起作用。 谁能告诉我我做错了什么 Courses.Component.html Node.js 视频根本没有播放。我在网上搜索了很多,但找不到任何帮助。 如果有人能帮忙,我将不胜感激。 谢谢编辑此文件以便任何人都能提供帮助 <div class="video-player-wrapper">

我正在从Node.js/Express.js向我的Angular前端应用程序发送视频。数据正在分块发送,我想在Angular应用程序中播放视频。不幸的是,有些东西似乎不起作用。 谁能告诉我我做错了什么

Courses.Component.html

Node.js

视频根本没有播放。我在网上搜索了很多,但找不到任何帮助。 如果有人能帮忙,我将不胜感激。 谢谢编辑此文件以便任何人都能提供帮助

  <div class="video-player-wrapper">

  <video id = "videoPlayer" controls preload = "metadata" style = "width: 65%; position: fixed; 
   border: 2px solid #7c2c6c;">
   
        <source [attr.src]="courseVideo" autoplay type = "video/mp4">
  
  </video>

  </div>
const params = new HttpParams().set('id', this.findcourseservice.getUserSelected()).set('id2', 
this.courseContent).set('id3', courseToPlay);

this.http.get('http://localhost:3000/playVideo', {params, responseType: "blob"})
.subscribe(response => {
  const reader = new FileReader();
  this.courseVideo = reader.readAsArrayBuffer(response);
})
router.get('/playVideo', (req, res) => {

const viewCourse = req.query.id;
const viewSubCourse = req.query.id2;
const videoLink = req.query.id3;

const path = `D:/Videos/${viewCourse}/${viewSubCourse}/${videoLink}`;
const stat = fs.statSync(path);
const fileSize = stat.size;

const head = {
  'Content-Length': fileSize,
  'Accept-Ranges' : 'bytes',
  'Content-Type': 'video/mp4'
}

res.writeHead(200, head);
fs.createReadStream(path).pipe(res);
});