android - VideoView與百度Map沖突
問題描述
我在VideoView上面放了一個百度的MapView,如果視頻不播放的話,就是不調用VideoView的start方法,MapView能正常顯示,一旦調用start方法,MapView就會變黑,只顯示比例尺和縮放按鈕。布局文件如下:
<?xml version='1.0' encoding='utf-8'?>
<FrameLayout xmlns:android='http://schemas.android.com/apk/res/android'
android:layout_width='match_parent'android:layout_height='match_parent'><ImageView android: android:layout_width='match_parent' android:layout_height='match_parent' android:background='@drawable/saber'/><com.seawolf.test.FullScreeVideoView android: android:layout_width='match_parent' android:layout_height='match_parent' /><RelativeLayout android:layout_width='match_parent' android:layout_height='match_parent' android:paddingTop='@dimen/activity_vertical_margin'> <TextViewandroid: android:layout_width='wrap_content'android:layout_height='wrap_content'android:layout_gravity='left|center_vertical'android:text='yaw'android:layout_centerVertical='true'android:layout_alignParentStart='true' /> <TextViewandroid: android:layout_width='wrap_content'android:layout_height='wrap_content'android:layout_above='@id/yaw_text'android:text='pitch'/> <TextViewandroid: android:layout_width='wrap_content'android:layout_height='wrap_content'android:text='roll'android:layout_above='@id/pitch_text'/> <com.seawolf.test.NavControllerandroid: android:layout_width='wrap_content'android:layout_height='wrap_content'android:layout_alignParentBottom='true'android:layout_alignParentLeft='true'/> <com.baidu.mapapi.map.MapViewandroid: android:layout_width='120dp'android:layout_height='100dp'android:layout_alignParentBottom='true'android:layout_alignParentEnd='true'android:layout_alignTop='@+id/navController'android:background='@color/white'/></RelativeLayout>
</FrameLayout>
public void init() {back_image = (ImageView) findViewById(R.id.back_image);mController = new MediaController(this);mVideo = (VideoView) findViewById(R.id.video);File video = new File('/storage/sdcard1/hd.mp4');if(video.exists()){ mVideo.setVideoPath(video.getAbsolutePath()); // ① // 設置videoView與mController建立關聯 mVideo.setMediaController(mController); // ② // 設置mController與videoView建立關聯 mController.setMediaPlayer(mVideo); // ③ // 讓VideoView獲取焦點 // mVideo.requestFocus(); mVideo.setVisibility(View.INVISIBLE);}else Toast.makeText(MainActivity.this,'The Video is not exist.',Toast.LENGTH_SHORT).show();mMapView = (MapView) findViewById(R.id.map);mMapView.setVisibility(View.INVISIBLE);navController = (NavController) findViewById(R.id.navController);navController.setVisibility(View.INVISIBLE);navController.setOnNavAndSpeedListener(new NavController.OnNavAndSpeedListener() { @Override public void onNavAndSpeed(float nav, float speed) {Toast.makeText(MainActivity.this, 'nav is ' + nav + ',speed is ' + speed, Toast.LENGTH_SHORT).show(); }}); } private void videoStart() {mVideo.setVisibility(View.VISIBLE);mMapView.setVisibility(View.VISIBLE);navController.setVisibility(View.VISIBLE); // mVideo.start(); }
問題解答
回答1:VideoView和MapView都可以理解為SurfaceView。你可以給VideoView設置:setZOrderMediaOverlay(true);試試
參考:鏈接1鏈接2
相關文章:
1. 百度地圖 - Android app中準備接入地圖sdk,百度VS高德哪個好一點?2. mongoDB批量插入文檔時,運行下面代碼,用MongoVUE查看數據庫,mongo庫中只存在一個文檔?不應該是20個嗎?3. 百度地圖api - Android百度地圖SDK,MapView上層按鈕可見卻不可觸,怎么解決?4. javascript - html5的data屬性怎么指定一個function函數呢?5. css - 小程序canvas環形進度條6. html5 - ajax post請求后如何渲染到頁面上7. javascript - 關于這組數據如何實現 按字母列表分類展示 不改動數據結構8. 前端 - html5 audio不能播放9. html - sumlime text3代碼自動補全功能問題!10. css 選擇器 帶有 readonly 屬性 的<input> 怎么定位呢?
