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
kungfucop
Posts: 57
Registered: ‎05-25-2009
My Device: Not Specified

music skip when playing music using custom datasouce

Hi, I create an byte array as as a buffer ,and write into it using the one thread and reading it inside the read method of sourcestream class, of course I synchronized the read and the right, however, the song plays well in the first 1 miniute but skip sometimes beginning from the next minute. I try to dump all the data read from the buffer and compare it with the original mp3 in the server which the custom datasource plays, it seems that it is totally the same.  So anybody knows what might causes this to happen?

 

 

Thanks.

 

 

Please use plain text.
Developer
Aviator168
Posts: 709
Registered: ‎09-10-2009
My Device: 8520, 8900, 9000, 9300, 9650, 9700, 9780, 9800, 9810, 9900, 9930
My Carrier: Verizon

Re: music skip when playing music using custom datasouce

How do you handle buffer full and buffer empty?

Please use plain text.
Developer
kungfucop
Posts: 57
Registered: ‎05-25-2009
My Device: Not Specified

Re: music skip when playing music using custom datasouce

I create a buffer of the size of the mp3 file I am going to play, so I write from 0 to length-1, and when I read I will first check whether the downloaded data is enough or not for my querying,  I read from 0 to length-1. And the read and write are synchorinized together.

 

Please use plain text.
Developer
ydaraishy
Posts: 562
Registered: ‎09-30-2009
My Device: Not Specified

Re: music skip when playing music using custom datasouce

Why are you creating a buffer the size of the file? Managing large hunks of memory will not be efficient.

Please use plain text.
Developer
Aviator168
Posts: 709
Registered: ‎09-10-2009
My Device: 8520, 8900, 9000, 9300, 9650, 9700, 9780, 9800, 9810, 9900, 9930
My Carrier: Verizon

Re: music skip when playing music using custom datasouce

Can you post some code? The read and write method of the bytearraystream will be helpful. I did buffer playback for the last few months and never encounter any skip.

Please use plain text.
Developer
kungfucop
Posts: 57
Registered: ‎05-25-2009
My Device: Not Specified

Re: music skip when playing music using custom datasouce

I cut the buffer into severl smaller ones to make sure the performance is not effected. The reason I must use buffer is because I nead to apply codec info to the information.

Please use plain text.
Developer
kungfucop
Posts: 57
Registered: ‎05-25-2009
My Device: Not Specified

Re: music skip when playing music using custom datasouce

Hi Aviator168 : Thank you for your reply and I am sorry to reply so late. The code is here:

http://supportforums.blackberry.com/t5/Java-Development/problem-in-using-datasource-to-feed-player-u...

 

The only diffrence to that is I add synchronization to the getData() function and the connectonthread write.  I tried to dump all the data the player read from  

LimitedRateSourceStream.read(byte[] bytes, int off, int len)

And write it to a file and play it: It is absolutely good.  But why the player will skip with the right data?

 

Please use plain text.
Developer
Aviator168
Posts: 709
Registered: ‎09-10-2009
My Device: 8520, 8900, 9000, 9300, 9650, 9700, 9780, 9800, 9810, 9900, 9930
My Carrier: Verizon

Re: music skip when playing music using custom datasouce

You code make me have cross eyes. It looks like you follow the buffered playback sample. There is a simpler way to do it. I use a ByteArrayInputStream (no custom datasource).

Please use plain text.
Developer
kungfucop
Posts: 57
Registered: ‎05-25-2009
My Device: Not Specified

Re: music skip when playing music using custom datasouce

Would you please share some idea or code pieces to let me know how to use the bytestream?I am struggling to find this out. Thanks dude.

Please use plain text.
Developer
klerisson
Posts: 78
Registered: ‎12-03-2009
My Device: Not Specified

Re: music skip when playing music using custom datasouce

@Aviator168 Is it possible to stream live radio over http connection? Using directly TCP is perfectly possible as you can see here http://code.google.com/p/chaudcast/

Thanks

--
Feel free to press the kudos button on the left side to thank the user that helped you.
Please mark posts as solved if you found a solution.
Please use plain text.