Thx!! Your method REALLY work!! On 8月21日, 下午5時51分, Panut Sunyakorn <[email protected]> wrote: > VideoView video = (VideoView) this.findViewById(R.id.VideoViewIntro); > > Uri uri = Uri.parse("android.resource://<your package such as > com.android/" + R.raw.<your video>); > video.setVideoURI(uri); > video.setMediaController(new MediaController(this)); > video.requestFocus(); > video.setOnCompletionListener(this); > video.start(); > > 2009/8/21 Zeeshan Muhammad <[email protected]>: > > > > > > > this might help you > > AssetFileDescriptor afd = getResources().openRawResourceFd(R.raw.video); > > > // Create a new media player and set the listeners > > mMediaPlayer = new MediaPlayer(); > > > mMediaPlayer.setDataSource(afd.getFileDescriptor(), > > afd.getStartOffset(), afd.getLength()); > > > On Fri, Aug 21, 2009 at 4:46 AM, rizwan <[email protected]> wrote: > > >> Hi All, > > >> From weeeks i m trying to play a video file from raw folder .but no > >> success. I have used this code > > >> setContentView(R.layout.mediaplayer_2); > >> mPreview = (SurfaceView) findViewById(R.id.surface); > >> holder = mPreview.getHolder(); > > >> // Create a new media player and set the listeners > >> mMediaPlayer = MediaPlayer.create(this, R.raw.lucky); > >> mMediaPlayer.setDisplay(holder); > >> mMediaPlayer.prepare(); > >> mMediaPlayer.setOnBufferingUpdateListener(this); > >> mMediaPlayer.setOnCompletionListener(this); > >> mMediaPlayer.setOnPreparedListener(this); > >> mMediaPlayer.setAudioStreamType > >> (AudioManager.STREAM_MUSIC); > > >> } catch (Exception e) { > > >> Log.e(TAG, "error: " + e.getMessage(), e); > >> } > > >> } > > >> public void onBufferingUpdate(MediaPlayer arg0, int percent) { > >> Log.d(TAG, "onBufferingUpdate percent:" + percent); > > >> } > > >> public void onCompletion(MediaPlayer arg0) { > >> Log.d(TAG, "onCompletion called"); > > >> } > > >> public void onPrepared(MediaPlayer mediaplayer) { > >> Log.d(TAG, "onPrepared called"); > >> mVideoWidth = mMediaPlayer.getVideoWidth(); > >> mVideoHeight = mMediaPlayer.getVideoHeight(); > >> if (mVideoWidth != 0 && mVideoHeight != 0) { > >> holder.setFixedSize(mVideoWidth, mVideoHeight); > >> mMediaPlayer.start(); > > >> } > > >> while I try to run the above I can hear the audio of video file but no > >> video. please advise . > >> I m trying to playhttp://www.mp4mail.com/docs/files/disney_128v_16a.mp4 > >> (mp4) > >> but having no luck please advise me . > > >> Thanks > >> Rizwan > > -- > > Panut Sunyakorn > 086-334-1616 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

