如何在Cordova iOS应用程序中播放html 5视频? [英] How to play an html 5 video in Cordova iOS app?

查看:198
本文介绍了如何在Cordova iOS应用程序中播放html 5视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在iOS上的CORDOVA应用程式中,在html5网页播放小mp4影片



可以播放本地mp4,但我可以播放存储在远程服务器上的视频。我不知道为什么。



=>是否有任何配置选项或元素添加到我的html页面,以在CORDOVA iOS应用程序中播放远程视频?请参阅我的代码:



cordova中的HTML页面:

 <!doctype html>< html lang =en> ; < head> < meta charset =utf-8> < title> TEST< / title> < meta http-equiv =Content-Typecontent =text / html; charset = utf-8/> < meta http-equiv =Content-Security-Policycontent =default-src *; style-src'self''unsafe-inline'; script-src'self''unsafe-inline''unsafe-eval' > < script src =cordova.js>< / script> < / head> < body> < h1> TEST APP< / h1> < video width =320height =240controls webkit-playsinline> < source src =http://video.tsara-autisme.com/test/010101_360p.mp4type =video / mp4>您的浏览器不支持视频标记。 < / video> < img src =http://video.tsara-autisme.com/test/test.jpgalt =test> < / body>< / html>  



<档案:

  ... 
< access origin =*/> ;
< allow-navigation href =https://api.tsara-autisme.com/*/>
< allow-navigation href =http://video.tsara-autisme.com/*/>
< allow-intent href =http:// * / */>
< allow-intent href =https:// * / */>
< preference name =Fullscreenvalue =true/>
< preference name =AllowInlineMediaPlaybackvalue =true/>
...

感谢您的帮助。
配置:Cordova 5.1.1,Xcode 7.2,iOS模拟器9,iPhone上的iOS 9

解决方案

Content-Security-Policy中的媒体来源:

 < meta http-equiv =Content-Security-Policy =default-src *; media-src *; style-src'self''unsafe-inline'; script-src'self''unsafe-inline''unsafe-eval'> 

有关Content-Security-Policy的更多信息,请访问 http://content-security-policy.com



使用Content-安全政策,允许一切都不是一个好主意。


I want to play a little mp4 video in an html5 page in my CORDOVA App on iOS.

Local mp4 can be played but I can play video stored on remote server. I dont know why.

=> Is there any config options or element to add to my html page for playing a remote video in CORDOVA iOS app ? See my code here :

HTML page in cordova :

<!doctype html><html lang="en">
   <head>
      <meta charset="utf-8">
      <title>TEST</title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
      <script src="cordova.js"></script>
   </head>
   <body>
      <h1>TEST APP</h1>
      <video width="320" height="240" controls webkit-playsinline>
         <source src="http://video.tsara-autisme.com/test/010101_360p.mp4" type="video/mp4">
         Your browser does not support the video tag.
      </video>
      <img src="http://video.tsara-autisme.com/test/test.jpg" alt="test"> 
   </body>
</html>

Config.xml file :

...
<access origin="*"/>
<allow-navigation href="https://api.tsara-autisme.com/*"/>
<allow-navigation href="http://video.tsara-autisme.com/*"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<preference name="Fullscreen" value="true" />
<preference name="AllowInlineMediaPlayback" value="true"/>
...

Thanks for help. Config : Cordova 5.1.1, Xcode 7.2, iOS Simulator 9, iOS 9 on iphone

解决方案

Try to add the media source in your Content-Security-Policy:

  <meta http-equiv="Content-Security-Policy" content="default-src *; media-src *;style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">

You find more infos about Content-Security-Policy at http://content-security-policy.com

Be careful by using the Content-Security-Policy, it is not a good idea to allow everything.

这篇关于如何在Cordova iOS应用程序中播放html 5视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆