我正在尝试播放直播视频(例如来自Ustream的ISS实时视频)。就那么简单。我尝试使用YouTube,但这太复杂了,这意味着我必须获得YouTube API等等。代码对我有用,但只有一个问题:我需要它启用自动播放,但它不起作用。有关如何做到这一点的任何想法?完整代码如下。
package com.splash.net.splashnet;
import android.graphics.Point;
import android.os.Bundle;
import android.app.Activity;
import android.view.Display;
import android.webkit.WebView;
public class Splash extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
WebView webView;
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
webView = (WebView)findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("file:///android_asset/isslive.html");
}
}
...和HTML文件......
<html>
<head>
<meta name = "viewport" content = "width = device-width, height = device-height" />
<style>
iframe {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<iframe src="http://www.ustream.tv/embed/17074538?v=3&wmode=direct&autoplay=true"
style="border: 0 none transparent;"
frameborder="no"></iframe><br />
</body>
</html>
我也试过不同的网址以防万一...
http://www.ustream.tv/embed/17074538
http://www.ustream.tv/embed/17074538?html5ui
http://www.ustream.tv/embed/17074538?wmode=direct
http://www.ustream.tv/embed/17074538?html5ui?wmode=direct
http://www.ustream.tv/embed/17074538?html5ui=1&autoplay=true
我想要的只是点击图标并获得实时Feed。我正在研究API 19(KitKat)。欢迎任何有关此事的信息或其他批准。再次感谢!
答案 0 :(得分:0)
尝试将这些属性添加到iframe:
<iframe webkitAllowFullScreen mozallowfullscreen allowFullScreen ...>
答案 1 :(得分:0)
webView.getSettings().setMediaPlaybackRequiresUserGesture(false);
尝试将此行添加到WebView
还有你的iframe
http://www.ustream.tv/embed/17074538?html5ui=1&autoplay=true"