我发现,嵌入式视频不会在Android上工作,而iOS上做得很好。 但是使用webviews url属性切换窗体来加载视频,以使用setHtml()函数起作用。做到这一点的方法是使用Youtube iframe api。
var videoUrl = 'https://www.youtube.com/embed/' + videoId + '? autoplay=1&autohide=1&cc_load_policy=0&color=white&controls=0&fs=0&iv_load_policy=3&modestbranding=1&rel=0&showinfo=0';
var playerWidth = $.youtubeWebView.width;
var playerHeight = $.youtubeWebView.height;
var html = '<iframe id="player" type="text/html" width="'+playerWidth+'" height="'+playerHeight+'" src="'+videoUrl+'" frameborder="0"></iframe>';
$.youtubeWebView.setHtml(html);
抬起头,I帧可以是一个痛苦,在负载情况下添加此获得在顶部&左侧摆脱了奇怪的白色填充
this.evalJS('document.getElementsByTagName( “本体”)[0] .style.margin = 0;');
事情是这样的:
$.youtubeWebView.addEventListener('load', function(){
this.evalJS('document.getElementsByTagName("body")[0].style.margin=0;');
var showYoutubeTimer = setTimeout(function() {
$.activityIndicator.hide();
$.youtubeWebView.opacity = 1;
clearTimeout(showYoutubeTimer);
}, 300);
});
嗨!你有没有找到这个答案? –