简体   繁体   English

离子服务器无法从Rails服务器加载视频文件

[英]Ionic server can't load video file from Rails server

I embedded a video in my Ionic app which has a source file on my Rails application, so basically I have this 我在Ionic应用程序中嵌入了一个视频,该视频在Rails应用程序中有一个源文件,所以基本上我有这个

<video width="320" height="240" controls="">
  <source src="http://localhost:3000/uploads/video/video/6/mov_bbb.mp4" type="video/mp4">
</video>

running on this url: http://localhost:8100/#/tab/videos/8 I think it has something to do with the same origin policy, so I've already tried to disable CORS on my Chrome browser starting it with this command: /Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --disable-web-security as well as installing and activating this Chrome plugin, too: https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi . 在此url上运行: http:// localhost:8100 /#/ tab / videos / 8我认为这与相同的原始策略有关,因此我已经尝试在Chrome浏览器中禁用以此为起点的CORS命令: /Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --disable-web-security以及安装和激活此Chrome插件: https : //chrome.google.com/webstore/detail / allow-control-allow-origi / nlfbmbojpeacfghkpbjhddihlkkiljbi It also doesn't work from any other browser which I have installed (Safari and FireFox). 我安装的其他任何浏览器(Safari和FireFox)也无法使用。

Yet, the video file will not load (the video element will just stay empty, also there is no message about a resource failed to load in my console). 但是,视频文件将不会加载(视频元素将保持为空,并且在我的控制台中也没有消息提示资源加载失败)。 How can I make the video load on my localhost:8100 while the video is being served from localhost:3000? 从localhost:3000提供视频时,如何在localhost:8100上加载视频?

It turned out it wasn't a CORS or server issue at all. 事实证明,这根本不是CORS或服务器问题。 Obviously, when working with Ionic, you need to kinda accept that your well known world of HTML has an overlay at the most obscure locations. 显然,与Ionic一起使用时,您需要有点接受,众所周知的HTML世界在最晦涩的地方都有覆盖层。 The issue was that Ionic requires you to use the angular.js src attribute ng-src="path/to/your/file" , making the following work: 问题是Ionic要求您使用angular.js src属性ng-src="path/to/your/file" ,以进行以下工作:

<video width="320" height="240" controls="">
  <source ng-src="http://localhost:3000/uploads/video/video/6/mov_bbb.mp4" type="video/mp4">
</video>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM