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. node.js通过module.exprots返回的是promise对象而非data?2. 使用 CSS3 的 Media Query 浏览器会加载其他不同分辨率的 css 文件么3. “Webdrivers”可执行文件可能具有错误的权限请参阅https://sites.google.com/a/chromium.org/chromedriver/home4. php-_server-php_self - nginx $_SERVER[’PHP_SELF’] 得到重复路径是什么原因?5. 前端 - 类到底该如何去命名 .newsList 这种的命名难道真的不是过度语义化吗?~6. html - 开发android的调取我web页面 他之前用的是收费的浏览器包 显示是全的换了免费的浏览器包后 显示就不全 是什么原因啊7. gulp-ruby-sass编译出来的文件有错8. 关于docker下的nginx压力测试9. javascript - 给js写的盒子添加css样式,css样式没起作用。10. 数据挖掘 - 如何用python实现《多社交网络的影响力最大化问题分析》中的算法?

网公网安备