http://stackoverflow.com/questions/9765629/android-videoview-black-screen
播放前黑屏的原因是videoview加載資源需要一定的耗時, 如何避免播放前的黑屏現象呢, 可以給videoview設置加載的監聽, 如果加載前給一個遮罩,等資源加載完成后隱藏遮罩.
如果有更好的解決方法,歡迎留言
采用這樣解決方案: 需要videoview放到framelayout布局中:
android:id="@+id/frameLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_marginTop="50dip" >
android:id="@+id/geoloc_anim"
android:layout_width="fill_parent"
android:layout_height="172dip" android:layout_gravity="top|center" android:visibility="visible"/>
android:id="@+id/placeholder"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@drawable/fondvert_anim">
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);
}
});