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
New Developer
Posts: 14
Registered: ‎04-08-2009
My Device: Not Specified

Re: [Help] AAC audio streaming playing on Bold

Thanks for your advice. I will give a try as a file.  Smiley Happy

 

We have printed the supported content type:  (We are using simulator bold 9000.)

 

String[] types = Manager.getSupportedContentTypes("http"); for(int i=0; i<types.length; i ++) { System.out.println("=======++++type surpport==============:"+types[i]); }

 

 the result as below:

=======++++type surpport==============:audio/midi               
=======++++type surpport==============:audio/mpeg           
=======++++type surpport==============:audio/x-wav
=======++++type surpport==============:audio/amr
=======++++type surpport==============:audio/basic
=======++++type surpport==============:audio/x-gsm
=======++++type surpport==============:audio/mp4     
=======++++type surpport==============:audio/aac       

=======++++type surpport==============:audio/x-ms-wma

(Removed vedio options)

 

Developer
Posts: 558
Registered: ‎11-25-2008
My Device: Not Specified

Re: [Help] AAC audio streaming playing on Bold

You have aac so you should be fine with "audio/aac". Good Luck.

-D

New Developer
Posts: 14
Registered: ‎04-08-2009
My Device: Not Specified

Re: [Help] AAC audio streaming playing on Bold

We have tested playing the same m4a (mp4a-latm) file by sd card and http. The results are different. sd card is ok to play. The http throw out AUDIOMANAGER: IOException.

 

The successful sd card code:

 

try{ InputStream stream = Connector.openInputStream("file:///SDCard/test.m4a"); Player player = javax.microedition.media.Manager.createPlayer(stream, "audio/aac"); player.start(); } catch(Exception e) { System.err.println("==========="+e.getMessage()); }

 

 

 

 

The failed http code:

try{ HttpConnection http = (HttpConnection) Connector.open("http://192.168.1.100/tv/test.m4a;deviceside=true",Connector.READ_WRITE, true); http.setRequestProperty("Connection", "KeepAlive"); if (http.getResponseCode() != HttpConnection.HTTP_OK && http.getResponseCode() != 206) { int responseCode = http.getResponseCode(); System.out.println("Http not ok:" + responseCode ); } System.out.println("Size: " + http.getLength()); SharedInputStream readAhead = SharedInputStream.getSharedInputStream(http.openInputStream()); Player player = javax.microedition.media.Manager.createPlayer(readAhead, "audio/aac"); player.start(); } catch(Exception e) { System.err.println("==========="+e.getMessage()); }

 

 

The debug log:

Size: 1628400
SMPSmiley Frustratedtreaming session aquired id=1799
MN: init0(0)=0
MN: load 0
AUDIOMANAGER: IOException
MN: unload0(0)=2 pauseHandle=7fffffff
Streaming done reason=1 prev-state=300

 

 

Anyone could help? 

 

New Developer
Posts: 14
Registered: ‎04-08-2009
My Device: Not Specified

Re: [Help] AAC audio streaming playing on Bold

And the same code, changed to play a mp3. It works fine.

try{ HttpConnection http = (HttpConnection) Connector.open("http://192.168.1.100/tv/test.mp3;deviceside=true",Connector.READ_WRITE, true);

 

http.setRequestProperty("Connection", "KeepAlive");

 

if (http.getResponseCode() != HttpConnection.HTTP_OK && http.getResponseCode() != 206) { int responseCode = http.getResponseCode(); System.out.println("Http not ok:" + responseCode ); }

 

System.out.println("Size: " + http.getLength()); SharedInputStream readAhead = SharedInputStream.getSharedInputStream(http.openInputStream()); Player player = javax.microedition.media.Manager.createPlayer(readAhead, "audio/mpeg");

 

player.start(); } catch(Exception e) { System.err.println("==========="+e.getMessage()); }

 

May i come to a conclusion: The blackberry mediaplayer on Bold device does not support http + audio/mp4a-latm?

Developer
Posts: 558
Registered: ‎11-25-2008
My Device: Not Specified

Re: [Help] AAC audio streaming playing on Bold

If it played the file from the SDCard, then the audio type is supported. That can't be the issue. The SDCard file playing would have failed otherwise.

So, there is something else going on. It could be a timing issue. mp3 is encoded more intensely than aac and it's decode is a bit slower as a result.

 

The way you are using the player is a bit different than every time I've used it. Normally every piece of code I've ever seen does the following...

 

 

 player = ...createPlayer....

 

player.realize();

player.prefetch();

player.start();

 

 

Your code is missing these steps.

 

 Have you tried it that way? Also, after the start, you must exit your code to the event loop before the actual playing will occur, so if this is in it's own thread, then you'll need to do a Thread.sleep(10) or something. If inside a listener, you just need to exit the listener.

 

See if any of this works....

 

Thx

-Donald

 

 

New Developer
Posts: 14
Registered: ‎04-08-2009
My Device: Not Specified

Re: [Help] AAC audio streaming playing on Bold

It is still same error, after adding the 2 lines below:

player.realize();

player.prefetch();

 

We have debugged into the player.start() many times.The realize() method will be invoked inside the start(), if you didn't call it explicitly.

 

The code attached is in a button listener. We have a more complex code (3 threads: 1for buffering, 1 for audio playing, 1 for ui). This code is sample and easy for testing.

Developer
Posts: 558
Registered: ‎11-25-2008
My Device: Not Specified

Re: [Help] AAC audio streaming playing on Bold

Now, you are getting an IOException. This is not an audio error.

 

So, what you need to do next is test every value returned for a correct value (not null for example).

 

What is the actual message i.e. Did you get the http not OK message?

 

Was the input stream, readahead, non-null?

 

Your file may need to be called test.aac. Try using the code with that name and rename the file.

 

 

etc, etc...

 

-D

Highlighted
New Developer
Posts: 14
Registered: ‎04-08-2009
My Device: Not Specified

Re: [Help] AAC audio streaming playing on Bold

here is latest test code and debug info:

 

try{ HttpConnection http = (HttpConnection)Connector.open("http://192.168.1.100/tv/test.aac;deviceside=true",Connector.READ_WRITE, true); http.setRequestProperty("Connection", "KeepAlive"); if (http.getResponseCode() != HttpConnection.HTTP_OK && http.getResponseCode() != 206) { int responseCode = http.getResponseCode(); System.out.println("Http not ok:" + responseCode ); } System.out.println("Size: " + http.getLength()); SharedInputStream readAhead = SharedInputStream.getSharedInputStream(http.openInputStream()); if(null == readAhead) { System.out.println("ERROR============readAhead is null "); } Player player = javax.microedition.media.Manager.createPlayer(readAhead, "audio/aac"); player.realize(); player.prefetch(); player.start(); } catch(Exception e) { System.err.println("==========="+e.getMessage()); }

 Debug info:

FocusHistory: Focus gained; App go8; Component net.rim.device.api.ui.component.ButtonField
Size: 1628400
SMPSmiley Frustratedtreaming session aquired id=1799
MN: init0(0)=0
MN: load 0
AUDIOMANAGER: IOException
MN: unload0(0)=2 pauseHandle=7fffffff
Streaming done reason=1 prev-state=300

 

 

If we debug into the player.start(), we can get more information. It will throw out this exception before it jump out of player.start() and throw out the 'AUDIOMANAGER: IOException'.

----------------------------------------------------------------------------------------------------------------------------------

StreamingMediaPlayer.doRealize() line: 457      java.lang.IllegalArgumentException
iae    IllegalArgumentException  (id=407388160)   
         backtrace    null   
         detailMessage    null    

 

 

 

Developer
Posts: 558
Registered: ‎11-25-2008
My Device: Not Specified

Re: [Help] AAC audio streaming playing on Bold

I'm running out of ideas other than to say use the audio format that works for you. mp3 is supported everywhere.

 

One more thing to try though.

 

Realize shouldn't be called if you've already called realize. I looked this up and it can take a while to get realized. It occurred to me that there could indeed be a timing issue.

So, what I'd suggest you do is put the following code in like this.....

 

 

player.realize();

try

{

    Thread.sleep(1000);       // wait one second

}

catch(Exception e)

{}

player.prefetch();

try

{

    Thread.sleep(1000);

}

catch(Exception e)

{}

player.start();

 

 

 I'm thinking that adding the 1 second delay between each step might be appropriate for this audio type.

 

if this works, you can lower the delay a bit like 100ms or something.

 

I suspect that for some reason, it's taking longer to buffer the audio stream with aac format. In the SDCard, the data is local, so the speed is fast. Likewise, with mp3, the timing is going to be different. It could happen possibly with mp3 too if the connection was a bit slower...maybe....

I suspect that it's not ready to be played until it's completed with realization and prefetching, so call each function seperate and give it time to complete before calling the next step.

 

If that works, let us know.

 

Otherwise, you'll need to just use mp3. I can't think what else to try.

 

Good Luck.

-Donald

=============

Donald Murray

CTO IPPUB

 

"If this solves your problem, remember to please click on solved and kudos on the post of the person who helped you the most"

 

 

 

 

 

 

 

 

 

New Developer
Posts: 14
Registered: ‎04-08-2009
My Device: Not Specified

Re: [Help] AAC audio streaming playing on Bold

We have fixed this problem by implementing a random seekable stream to replace the shareinputstream. Shareinputstream doesn't have seek();

 

 This is inspired by when add a shareinputstream between the inputstream and the player. It will throw out the IO exception as well. So, I compared the InputStream and ShareInputStream.  Maybe it is because of the seek(). Then give it a test and it works.

 

try{ InputStream stream = Connector.openInputStream("file:///SDCard/test.m4a"); SharedInputStream readAhead = SharedInputStream.getSharedInputStream(stream); Player player = javax.microedition.media.Manager.createPlayer(readAhead, "audio/aac"); player.start(); } catch(Exception e) { System.err.println("==========="+e.getMessage()); }

 

 

 

 

 

Thanks,

Leo