BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 03-20-2009, 09:39 AM   #1
jasondavidcarr
New Member
 
Join Date: Mar 2009
Model: 8330
PIN: N/A
Carrier: Verizon
Posts: 4
Question $25 via PayPal for helping me get MP3 music working

Please Login to Remove!

Hello,

I'm more than willing to send off $25 if I can get this resolved. I'm trying to play an MP3 as background music for a game. I'm currently testing on the 8300 series emulator and a Curve 8330.

The code looks like this:

Code:
try
{
    InputStream stream = getClass().getResourceAsStream("/MenuMusic.mp3");
    Player player = Manager.createPlayer(stream, "audio/mpeg3");
    player.setLoopCount(-1);
    player.start();
}
catch (MediaException ex)
{
}
catch (IOException ex)
{
}
MenuMusic.mp3 is roughly 512KB and is built (compiled into) the COD file by the JDE. I encoded the MP3 with LAME, at the minimum VBR setting. The music is roughly a minute and a half long.

When I run the code in the emulator, the music plays, but it is extremely choppy and it slows the rest of my game to a crawl. When I run it on the actual 8330 device it slows the game to a crawl, but never plays the music.

Obviously, I expect the music to slow down the game significantly, but I know performance should be much better than this (and it should at least start playing) because I can play an MP3 manually in the background on the device without significantly affecting performance of the game. Therefore, I know the device is capable of it.

Referencing the above code, I've also tried calling the Player class's realize and prefetch methods before calling the start method, but I got pretty much the same results in testing.

Any information would be appreciated, and I promise I'll pay up!

Thanks,
Jason
Offline  
Old 03-20-2009, 11:08 AM   #2
bbtrapped
Knows Where the Search Button Is
 
bbtrapped's Avatar
 
Join Date: Nov 2008
Location: Huntsville
Model: 8100
Carrier: T-Mobile
Posts: 37
Default

Wirelessly posted (@ 88 mph)

Try a midi. I had no success with MP3. Midi works just fine.
Offline  
Old 03-20-2009, 11:22 AM   #3
hippocamp software
Thumbs Must Hurt
 
Join Date: Feb 2009
Model: 9000
PIN: N/A
Carrier: T-Mobile
Posts: 67
Default

are you playing the audio in a seperate thread to your game loop?
Offline  
Old 03-20-2009, 11:56 AM   #4
remaerdlacidar
Knows Where the Search Button Is
 
Join Date: Jul 2007
Model: 9000
PIN: N/A
Carrier: Rogers
Posts: 17
Default

I would try midis as well if possible

Last edited by remaerdlacidar; 03-20-2009 at 12:00 PM..
Offline  
Old 03-20-2009, 12:12 PM   #5
jasondavidcarr
New Member
 
Join Date: Mar 2009
Model: 8330
PIN: N/A
Carrier: Verizon
Posts: 4
Default

Thank you all for responding.

I have lots of experience with MIDIs but that's not at all what I'm going for, unfortunately.

I've tried playing the audio both in the game loop and in a separate thread, but it appears that the music starts playing in a separate thread automatically, anyway, when you start the music. There was no difference in performance/end results when I switched between a separate thread and the same game loop thread.

It would be pretty disappointing if I couldn't get this to work, as I've already written and recorded the music and figured it would work fine since the APIs appear to support it. It also seemed technically possible because of the fact that the device can easily play back an MP3 song (using the built in media software) while the game is playing. I sure hope somehow there's a way to make it work...
Offline  
Old 03-20-2009, 12:22 PM   #6
jasondavidcarr
New Member
 
Join Date: Mar 2009
Model: 8330
PIN: N/A
Carrier: Verizon
Posts: 4
Default

I should note that I tried a different method as well, but unfortunately I couldn't get it to work at all. I tried the net.rim.device.api.media method, which looks like is meant to play a streaming file (or a local file). This may be the solution, but I haven't had any luck with it. Does anyone have experience using these calls?
Offline  
Old 03-22-2009, 01:24 PM   #7
zechariahs
Thumbs Must Hurt
 
Join Date: Nov 2008
Location: Sioux Falls, SD
Model: 9530
PIN: N/A
Carrier: Verizon Wireless
Posts: 65
Default

This article - How To - Play audio in an application, has a nice code snippet.

There's also a long thread on the BlackBerry Support Forums: Problem playing audio in my application (Storm). The thread talks about permission issues, etc that are related to playing media.

RIM's Multimedia Guide (pdf) is probably a good thing to review as well.
__________________
Handspring >> Palm >> BB Pearl >> BB Storm

Tumblog: http://www.geekkink.com
Blog: http://www.zechariahs.org/blog
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


NEW DELL OEM REPLACEMENT PROJECTOR LAMP FOR 4220 4320 GENUINE ORIGINAL  picture

NEW DELL OEM REPLACEMENT PROJECTOR LAMP FOR 4220 4320 GENUINE ORIGINAL

$198.22



Dell OEM Latitude Rugged Extreme 5414 Driving Board Cable for Cable 5414VERTCBL picture

Dell OEM Latitude Rugged Extreme 5414 Driving Board Cable for Cable 5414VERTCBL

$8.95



Dell OEM Latitude Rugged Extreme 7404 GPS Antenna Junction Cable Cable KMX0M picture

Dell OEM Latitude Rugged Extreme 7404 GPS Antenna Junction Cable Cable KMX0M

$2.95



Dell OEM Latitude Rugged Extreme 7404 Left and Right Mouse Buttons 00008 picture

Dell OEM Latitude Rugged Extreme 7404 Left and Right Mouse Buttons 00008

$5.95



DELL 330-6581 3306581 725-10229 OEM LAMP FOR 1510X 1610HD 1610X  - Made By DELL picture

DELL 330-6581 3306581 725-10229 OEM LAMP FOR 1510X 1610HD 1610X - Made By DELL

$39.98



Genuine OEM Dell 2375 B2375dnf B2375dfw 110V Fuser fixing N41P2 sku 724-BBCI picture

Genuine OEM Dell 2375 B2375dnf B2375dfw 110V Fuser fixing N41P2 sku 724-BBCI

$94.99







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.