jw player学习笔记----跨域请求

需求来源:播放器皮肤文件请求不到,被限制了。


参考官网解决方案:

http://www.longtailvideo.com/support/jw-player/28844/crossdomain-file-loading


一、FLASH跨域

在你的资源web服务器上的根目录下,新建crossdomain.xml文件,

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
   <allow-access-from domain="*.xx.com"/>
</cross-domain-policy>

具体参数含义以及更细化的配置,可以参考

http://blog.sina.com.cn/s/blog_6d8842390101g1cp.html


二、js跨域----CORS方式

还未做好。


个人心得,尽量选用flash方式,这样比较简单,方便配置和控制。

可以通过设置primary参数,实现各个浏览器统一。如果不设置,默认会在最新浏览器中,采用HTML5的方式。就得同时做2种方案了。

<script type="text/javascript">
jwplayer("container").setup({
file: "http://xx.com/jwplayer/uploads/test.mp4",
image: "http://xx.com/jwplayer/uploads/snapshot.jpg",
skin:"http://xx.com/jwplayer/skins/six.xml",
repeat: 'true',
primary: 'flash',
title:"来自xx的视频"
});
</script>

原文地址:https://www.cnblogs.com/ycpanda/p/3637219.html