嵌入的 Youtube 视频到 WebView (Appcelerator) 不显示(黑屏) [英] Embeded Youtube video to WebView (Appcelerator) doesn't show (black screen)
本文介绍了嵌入的 Youtube 视频到 WebView (Appcelerator) 不显示(黑屏)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试在我的应用程序(Appcelerator、Android)中显示 YT 视频.我发现最好的方法是在 WebView 中显示嵌入的视频,所以我用这样的代码来做:
I try to show YT video in my application (Appcelerator, Android). I found that the best way is to show embeded video in WebView, so I do it with such code:
var webView = Ti.UI.createWebView({
url: 'https://www.youtube.com/embed/LTRfmqc0KBg',
enableZoomControls: false,
scalesPageToFit: true,
scrollsToTop: false,
showScrollbars: false
});
但视频无法加载(我只看到黑屏 - 而不是 webview 的白色).WebView 正常工作,因为它显示其他页面.
but video does not load (I see only black screen - instead of webview's white). WebView works properly because it shows other pages.
推荐答案
那你可以试试这个
var Win = Titanium.UI.createWindow({
title : 'Video View Demo',
backgroundColor : '#fff'
});
var video_url = 'https://www.youtube.com/watch?v=bSiDLCf5u3s';
var movie = '<html><head></head><body style="margin:0"><embed id="yt" src="' + video_url + '" type="application/x-shockwave-flash" width="480" height="266"></embed></body></html>';
var webView = Ti.UI.createWebView({
top:0,
left:0,
width:480,
height:266,
url:video_url,
html:movie
});
Win.add(webView);
Win.open();
这篇关于嵌入的 Youtube 视频到 WebView (Appcelerator) 不显示(黑屏)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文