Hello Jeremy,
    Thanks for the Immediate Reply.
    I've used that solution.The File is playing well. My problem is
whatever button i've clicked the song plays from the alphabetical
order from assets. I can not call a specific file at runtime that's
why i'm struggling.

On Sep 27, 1:38 am, Jeremy Dagorn <jeremy.dag...@gmail.com> wrote:
> Hi,
>
> So with the link describing someone with the same issue, there is a
> kind of solution by calling different methods in the catch for the
> IllegalStateException.
>
> Did you try it?
>
> On Sep 26, 3:58 am, julious raj <julious...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hello developers,
> >    I am facing one big issue with my application. AFAIK the
> > mediaplayer datasource should be Uri(or) FileDescriptor(or) Path. I
> > have loaded my Files to assets. So i used FileDescriptor as datasource
> > for my player. My problem is whenever i try to play any file the first
> > file from assets played. It doesnot respond to the input i've given. I
> > am new to Android development.I am googling it but does not find a
> > better answer.
> > I also faced the issue in the below 
> > link.http://code.google.com/p/android/issues/detail?id=957
>
> > Thanks in advance for Spending your valuable time.
>
> > My code is Below:
> >         player = new MediaPlayer();
> >         playnext = (Button)findViewById(R.id.button2);
> >         seekplay = (SeekBar)findViewById(R.id.seekBar1);
> >         button = (Button)findViewById(R.id.button1);
> >         button.setOnClickListener(new OnClickListener() {
>
> >                         @Override
> >                         public void onClick(View arg0) {
>
> >                                 AssetFileDescriptor afd;
> >                                 try {
> >                                         if(player.isPlaying())
> >                                 {
> >                                         player.stop();
> >                                         player.release();
> >                                         player = new MediaPlayer();
> >                                 }
>
> >                                         afd = 
> > assetManager.openFd("edho.mp3");
>
> >                                         playFile(afd.getFileDescriptor());
> >                                 } catch (IOException e) {
> >                                         Log.e("Play File", e.toString());
> >                                         e.printStackTrace();
> >                                 }
>
> >                         }
> >                 });
>
> >         playnext.setOnClickListener(new OnClickListener() {
>
> >                         @Override
> >                         public void onClick(View arg0) {
>
> >                                 AssetFileDescriptor afd;
> >                                 try {
> >                                         if(player.isPlaying())
> >                                 {
> >                                         player.stop();
> >                                         player.release();
> >                                         player = new MediaPlayer();
> >                                 }
> >                                         afd = 
> > assetManager.openFd("jugg.mp3");
>
> >                                         playFile(afd.getFileDescriptor());
> >                                 } catch (IOException e) {
> >                                         Log.e("Play Next File", 
> > e.toString());
> >                                         e.printStackTrace();
> >                                 }
>
> >                         }
> >                 });
>
> >     }
>
> >     void playFile(FileDescriptor name)
> >     {
>
> > //      if(player ==null)
> > //              player = new MediaPlayer();
>
> >         try {
> >                 player.reset();
> >                 player.setAudioStreamType(AudioManager.STREAM_MUSIC);
> >                         player.setDataSource(name);
> >                         player.prepare();
>
> >                         player.setOnPreparedListener(new 
> > OnPreparedListener() {
>
> >                                 @Override
> >                                 public void onPrepared(final MediaPlayer 
> > mp) {
>
> >                                         seekplay.setMax(mp.getDuration());
> >                                         new Thread(new Runnable() {
>
> >                                                 @Override
> >                                                 public void run() {
>
> >                                                         
> > while(mp.getCurrentPosition()<mp.getDuration())
> >                                                         {
> >                                                                 
> > seekplay.setProgress(mp.getCurrentPosition());
> >                                                         }
>
> >                                                 }
> >                                         }).start();
> >                                         player.start();
> >                                 }
> >                         });
> >                 } catch (IllegalArgumentException e) {
> >                         Log.e("IllegalAArgumentException", e.toString());
> >                 } catch (IllegalStateException e) {
> >                         Log.e("IllegalStateException", e.toString());
>
> >                 } catch (IOException e) {
> >                         Log.e("IOException", e.toString());
> >                 }
> >     }

-- 
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

Reply via email to