当我在4.x中尝试时,播放器加载视频,当我开始播放时,我只看到视频声音.
logcat反复填充Chrome错误消息:
E/chromium(20362): [ERROR:gles2_cmd_decoder.cc(5942)] [.Compositor-Onscreen-0x5db83bb8]GL ERROR :GL_INVALID_OPERATION : gluseProgram: program not linkedE/chromium(20362): [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x5db83bb8]GL ERROR :GL_INVALID_OPERATION : gluniformMatrix4fv: wrong uniform function for typeE/chromium(20362): [ERROR:gles2_cmd_decoder.cc(5718)] [.Compositor-Onscreen-0x5db83bb8]GL ERROR :GL_INVALID_OPERATION : gluniform1iv: wrong uniform function for type
以下是我设置WebVIEw的方法:
this.webvIEw = (WebVIEw) this.findVIEwByID(R.ID.webvIEw);WebSettings settings = this.webvIEw.getSettings();settings.setJavaScriptEnabled(true);settings.setAppCacheEnabled(false);this.webvIEw.setWebChromeClIEnt(new WebChromeClIEnt());...this.webvIEw.loadUrl(ADDRESS_OF_PAGE);
另外,我在清单中启用了硬件加速:
<application ... androID:harDWareAccelerated="true">
这是Js部分:
var player;var VIDEO_ID = "EIsauUfiguE";window.onYouTubeiframeAPIReady = function() { console.log("youtube API ready,loading player"); player = new YT.Player("playeriframe",{ wIDth: "100%",height: "100%",vIDeoID: null,events: { onReady: onPlayerReady,onStateChange: onPlayerStateChange,onPlaybackQualityChange: onPlayerPlaybackQualityChange,onError: onPlayerError },playerVars: { modestbranding: 1,playsinline: 1,fs: 0,showinfo: 0 } });}function onPlayerReady(event) { console.log("player is ready: ",event); playVIDeo();}function onPlayerStateChange(event) { console.log("player state change: ",event);}function onPlayerPlaybackQualityChange(event) { console.log("player playback quality change: ",event);}function onPlayerError(event) { console.log("player error: ",event);}function playVIDeo() { console.log("playing vIDeo: " + VIDEO_ID); player.loadVIDeoByID(VIDEO_ID); player.setPlaybackQuality("medium");}function loadplayer() { console.log("loading youtube API"); var tag = document.createElement("script"); tag.src = "https://www.youtube.com/iframe_API"; var firstScriptTag = document.getElementsByTagname("script")[0]; firstScriptTag.parentNode.insertBefore(tag,firstScriptTag);}loadplayer();
知道它为什么会这样,只在androID 4.x中?
谢谢.
在我研究之后,我只能添加:
>在AndroID 4版本中,无法自动播放.用户必须按播放按钮进入iframe才能开始播放视频.尤其:
>在AndroID 4.1中,它会再现音频而不是图像.
>在AndroID 4.3中,我测试的设备可以重现音频但没有视频和设备无法再现任何东西.
>在AndroID 4.4中不要重现任何东西
>从AndroID 5开始,一切正常.
祝你好运,我加上投票这个问题,知道是否有人可以说明这个问题:)
总结以上是内存溢出为你收集整理的Youtube iframe播放器不会在android 4.x WebView中显示视频全部内容,希望文章能够帮你解决Youtube iframe播放器不会在android 4.x WebView中显示视频所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)