[VIDEO-Tut] - Playing Media(mp3) on the emulator

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Postby plusminus » Mon Dec 03, 2007 8:46 am

Hey zaac,

perhaps you forgot to change the main.xml or didn't add the -useaudio in the :run:(Run)-configurations.
If you use the debugger to locate the line, the NullPointerException gets thrown, would make it easier to help.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Postby zaac » Mon Dec 03, 2007 10:10 am

My main.xml is ok and i have make -useaudio

Now i can't launch, i have this on the console:

Code: Select all
[2007-12-03 10:08:04 - musicplayer] ------------------------------
[2007-12-03 10:08:04 - musicplayer] Android Launch!
[2007-12-03 10:08:04 - musicplayer] Launching: org.anddev.android.musicplayer.musicplayer
[2007-12-03 10:08:04 - musicplayer] WARNING: Unknown device build id
[2007-12-03 10:08:04 - musicplayer] Pushing musicplayer.apk to /data/app on the device
[2007-12-03 10:08:21 - musicplayer] Failed to install musicplayer.apk on device #1: Unknown Error
[2007-12-03 10:08:21 - musicplayer] Unknown Error
zaac
Freshman
Freshman
 
Posts: 4
Joined: Mon Dec 03, 2007 12:24 am
Location: France

Postby plusminus » Mon Dec 03, 2007 3:31 pm

Hey zaac,

that Error is really strange :!:
WARNING: Unknown device build id

Seems like you Emulator-Image is corrupt...
You could try the following (reset the emulator-rom): (click)

If that dosn't help: Final 'solution' redownload the whole SDK :(


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby zaac » Mon Dec 03, 2007 4:02 pm

It work now but it begin to play only if i click on the volume:

Image

Could you do an archive zip witch the full project ?
zaac
Freshman
Freshman
 
Posts: 4
Joined: Mon Dec 03, 2007 12:24 am
Location: France

Postby plusminus » Mon Dec 03, 2007 9:10 pm

Hello zaac,

please tell us how did you handle the Error you had before, so everybody can learn from it :!:

When you hit the Sound-Buttons, you will always hear a sound coming out :!: (if you started with -useaudio)

Just because it is you :) :The full source (without the song :!:)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby lancelot » Tue Dec 04, 2007 1:44 pm

Hello everyone..

I was trying to make this aplication work but I´m still gettind this message..

Image

I have no idea what I´m doing wrong, can someone tell me what it could be???.

The program starts ok, but if i press the button I get that message..

Thanks..
lancelot
Freshman
Freshman
 
Posts: 2
Joined: Tue Dec 04, 2007 1:40 pm

Top

Postby Katharnavas » Tue Dec 04, 2007 2:02 pm

zaac wrote:Yes it is the solution but now i have an other bug when i click on the button play:

Image


Hi,
What i hope was mp is not getting initialized. Because for me also the audio is not getting played but no error.
Katharnavas
Senior Developer
Senior Developer
 
Posts: 100
Joined: Tue Dec 04, 2007 5:57 am
Location: India

Postby plusminus » Tue Dec 04, 2007 3:49 pm

Hey guys,

somehow your MediaPlayer doesn't want to get initialized.
What you can try is the following:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. MediaPlayer mp = new MediaPlayer();
  2. try {
  3.     mp.setDataSource( "/path/to/your/mp3/everlast.mp3" );
  4. } catch ( IOException e ) {
  5.     Log.e( "ioexception", "",  e);
  6. }
  7. mp.prepare();
  8. mp.start();
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

You will need to push the mp3-file to the folder you specified in your code using adb push. (read more)
plusminus wrote:Console PUSHing files:
:idea: Emulator has to be open && Browse in Terminal/CommandLine to ".../android_sdk/tools"

Syntax: " adb push <local_source> <emulator_destination> "
Image


MediaPlayer now at least should not become null :!:
If it still doesn't want to play the file, that could happen because for Securtiy-Reasons... (file not 'Associated' with your application)
:arrow: Then try a file that was originally shipped with the emulator, like: "/system/media/audio/ringtones/em_ringtone1.mp3"

Hope this could solve it :|

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

me again

Postby dave007 » Wed Dec 05, 2007 2:28 am

Hello everybody!
I really thank you plusminus for your help. now i can listen music with the player. I really don't understand why it doesn't worked but in this way, i have no any errors. thank you!
dave007
Freshman
Freshman
 
Posts: 4
Joined: Fri Nov 30, 2007 4:35 pm

Need to access files

Postby NumBeast » Sun Dec 09, 2007 10:12 pm

I have had the same problem as you guys. Debugging shows that on

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. MediaPlayer mp = MediaPlayer.create(this, R.raw.yourmp3);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


mp is not created, so you get an null pointer exception when you try to call a method on mp, namely
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. mp.prepare();
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


I have tried doing an adb push, but the MediaPlayer does not want to read the file, and when I try to emulate an sd card, the file won't open either. I thought it was a permission problem so I went into the adb shell and chmod'ed the sound file, but that didn't help at all.

As a side note: When I point the media player at /system/media/audio/ringtones I can play all four ringtones, so I know my sound is working.

If you have any ideas on how to fix this, please tell me. I'm trying to make a media player and you can see how not being able to play sounds would be a problem for such an app.
NumBeast
Freshman
Freshman
 
Posts: 7
Joined: Sun Dec 09, 2007 8:59 pm

Re: Need to access files

Postby living_sword » Mon Dec 10, 2007 1:34 pm

switch to DDMS view and check if you see 'sdcard' in the File Explorer.
living_sword
Junior Developer
Junior Developer
 
Posts: 23
Joined: Fri Nov 23, 2007 4:44 am

re

Postby NumBeast » Tue Dec 11, 2007 5:03 am

I know the SDcard works, I can view it with the file browser.
NumBeast
Freshman
Freshman
 
Posts: 7
Joined: Sun Dec 09, 2007 8:59 pm

Postby living_sword » Tue Dec 11, 2007 7:23 am

post the code. that would give us a better idea of the problem.
living_sword
Junior Developer
Junior Developer
 
Posts: 23
Joined: Fri Nov 23, 2007 4:44 am

Postby Asgard » Sun Dec 16, 2007 9:21 pm

I have the same problem with not initialized player (mp = null). If smd knows what is wrong with provided example, please let me know, because this all makes me crazy.
Catch the moment
Asgard
Junior Developer
Junior Developer
 
Posts: 18
Joined: Sat Dec 15, 2007 8:49 pm

Postby plusminus » Sun Dec 16, 2007 9:28 pm

Hello Asgard,

did you try the second possible solution too :?:

:arrow: http://www.anddev.org/viewtopic.php?p=580#580

If that doesn't work too, try a file that is shipped with the emulator. (Somewhere in System-Media-Ringtones...)

Regards,
plusminus
Last edited by plusminus on Sun Dec 16, 2007 10:01 pm, edited 2 times in total.
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top
PreviousNext

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 5 guests