01-04-2010 07:57 PM
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.
01-04-2010 08:27 PM
How do you handle buffer full and buffer empty?
01-04-2010 08:32 PM
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.
01-04-2010 09:04 PM
Why are you creating a buffer the size of the file? Managing large hunks of memory will not be efficient.
01-04-2010 09:04 PM
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.
01-05-2010 06:34 PM
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.
01-05-2010 06:45 PM
Hi Aviator168 : Thank you for your reply and I am sorry to reply so late. The code is here:
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?
01-06-2010 03:06 PM
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).
01-06-2010 05:40 PM
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.
01-07-2010 07:06 AM
@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