我想将最新的视频从JW播放器动态加载到我的网站中。
我使用授权密钥从JW播放器获取视频。 (从crome调试工具中获得授权密钥,->检查->网络->列表->标头->授权密钥)它起作用了,视频正在动态加载到我的网站中。问题是,我从标头获得的授权密钥不是永久的,它一直在变化。我联系了JW播放器的支持人员,并得到以下答复:
我听到了回音,我们的团队提到您不应该使用Portal API来获取视频。该API仅由仪表板使用。您应该使用面向公众的Management API的/ videos / list端点。
https://developer.jwplayer.com/jw-platform/reference/v1/methods/videos/list.html https://developer.jwplayer.com/jw-platform/docs/developer-guide/management-api/
<script src="https://content.jwplatform.com/players/E1fkpmxl-2tbS2oZn.js"></script>
<script type="text/javascript">
jQuery(window).load(loadVideoFiles());
function loadVideoFiles(){
var limit = jQuery(".dynamic-video-files").length;
var settings = {
"async": true,
"crossDomain": true,
"url": "https://portal-api.jwplayer.com/v2/proxy/botr/videos/list",
"method": "POST",
"headers": {
"Authorization": "642e5bf0-f91f-11e8-9ab4-620bf832cfd0.DvrH7w.V5dMbyfEFDnVHbx4mMOH6thUxlQ",
"Content-Type": "application/json"
},
"data": "{\"result_offset\":0,\"result_limit\":"+limit +",\"order_by\":\"date:desc\",\"site_token\":\"0e3eaac4-0c08-11e8-998e-0a55b80e2f57\",\"simple\":true}"
}
jQuery.ajax(settings).done(function (response) {
if(response.videos.length <= 0){
return jQuery(".dynamic-video-files").hide();
}
jQuery(".dynamic-video-files").each(function(i){
var file = 'https://content.jwplatform.com/players/'+ response.videos[i].key +'-2tbS2oZn.html';
var str = '<div style="position:relative; padding-bottom:56.25%; overflow:hidden;"><iframe src="'+file+'" width="100%" height="100%" frameborder="0" scrolling="auto" allowfullscreen style="position:absolute;"><\/iframe><\/div>';
jQuery(this).html(str);
});
});
}
</script>