andbook!.pdf - Learning Android Get an anddev.org - Android-Shirt Back to index
anddev.org Header Logo
FAQ Search Top rated articles Browse Feeds anddev.org - Authors Contact Details Register Log in

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

Goto page Previous  1, 2, 3, 4, 5  Next
 
       anddev.org - Android Development Community | Android Tutorials | Index -> Novice Tutorials
Author Message
plusminus
Site Admin


Joined: 14 Nov 2007
Posts: 2067
Location: Germany

PostPosted: Mon Dec 03, 2007 8:46 am    Post subject: Reply with quote

Hey zaac,

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

Regards,
plusminus

_________________

| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
zaac
Freshman


Joined: 03 Dec 2007
Posts: 4
Location: France

PostPosted: Mon Dec 03, 2007 10:10 am    Post subject: Reply with quote

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

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

Code:
[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
Back to top
View user's profile Send private message Visit poster's website
plusminus
Site Admin


Joined: 14 Nov 2007
Posts: 2067
Location: Germany

PostPosted: Mon Dec 03, 2007 3:31 pm    Post subject: Reply with quote

Hey zaac,

that Error is really strange Exclamation
Quote:
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 Sad


Regards,
plusminus

_________________

| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
zaac
Freshman


Joined: 03 Dec 2007
Posts: 4
Location: France

PostPosted: Mon Dec 03, 2007 4:02 pm    Post subject: Reply with quote

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



Could you do an archive zip witch the full project ?
Back to top
View user's profile Send private message Visit poster's website
plusminus
Site Admin


Joined: 14 Nov 2007
Posts: 2067
Location: Germany

PostPosted: Mon Dec 03, 2007 9:10 pm    Post subject: Reply with quote

Hello zaac,

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

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

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

Regards,
plusminus

_________________

| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
lancelot
Once Poster


Joined: 04 Dec 2007
Posts: 1

PostPosted: Tue Dec 04, 2007 1:44 pm    Post subject: Reply with quote

Hello everyone..

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



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..
Back to top
View user's profile Send private message
Katharnavas
Senior Developer


Joined: 04 Dec 2007
Posts: 100
Location: India

PostPosted: Tue Dec 04, 2007 2:02 pm    Post subject: Reply with quote

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



Hi,
What i hope was mp is not getting initialized. Because for me also the audio is not getting played but no error.
Back to top
View user's profile Send private message Yahoo Messenger
plusminus
Site Admin


Joined: 14 Nov 2007
Posts: 2067
Location: Germany

PostPosted: Tue Dec 04, 2007 3:49 pm    Post subject: Reply with quote

Hey guys,

somehow your MediaPlayer doesn't want to get initialized.
What you can try is the following:
Java:
MediaPlayer mp = new MediaPlayer();
try {
    mp.setDataSource( "/path/to/your/mp3/everlast.mp3" );
} catch ( IOException e ) {
    Log.e( "ioexception", "",  e);
}
mp.prepare();
mp.start();

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


MediaPlayer now at least should not become null Exclamation
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 Neutral

Regards,
plusminus

_________________

| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dave007
Freshman


Joined: 30 Nov 2007
Posts: 4

PostPosted: Wed Dec 05, 2007 2:28 am    Post subject: me again Reply with quote

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!
Back to top
View user's profile Send private message
NumBeast
Freshman


Joined: 09 Dec 2007
Posts: 6

PostPosted: Sun Dec 09, 2007 10:12 pm    Post subject: Need to access files Reply with quote

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

Java:
MediaPlayer mp = MediaPlayer.create(this, R.raw.yourmp3);


mp is not created, so you get an null pointer exception when you try to call a method on mp, namely
Java:
mp.prepare();


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.
Back to top
View user's profile Send private message
living_sword
Junior Developer


Joined: 23 Nov 2007
Posts: 18

PostPosted: Mon Dec 10, 2007 1:34 pm    Post subject: Re: Need to access files Reply with quote

switch to DDMS view and check if you see 'sdcard' in the File Explorer.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
NumBeast
Freshman


Joined: 09 Dec 2007
Posts: 6

PostPosted: Tue Dec 11, 2007 5:03 am    Post subject: re Reply with quote

I know the SDcard works, I can view it with the file browser.
Back to top
View user's profile Send private message
living_sword
Junior Developer


Joined: 23 Nov 2007
Posts: 18

PostPosted: Tue Dec 11, 2007 7:23 am    Post subject: Reply with quote

post the code. that would give us a better idea of the problem.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Asgard
Junior Developer


Joined: 15 Dec 2007
Posts: 16

PostPosted: Sun Dec 16, 2007 9:21 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
plusminus
Site Admin


Joined: 14 Nov 2007
Posts: 2067
Location: Germany

PostPosted: Sun Dec 16, 2007 9:28 pm    Post subject: Reply with quote

Hello Asgard,

did you try the second possible solution too Question

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

_________________

| Android Development Community / Tutorials


Last edited by plusminus on Sun Dec 16, 2007 10:01 pm; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
       anddev.org - Android Development Community | Android Tutorials | Index -> Novice Tutorials All times are GMT + 1 Hour
Goto page Previous  1, 2, 3, 4, 5  Next
Page 2 of 5

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


© 2007, Android Development Community
All rights reserved.
Powered by phpBB.