Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 1,632
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido
Accepted Solution

Can't hear sound when playing mp3 on the Storm

I'm using the following similar code in my app by one of the poster

to play a mp3 sound on the Storm.  The app works fine in the simulator.

 

 

public void playClick( ) { try { Class cl = Class.forName("net.berrysoft.dib.Dib"); InputStream is = cl.getResourceAsStream("/sounds/switch.mp3"); // Create an instance of the player from the InputStream player = Manager.createPlayer( is, "audio/mpeg" ); player.realize(); volumeControl = getVolumeControl(player); if (volumeControl != null) volumeControl.setLevel(volume); player.prefetch(); player.start(); } catch (Exception e) { System.out.println("ERR: " + e.toString()); } } private VolumeControl getVolumeControl( Player p ) { return (VolumeControl)p.getControl( "VolumeControl" ); }

 

the problem is that i can only hear the sound when i plugin the headset.

Once i unplug i can not hear anything.

 

Sound works on my Storm. I can listen to music with the Media app.

 

anybody know why?

 

 

 

 

 

 

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Can't hear sound when playing mp3 on the Storm

Known issue starting on 4.7.0.75, reported to RIM and acknowledged as a bug.

 

Eagerly awaiting news of a fix.

 

 

 

Developer
Posts: 1,632
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: Can't hear sound when playing mp3 on the Storm

thx. I read your replies on the other thread.

 

No wonder there are some many updates. hehe

 

I hope a release very soon cuz this is very annoying.

 

 

 

New Developer
Posts: 13
Registered: ‎12-09-2008
My Device: Not Specified

Re: Can't hear sound when playing mp3 on the Storm

Is there a public bug tracking system where we can monitor the status of this defect? 

 

I'd like to read the issue to see if it applies to my problems...

 

I seem to be having a very similar issue, except with wav files...  I'm writing a small game which produces some clicks and beeps when things happen in the game...  Running in the simulator works perfectly fine...  However, when I try to run on my Storm, not only does the sound not work, both with and without the earphones, but it ends up totally hosing my application to the point where I have to pop out the battery to shut down the application...  I think I heard a single click sound at one point when playing with the headset, but nothing after that...

 

Thanks,

-Garrett

 

 

BlackBerry Development Advisor
Posts: 15,752
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Can't hear sound when playing mp3 on the Storm

We do not currently have any public bug tracking system.

 

Can you elaborate on the lock up problem you are seeing in your game?  Is an exception thrown?  If so, what is it?  What line(s) of code are triggering the lock up?  Can you use Alt+Escape to task switch out of your application?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
Posts: 13
Registered: ‎12-09-2008
My Device: Not Specified

Re: Can't hear sound when playing mp3 on the Storm

[ Edited ]

Hello Mark,

 

Thanks for you reply...

 

I just wrote a HUGE reply to this, and then I was logged out of the site and lost it when I hit submit...  What a bummer...

 

I'll try to summarize the main points again...

 

I believe the "lock up" problem is more due to extreme lag rather than actually being completely locked, but as mentioned, results in needing to pop out the battery...

 

I've inserted a snippet of my sound playing code below...  Granted it's probably the least effecient way to play sound right now since it does ZERO caching, however, I figured it should still work, and I would work on optimization later...

 

A game consists of about 30ish "player moves", 45 "capture moves", and 1 "end game"...  I have yet to complete a full game when the sound code being executed...  I can play many full games with no problems if I disable sound within my game, which essentiallly just skips calling theses methods...  With the sound on, I will usually get close to the end of a game, and then the computer will start hesitating for very long periods to make moves which should take fractions of a second to make...  In fact, I've even had to introduce a delay because they usually are too fast...  Once that starts, the default OS close menu functionality is pretty much gone...  The menu won't even pop up most of the time... Swipe, click, and touch events are completely unresponsive, and it essentially just gets stuck until I pop out the battery...

 

On the simulator, this sound code works perfectly... I can hear every player move sound effect, every capture sound effect and the end game sound effect...  No lock ups, no lag...  The Storm handset won't play anything, except I occassionally hear a faint "tick" or something as though it's trying to play one of the sounds but gets cut off...

 

You'll notice the code sends the user to the error canvas if an exception occurs...  So far, I'm not seeing any exceptions being thrown from the execution of the code....

 

I should mention, I do have another game which has a single class level instance variable "player", which is used to loop a background MIDI file indefinitely in the background of a game with no user input "sound effects"...  That has worked perfectly from day one with no problems... It just seems there is an issue with this multiple sound effect thing...  Or maybe it's the file formats...  I haven't tried using MIDI's for my sound effects yet...  I suppose I could try that instead of using wavs....  I also started a different game a while back which was abandoned because I had trouble combining the midi background loop with a simple "boom" sound effect...  The "boom" sound effect, played in essentially the same way as these capture moves in that prototype would somehow disable permanently the looping background MIDI loop...  I wouldn't be able to start it again once it was shut off...  Again, all of these effects worked great on the simulator, but were nothing but problems on the Storm handset...

 

Any input you could provide would be great...  Perhaps I'm going about playing sounds wrong...  I'd be happy to try any suggestions...

 

Thanks!

-Garrett

 

Edit:  Wanted to mention, my application is a MIDlet, not a CLDC app...

 

Here is my code:

 

public void playCaptureSound() { playSound("/sounds/capture.wav", "audio/wav"); } public void playGameOverSound(boolean inGood) { String resource = null; if (inGood) { resource = "/sounds/good_game_over.wav"; } else { resource = "/sounds/bad_game_over.wav"; } playSound(resource, "audio/wav"); } public void playRegularMoveSound() { String resource = null; if (mModel.getTurn() == Constants.PLAYER1) { resource = "/sounds/player1_move.wav"; } else { resource = "/sounds/player2_move.wav"; } playSound(resource, "audio/wav"); } private void playSound(String inResourceName, String inFormat) { try { Player player = Manager .createPlayer(Dots.class.getResourceAsStream(inResourceName), inFormat); player.start(); } catch (Exception ex) { mErrorCanvas.setData(ex.getMessage()); goToError(); } }

 

Message Edited by greinard on 01-16-2009 06:49 PM
New Developer
Posts: 13
Registered: ‎12-09-2008
My Device: Not Specified

Re: Can't hear sound when playing mp3 on the Storm

Hey All,

 

I wanted to post an update...

 

I've got past the crashing/locking part now...  I optimized the code to cache the players instead of creating one each time, and that seems to have given it enough leway to not lock up and crash the application...  However, I'm still dealing with the original bug which is that the audio is only audible through the plugged in headset... Smiley Sad

 

Thanks,

-Garrett