Hi, A surprising problem occurs when I try to play Video, I can only hear the sound part of the video. My code snippet is below:
public class VideoDemo extends Activity { public static final int MENU_PLAYER=Menu.FIRST; public static final int MENU_VIDEO=MENU_PLAYER+1; private final static String VIDEOURL="/sdcard/10-58-26.3gp"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // playVideoByVideoView(VIDEOURL); } private void playVideoByVideoView(String fileURL){ // this.getWindow().setFormat(PixelFormat.TRANSLUCENT); setContentView(R.layout.videoview); VideoView videoView=(VideoView)findViewById(R.id.surface_view); // videoView.setVisibility(SurfaceView.VISIBLE); videoView.bringToFront(); videoView.setVideoPath(fileURL); videoView.setMediaController(new MediaController(this)); videoView.requestFocus(); // videoView.start(); } private void playVideoByMediaPlayer(String fileURL){ MediaPlayer mp = new MediaPlayer(); SurfaceView sv =new SurfaceView(this); try { mp.setDataSource(fileURL); mp.setDisplay(sv.getHolder()); mp.prepare(); mp.start(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); mp.release(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); mp.release(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); mp.release(); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // TODO Auto-generated method stub boolean ret= super.onCreateOptionsMenu(menu); menu.add(0, MENU_PLAYER, 0, "MediaPlayer"); menu.add(0, MENU_VIDEO, 0, "VideoView"); return ret; } @Override public boolean onMenuItemSelected(int featureId, MenuItem item) { // TODO Auto-generated method stub boolean ret= super.onMenuItemSelected(featureId, item); switch(item.getItemId()){ case MENU_PLAYER: playVideoByMediaPlayer(VIDEOURL); break; case MENU_VIDEO: playVideoByVideoView(VIDEOURL); break; } return ret; } } But when I invoke playVideoByVideoView() method in onCreate() ,I can see the video part. Can anybody tell me why this problem happen? How can I solve this problem. Thanks Very Much! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---