您好我为我的视频网站创建了一个 WebView 应用程序。该网站的设计是为移动用户加载的混合体。只有与移动设备兼容的视频才会加载到混合设备上。播放器来自 Vk、DailyMotion、YouTube 和 QuickTime。
视频只能在 SDK 11 及更高版本上播放,但是当我单击播放器按钮进入全屏模式时,它只会停止播放视频,而永远不会进入全屏模式。
(Webviewactivity.java)
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.main);
parentView = (RelativeLayout) findViewById(R.id.parent_rl);
webviewProgress = (ProgressBar) findViewById(R.id.webview_progress);
webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.getSettings().setAllowFileAccess(true);
webview.setWebViewClient(new MyWebViewClient());
webview.getSettings().setPluginState(WebSettings.PluginState.ON);
webview.loadUrl(URL);
webviewProgress.setProgress(0);
webview.setWebChromeClient(new MyWebChromeClient());
webview.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
mProgressDialog = new ProgressDialog(WebViewActivity.this);
mProgressDialog.setMessage("Downloading...");
mProgressDialog.setIndeterminate(false);
mProgressDialog.setMax(100);
mProgressDialog
.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
DownloadFile downloadFile = new DownloadFile();
downloadFile.execute(url);
}
});
initSlider();
initAdmob();
}
/**
* When when file was chosen
*/
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
if (requestCode == FILECHOOSER_RESULTCODE) {
if (null == mUploadMessage)
return;
Uri result = intent == null || resultCode != RESULT_OK ? null
: intent.getData();
mUploadMessage.onReceiveValue(result);
mUploadMessage = null;
(主.xml)
android:id="@+id/parent_rl"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:keepScreenOn="true" >
<ProgressBar
android:id="@+id/webview_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:maxHeight="5dip"
android:minHeight="5dip"
android:progressDrawable="@drawable/blueprogress" />
<FrameLayout
android:id="@+id/framelayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/webview_progress"
android:orientation="vertical" >
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
(清单.xml)
package="com.wCHfree"
android:versionCode="7"
android:versionName="1.1" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher_red"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black" >
<activity
android:name="com.webview.splashScreen.SplashScreenActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.webview.splashScreen.WebViewActivity"
android:configChanges="orientation|screenSize|screenLayout"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />