Reputation: 5952
Here is how I try to play an audio streaming from a server over RTP.
try {
String url = "rtp://...";
Player p = Manager.createPlayer(url);
p.realize();
VideoControl video = (VideoControl) p.getControl("VideoControl");
Item itm = (Item) video.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, null);
midlet.form.append(itm);
p.start();
} catch (Exception e) {...}
I tried http and it worked well. In http, all the media content download and then we can play, pause and play again. It is ok. I want to play an audio from RTP. I want to know how to pause the player (and data is not downloading, keep a record where the media paused) again play when user needs to play (and start downloading again from the last point downloaded (not from beginning)).
As far as I know, smartphones cannot keep a session with the server as the mobile phone doesn't keep sessions and send back to the server every time a request is sent to the server (and just only send a request and get the response, no session management). Maybe I am wrong.
Anyway how can I pause (and stop downloading) and play again (start downloading from the last point where downloading stopped) an audio in a J2ME application? Please let me know if any one know a good solution, sample code.
Upvotes: 0
Views: 1060
Reputation: 175
When streaming, the entire media is NOT downloaded at once,rather portions of the media are downloaded as playback progresses. When a player is created with rtp/rtsp locator, calling player.stop() is enough to stop playback and any further download of the media.Likewise, player.start() is enough to resume playback from where it was stopped.
You must bear in mind that since the media is not local if a stream is not resumed after a while the streaming server may consider a stream to have timed out and you would need reestablish the stream.
Upvotes: 1