BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 03-20-2009, 10:39 AM   #1 (permalink)
New Member
 
Join Date: Mar 2009
Model: 8330
PIN: N/A
Carrier: Verizon
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
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, 12:08 PM   #2 (permalink)
Knows Where the Search Button Is
 
bbtrapped's Avatar
 
Join Date: Nov 2008
Location: Huntsville
Model: 8100
Carrier: T-Mobile
Posts: 37
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Wirelessly posted (@ 88 mph)

Try a midi. I had no success with MP3. Midi works just fine.
Offline  
Old 03-20-2009, 12:22 PM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Feb 2009
Model: 9000
PIN: N/A
Carrier: T-Mobile
Posts: 67
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

are you playing the audio in a seperate thread to your game loop?
Offline  
Old 03-20-2009, 12:56 PM   #4 (permalink)
Knows Where the Search Button Is
 
Join Date: Jul 2007
Model: 9000
PIN: N/A
Carrier: Rogers
Posts: 17
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I would try midis as well if possible

Last edited by remaerdlacidar : 03-20-2009 at 01:00 PM.
Offline  
Old 03-20-2009, 01:12 PM   #5 (permalink)
New Member
 
Join Date: Mar 2009
Model: 8330
PIN: N/A
Carrier: Verizon
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
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, 01:22 PM   #6 (permalink)
New Member
 
Join Date: Mar 2009
Model: 8330
PIN: N/A
Carrier: Verizon
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
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, 02:24 PM   #7 (permalink)
Thumbs Must Hurt
 
Join Date: Nov 2008
Location: Sioux Falls, SD
Model: 9530
PIN: N/A
Carrier: Verizon Wireless
Posts: 65
Post Thanks: 0
Thanked 0 Times in 0 Posts
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


Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





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