here's the code try clicking that will trigger dial number, and then push back button, and you will see the video screen disappeared but the sound is playing thx :D
public class VideoTest extends Activity { private VideoPlayer mVideoPlayer; private String mFile = "/sdcard/Airplane.3gp"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FrameLayout mainLayout = new FrameLayout(this); mainLayout.setLayoutParams(new FrameLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); // set to dial number mainLayout.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent dialIntent = new Intent(Intent.ACTION_DIAL, Uri .parse("tel:12345")); startActivity(dialIntent); } }); // surface view for video screen SurfaceView videoSurface = new SurfaceView(this); videoSurface.setLayoutParams(new LayoutParams (LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); mainLayout.addView(videoSurface); mVideoPlayer = new VideoPlayer(videoSurface, mFile); setContentView(mainLayout); } @Override protected void onResume() { super.onResume(); mVideoPlayer.Start(); } @Override protected void onStop() { super.onStop(); mVideoPlayer.Pause(); } private class VideoPlayer implements MediaPlayer.OnPreparedListener, SurfaceHolder.Callback { private MediaPlayer mMediaPlayer; private String mVideoFile; private SurfaceHolder mHolder; public VideoPlayer(final SurfaceView surfaceView, final String file) { mHolder = surfaceView.getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); mHolder.setSizeFromLayout(); mVideoFile = file; } public void Start() { if (mMediaPlayer != null) mMediaPlayer.start(); } public void Pause() { if (mMediaPlayer != null) mMediaPlayer.pause(); } public void onPrepared(MediaPlayer mp) { mVideoPlayer.Start(); } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { } public void surfaceCreated(SurfaceHolder holder) { // to prevent recreating media player if (mMediaPlayer == null) { mMediaPlayer = new MediaPlayer(); try { mMediaPlayer.setDataSource(mVideoFile); mMediaPlayer.setDisplay(mHolder); mMediaPlayer.prepare(); mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); } catch (Exception e) { } } } public void surfaceDestroyed(SurfaceHolder holder) { } public void onBufferingUpdate(MediaPlayer mp, int percent) { } } } On Jul 27, 10:40 pm, Mark Murphy <mmur...@commonsware.com> wrote: > sleith wrote: > > any idea? > > Is this hardware or the emulator? > > If it is the emulator, can you reproduce the problem on a device? > > -- > Mark Murphy (a Commons > Guy)http://commonsware.com|http://twitter.com/commonsguy > > _Android Programming Tutorials_ Version 1.0 In Print! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---