Toast is a notification widget. The above piece of code will display a
small notification at the near the bottom of your screen that the
"path" has not been set.

In the above example, inside the if (path==""){ }, it would be better
to return rather than continuing.

Please look at 
http://code.google.com/android/reference/android/media/MediaPlayer.html
for the list of exceptions that the APIs can throw.

-Ravi

On Jan 6, 1:54 pm, Honest <honestsucc...@gmail.com> wrote:
> I am learning API related to sound playing.  I was understanding code
> for it. The code is as below.
>
> private void playAudio(Integer media) {
>         try {
>             switch (media) {
>                 case LOCAL_AUDIO:
>                     /**
>                      * TODO: Set the path variable to a local audio
> file path.
>                      */
>                     path = "";
>                     if (path == "") {
>                         // Tell the user to provide an audio file URL.
>                         Toast.makeText(
>                                         MediaPlayerDemo_Audio.this,
>                                         "Please edit MediaPlayer_Audio
> Activity, "
>                                                 + "and set the path
> variable to your audio file path."
>                                                 + " Your audio file
> must be stored on sdcard.",
>                                         Toast.LENGTH_LONG).show();
>
>                     }
>                     mMediaPlayer = new MediaPlayer();
>                     mMediaPlayer.setDataSource(path);
>                     mMediaPlayer.prepare();
>                     mMediaPlayer.start();
>                     break;
>
> I could not understand the block of code after the condition if
> (path=="").
>
> What Toast.makeText() will do ? FRom my understanding it is not
> intializing any value to path variable so at the end of that code
> block the value of path will be ""(blank) after that there is a code
> to play file by giving path but the value of path is blank so will
> there be any exception ?
>
> I hope some one will give reply.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to