i followed the media api example MediaPlayerDemo_Video.java
Null Eception at setDisplay(holder);
private void playVideo() {
try {
/*
* TODO: Set the path variable to a local media file
path.
*/
path = "/sdcard/intro.mp4";
// Create a new media player and set the listeners
mMediaPlayer = new MediaPlayer();
//mMediaPlayer.setDataSource(path);
mMediaPlayer= MediaPlayer.create(this, R.raw.intro);
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);
}
}
On Thu, Aug 13, 2009 at 5:00 PM, Jack Ha <[email protected]> wrote:
>
> Where did the null exception occur? Stack trace?
>
> --
> Jack Ha
> Open Source Development Center
> ・T・ ・ ・Mobile・ stick together
>
> The views, opinions and statements in this email are those of
> the author solely in their individual capacity, and do not
> necessarily represent those of T-Mobile USA, Inc.
>
>
> On Aug 13, 8:57 am, zeeshan <[email protected]> wrote:
> > yes i already tried it but it gives me null exception
> >
> > On Aug 13, 4:17 pm, zeeshan <[email protected]> wrote:
> >
> > > Hi Dear,
> >
> > > i am trying to play a video in my activity before i load my main page
> > > of my application.
> >
> > > i have created another activity PlayIntro as follows
> >
> > > private void playVideo() {
> > > try {
> >
> > > /*
> > > * TODO: Set the path variable to a local media
> > > file path.
> > > */
> > > path = "/sdcard/intro.mp4";
> >
> > > // Create a new media player and set the listeners
> > > mMediaPlayer = new MediaPlayer();
> > > mMediaPlayer.setDataSource(path);
> > > 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);
> > > }
> > > }
> >
> > > /////////////////////
> >
> > > it does play the video and i call finish(); on completion.
> >
> > > now the problem is :
> > > i have video in my raw folder rather than in my sdcard. how can i load
> > > from raw folder
> >
> >
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---