mediaplayer mp = new mediaplayer();
mp.getResources().openRawResources(myfilename);
mp.start();
mp.stop();

On Oct 9, 7:08 pm, abhi <rkabhi1...@gmail.com> wrote:
> Thank you, Balwinder. But I just have a string for the name of the
> song and so, its not possible to get the ID for it using: .
>
> Please find my code below:
>
> String songFile =  "NameOfSong.mp3";
> MediaPlayer mp = new MediaPlayer(songFile); //This is not working
> since I don't have the entire path to the music file which is stored
> inside the .APK file
>
> Maybe I am using a wrong approach here.
>
> On Oct 8, 10:32 am, "Balwinder Kaur (T-Mobile USA)" <balwinder.k...@t-
>
>
>
> mobile.com> wrote:
> > getResources().openRawResourceFd(int id)
>
> > Get the FileDescriptor for the file and use MediaPlayer.setDataSource
> > (FileDescriptor fd) method.
>
> > Balwinder Kaur
> > Mobile.Software.Development
> > ·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 Oct 8, 12:55 am, abhi <rkabhi1...@gmail.com> wrote:
>
> > > Hi,
>
> > > I have included three MP3 file in the R.raw folder. Now I am able to
> > > get the file name of the MP3 file, but I need to find out the complete
> > > path of the file in order to play the file using MediaPlayer.
>
> > > I am using MediaPlayer.setDataSource(String path) to set the path to
> > > the file. When I set the path as just the file name, the MediaPlayer
> > > does not play it.
>
> > > Is there any way to get the full path of the MP3 file in resources? Or
> > > else, can I  use some other implementation of MediaPlayer.setDataSource
> > > ()?
>
> > > Thanks,
--~--~---------~--~----~------------~-------~--~----~
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