this is my layout :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/frameLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center" >
<VideoView
android:id="@+id/geoloc_anim"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="top|center"
android:visibility="visible" />
<FrameLayout
android:id="@+id/placeholder"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</FrameLayout>
</FrameLayout>
</LinearLayout>
this is my activity code:
public class MainActivity extends ActionBarActivity implements OnPreparedListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().hide();
VideoView mVideoView = (VideoView) findViewById(R.id.videoview);
Uri uri = Uri.parse("android.resource://" + getPackageName()+"/raw/lst2");
mVideoView.setVideoURI(uri);
mVideoView.requestFocus();
mVideoView.setZOrderOnTop(true);
mVideoView.start();
}
@Override
public void onPrepared(MediaPlayer mp) {
mp.setOnInfoListener(new MediaPlayer.OnInfoListener() {
@Override
public boolean onInfo(MediaPlayer mp, int what, int extra) {
View placeholder = (View) findViewById(R.id.placeholder);
if (what == MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START) {
// video started; hide the placeholder.
placeholder.setVisibility(View.GONE);
return true;
}
return false;
}
});
}
public void surfaceChanged(SurfaceHolder holder, int format, int width,int height) {
}
public void surfaceCreated(SurfaceHolder holder) {
}
public void surfaceDestroyed(SurfaceHolder holder) {
}
}
It works fine on android 4.2 but it doesn't work properly on android 2.3 . on android 2.3 , the first time it opens it works find but when close the app and open it again ,a black screen comes , something like this :
and after one minute or so , it goes from a black screen to a white screen but still nothing plays .
Could you help me to solve this problem ?