http://stackoverflow.com/questions/9765629/android-videoview-black-screen
播放前黑屏的原因是videoview加载资源需要一定的耗时, 如何避免播放前的黑屏现象呢, 可以给videoview设置加载的监听, 如果加载前给一个遮罩,等资源加载完成后隐藏遮罩.
如果有更好的解决方法,欢迎留言
采用这样解决方案: 需要videoview放到framelayout布局中:
<FrameLayout
android:id="@+id/frameLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_marginTop="50dip" >
<VideoView
android:id="@+id/geoloc_anim"
android:layout_width="fill_parent"
android:layout_height="172dip" android:layout_gravity="top|center" android:visibility="visible"/>
<FrameLayout
android:id="@+id/placeholder"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@drawable/fondvert_anim">
</FrameLayout>
videoview设置监听:
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
//Called when the video is ready to play
View placeholder = findViewById(R.id.placeholder);
placeholder.setVisibility(View.GONE);
}
});