I am trying from hours to play a video file from raw resource but no
success.
I have tried
setContentView(R.layout.mediaplayer_2);
mPreview = (SurfaceView) findViewById(R.id.surface);
holder = mPreview.getHolder();
// Create a new media player and set the listeners
mMediaPlayer = new MediaPlayer() ;
AssetFileDescriptor afd = getResources().openRawResourceFd
(R.raw.lucky);
mMediaPlayer.setDataSource(afd.getFileDescriptor(),
afd.getStartOffset(), afd.getLength());
mMediaPlayer.setDisplay(holder);
// mMediaPlayer.prepare();
mMediaPlayer.setOnBufferingUpdateListener(this);
mMediaPlayer.setOnCompletionListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
nothing happens on the screen and it just stand idle ,neither
OnBuffering event called nor onCompletion Event. I have tried to play
boht wmv and 3gp file. but nothing works . please advise what i m
missing.
On Aug 19, 7:57 am, riz <[email protected]> wrote:
> ok Nelisson , I will ,
> but tell me how can load a movie from resource through media Player or
> any other alternative,please .........
>
> On Aug 18, 9:00 pm, Marco Nelissen <[email protected]> wrote:
>
> > On Tue, Aug 18, 2009 at 12:07 AM,rizwan<[email protected]> wrote:
>
> > > Hi,
>
> > > I m trying to run a simple media player activity ..............
>
> > > public void onCreate(Bundle icicle) {
> > > super.onCreate(icicle);
>
> > > try {
>
> > > /*
> > > * TODO: Set the path variable to a local media
> > > file path.
> > > */
> > > 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();
>
> > That won't work, because MediaPlayer.create() calls prepare()
> > internally, and you can't call prepare() twice.
> > It shouldn't cause a native crash though. Can you file a bug
> > athttp://b.android.com, and attach the file you're trying to play?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---