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

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

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

Hello, plusminus. Thanks for your help :)

All the ways described above works fine, but I would like to play sound from project res folder, as in your example.
Catch the moment
Asgard
Junior Developer
Junior Developer
 
Posts: 18
Joined: Sat Dec 15, 2007 8:49 pm

Top

Postby plusminus » Sun Dec 16, 2007 10:05 pm

Hm,
there is no other solution to load from resource that I am aware of...

:idea: Please post your code and OS/SDK/ADT-VErsions ( are you using the new SDK (released yersterday :?:) )
:arrow: Perhaps someone recognizes the he/she had the same problem and answers.

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

Can't hear

Postby cybersat » Tue Dec 18, 2007 12:24 pm

Installed music player file and program is working , but i can't hear mp3.

I had increased volume in emulator, still no sound.
cybersat
Freshman
Freshman
 
Posts: 5
Joined: Tue Dec 18, 2007 8:09 am

Postby plusminus » Tue Dec 18, 2007 3:44 pm

Hello cybersat,

did you hear the sound the emulator makes when hitting the VolumeUp/Down Buttons :?:
did you run the emulator with "-useaudio" :?:

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 Katharnavas » Wed Dec 19, 2007 5:05 am

I hope he is missing that atleast when volume key is pressed he will hear a music.


plusminus wrote:Hello cybersat,

did you hear the sound the emulator makes when hitting the VolumeUp/Down Buttons :?:
did you run the emulator with "-useaudio" :?:

Regards,
plusminus
Katharnavas
Senior Developer
Senior Developer
 
Posts: 100
Joined: Tue Dec 04, 2007 5:57 am
Location: India

SOLUTION!!!!

Postby NumBeast » Wed Dec 19, 2007 5:19 am

I have finally figured out why none of my mp3s were playing. They were not Mp3s. The files I were trying to play were Mono/22050Hz/64kbps/MPEG-1layer2 with the /mp3 extension. reformatting MPEG-1layer3 solves all my problems. YAY!!!!!! :) :D
NumBeast
Freshman
Freshman
 
Posts: 7
Joined: Sun Dec 09, 2007 8:59 pm

Top

Postby R4 » Wed Dec 19, 2007 9:37 am

Hello,

Similar symptoms to everyone else but in my case the problem was that the mp3 file was too big. The debugger log window showed this message:

Code: Select all
D/asset(555): Data exceeds UNCOMPRESS_DATA_MAX (11960997 vs 1048576)


Simply changing to a smaller (<1M) mp3 file solved the problem. No source code changes to the original at all.

R4
R4
Freshman
Freshman
 
Posts: 3
Joined: Wed Dec 19, 2007 7:48 am

Postby plusminus » Wed Dec 19, 2007 6:29 pm

Hello R4,

Yes exactly 1 MB ( == 1.048.576 Bytes )

Why ever they chose that limit ... :roll:

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

APPLICATION CANNOT BE FOUND

Postby gcameo » Thu Dec 20, 2007 5:46 pm

After watching the screencast and following the tutorials evrything worked fine but the i could not find the application in the emulator.

I must mention that I did it from commandprompt since I dont have eclipse. Is there a plugin for netbeans
gcameo
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Dec 20, 2007 5:40 pm

Postby ramgraph1 » Fri Jan 11, 2008 5:55 am

Is there a way to stop all audio that an activity is running when you quit it? I have a looping mp3 that just keeps playing when I quit and I need to know how to kill it!
Anybody know how?
Thanks
ramgraph1
Experienced Developer
Experienced Developer
 
Posts: 68
Joined: Wed Jan 09, 2008 10:03 pm

Postby plusminus » Fri Jan 11, 2008 11:03 am

Hello ramgraph,

you somewhere created a MediaPlayer object and you can use its stop()-method. Is it not working properly :?:

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 ramgraph1 » Fri Jan 11, 2008 2:09 pm

Thanks for responding. I did create a MediaPlayer object but the use of it seems limited to the public void in which I created it so that to access the MediaPlayer I need to call that void again which just creates a new MediaPlayer, it seems. The code UI use is similar to your example above:

Code: Select all
public void onClick(View arg0) {
                    MediaPlayer mp = MediaPlayer.create(MusicPlayer.this,
                              R.raw.everlast);
                    mp.prepare();
                    mp.start();


except instead of setOnCompletionListener I am looping the audio. If I try to use "mp.stop();" from somewhere outside of the onClick where is was created I get "mp cannot be resolved". What code would you use to use another button to stop the audio you start in the code above? Thanks for any light you can shed!
ramgraph1
Experienced Developer
Experienced Developer
 
Posts: 68
Joined: Wed Jan 09, 2008 10:03 pm

Postby AndreySerj » Thu Jan 17, 2008 11:52 am

Hi All,
While player is running I try to adjust a sound volume by buttons on emulator (on the right side), but nothing happens. How to control a sound volume on device ?
AndreySerj
Developer
Developer
 
Posts: 31
Joined: Wed Dec 26, 2007 9:57 am
Location: Minsk

Postby plusminus » Thu Jan 17, 2008 9:18 pm

Hello AndreySerj,

Ringing on incoming Voice-Calls works fine for me (changing the volume while its ringing works also)

Perhaps have a look at:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. android.view.IRingerVolume volumeService = android.view.RingerVolumeNative.asInterface(sm.getService("volume"));
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


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 AndreySerj » Fri Jan 18, 2008 9:19 am

plusminus wrote:Ringing on incoming Voice-Calls works fine for me (changing the volume while its ringing works also) ....

Hi plusminus, I mean an audio volume control while playback ...
I found the following solution:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ...
  2. AudioSystem.setVolume(AudioSystem.STREAM_MUSIC, AudioSystem.MAX_VOLUME - step);
  3. ...
  4.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


It work, but when I increase/decrease sound volume by right-side buttons on the emulator I hear both my audio playback and emulator-specific tone.
AndreySerj
Developer
Developer
 
Posts: 31
Joined: Wed Dec 26, 2007 9:57 am
Location: Minsk

Top
PreviousNext

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 9 guests