未显示将Youtube视频嵌入到WebView(Appcelerator)中(黑屏) [英] Embeded Youtube video to WebView (Appcelerator) doesn't show (black screen)

查看:104
本文介绍了未显示将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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆