1

I am developing a sample application which can play shoutcast mp3 streams (Developing for S40 platforms, CLDC 1.1, MIDP 2.0). I am using two players switching for continues play back.

I used the below logic for streaming.

Buffer enough chunks
Start Player1
Wait Player1 to finish
Start Player2
Wait Player2 to finish
repeat... 2

The problem is, listener can feel 1 Second silence (Gap) while switching between players.

I would like to know is it possible to stream audio from server without gaps (while switching the players)?

Here is my code for starting player:

Player p = Manager.createPlayer(is, type);
p.addPlayerListener(playerListener);
p.realize();
p.prefetch(); 

Player2 is prefetched before Player1 finishes - I created a FIFO queue for players, and when a chunk is downloaded, I create input stream -> Player -> Realize() -> Prefetch() -> Push into the Queue.

gnat
  • 6,213
  • 108
  • 53
  • 73
MobDev
  • 1,489
  • 1
  • 17
  • 26
  • do you use **[Player.prefetch()](http://docs.oracle.com/javame/config/cldc/opt-pkgs/api/mm/jsr135/javax/microedition/media/Player.html#prefetch() "API javadocs")**? This method "Acquires the scarce and exclusive resources and processes as much data as necessary to **reduce the start latency**..." – gnat Jun 18 '12 at 14:28
  • 1
    Yes i am using Player.prefetch() and Here is my code for starting player. Player p = Manager.createPlayer(is, type); p.addPlayerListener(playerListener); p.realize(); p.prefetch(); – MobDev Jun 18 '12 at 14:47
  • Is player2 prefetched before player1 finish? – Telmo Pimentel Mota Jun 18 '12 at 16:18
  • Yes I am created a FIFO queue for players, and when a chunk is downloaded, I creates input stream -> Player -> Realize() -> Prefetch() -> Push into the Queue. – MobDev Jun 19 '12 at 05:06
  • So, player2.start() is called when playerListener.playerUpdate of player1 is called with event equals to END_OF_MEDIA, right? – Telmo Pimentel Mota Jun 19 '12 at 15:48

1 Answers1

1

There is this project too : mfradio.sourceforge.net but not maintened anymore and i did not get it to work on a "late" MIDP device (Sony W995) I'm still using apart form another android device.

Is your development available somewhere ?

Thanks.

eosphere
  • 316
  • 2
  • 6