As you can see in the next link: https://www.dropbox.com/s/5qdu28byz0luxyu/Screenshot.png?dl=0
It's only shown a part of my SurfaceView. I have defined SurfaceView like next xml:
<RelativeLayout
android:id="@+id/rel_page0"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true" >
<SurfaceView
android:id="@+id/video0_0p"
android:layout_width="fill_parent"
android:layout_height="470dp"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"/>
...
My java code to make it works is:
sv.getHolder().addCallback(new Callback() {
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
mediaPlayer.release();
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
mediaPlayer.setVolume(0, 0);
playVideoDelay(mediaPlayer, sv, path);
}
@Override
public void surfaceChanged(SurfaceHolder holder,
int format, int width, int height) {
}
});
//The method called is:
private void playVideoDelay(final MediaPlayer videoView,
final SurfaceView sv, Uri uri) {
try {
videoView.setDataSource(getActivity().getApplicationContext(), uri);
sv.getHolder().setFormat(PixelFormat.OPAQUE);
videoView.setDisplay(sv.getHolder());
videoView.prepare();
if (Build.VERSION.SDK_INT >= 16)
videoView
.setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING);
if (currentPositionVid > 0) {
videoView.seekTo(currentPositionVid);
}
videoView.start();
} catch (Exception e) {
e.printStackTrace();
}
}
It works in my old tablet Samsung Galaxy 10.1, but in my tablet bq Edison 3 it works bad (as you see in the previous link).
Finally, by reading a lot of posts, Android documentation and other stuff; I understood that when you use more than two layers in Adroid (each layer can be composed by images, buttons, views, SurfaceView or another advance graphic component as my case), you have to be careful because of the android render sometimes doesn't know the weight of each layer and the right order with some elements.
So in my case, I tried to show a SurfaceView (with some buttons and images over it) over a layer with a background, with some imagebuttons over them,etc. Sometimes the layer was well painted but sometimes not. Actually the problem was really difficult to solve in the layer behaviour form, so I re-built all interface by putting all the buttons and the images outside the SurfaceView.
https://www.dropbox.com/s/pb7hn32cx9y2eak/Screenshot_2015-01-12-14-21-29.png?dl=0
Hope it helps! Regards