Playing local sound with MediaPlayer?

All your problems with Audio, Video and Images.

Re: Playing local sound with MediaPlayer?

Postby raito_yagami » Mon Sep 06, 2010 6:29 pm

but I think it's not good to put files that are little big in that folder.
raito_yagami
Junior Developer
Junior Developer
 
Posts: 14
Joined: Mon Sep 06, 2010 5:48 pm

Top

Re: Playing local sound with MediaPlayer?

Postby Aerosol » Fri Feb 25, 2011 6:37 pm

Hey I'm having a similar problem and cannot seem to find any answers online :?

The code I have is

Code: Select all
       MediaPlayer mp = MediaPlayer.create(SplashScreen.this, Uri.parse("R.raw." + songName));
       if (mp != null){
             mp.start();
       }

the songName refers to a file in my raw folder, so songName = zelda (which is zelda.mp3 in the raw folder)
but I keep getting this error in the logcat

02-25 11:21:57.613: INFO/StagefrightPlayer(33): setDataSource('R.raw.zelda')
02-25 11:21:57.623: ERROR/MediaPlayer(618): error (1, -2147483648)

I also tried doing someting like

Code: Select all
Uri uri = Uri.parse("R.raw."+songName);

then replacing Uri.parse() with just uri
still no luck :-(


Any suggestions? Thanks in advance
Aerosol
Freshman
Freshman
 
Posts: 3
Joined: Fri Feb 25, 2011 6:26 pm

Re: Playing local sound with MediaPlayer?

Postby NoobDroid » Fri Feb 25, 2011 6:55 pm

I have a similar problem, too
my log shows me the error " Invalid File name:must contain only[a-z0-9_.]"
here is some code:
Code: Select all
final MediaPlayer mp = MediaPlayer.create(this,R.raw.Happy_Birthday);
       Button button=
          (Button)this.findViewById(R.id.button1);
       button.setOnClickListener(new View.OnClickListener()
       {
          
          public void onClick(View v){
             mp.prepare();
                mp.start();
          }
          
          
          
       });
    }



thanks for replies
Last edited by NoobDroid on Fri Feb 25, 2011 7:04 pm, edited 2 times in total.
NoobDroid
Freshman
Freshman
 
Posts: 6
Joined: Thu Feb 24, 2011 9:00 pm

Re: Playing local sound with MediaPlayer?

Postby Aerosol » Fri Feb 25, 2011 7:00 pm

Yeah I used to have that too, just don't capitalize any letters, a-z but not A-Z
Aerosol
Freshman
Freshman
 
Posts: 3
Joined: Fri Feb 25, 2011 6:26 pm

Re: Playing local sound with MediaPlayer?

Postby NoobDroid » Fri Feb 25, 2011 7:06 pm

i have already searched in google etc. all forums, but didnt find anything really helpful
NoobDroid
Freshman
Freshman
 
Posts: 6
Joined: Thu Feb 24, 2011 9:00 pm

Re: Playing local sound with MediaPlayer?

Postby Aerosol » Fri Feb 25, 2011 7:09 pm

Try this

Code: Select all
final MediaPlayer mp = MediaPlayer.create(this,R.raw.happy_birthday);// Just changed H and B to lower case

         
Aerosol
Freshman
Freshman
 
Posts: 3
Joined: Fri Feb 25, 2011 6:26 pm

Top

Re: Playing local sound with MediaPlayer?

Postby NoobDroid » Fri Feb 25, 2011 7:18 pm

thanks, but didnt help
sorry that i cant help u
NoobDroid
Freshman
Freshman
 
Posts: 6
Joined: Thu Feb 24, 2011 9:00 pm

Top
Previous

Return to Multimedia Problems

Who is online

Users browsing this forum: Google [Bot] and 22 guests