| Reply | « Previous Thread | Next Thread » |
|
Hello everyone,
Does anyone know how to change the inputstream of the Player in J2ME, without closing/stopping the player? I want the player change song without stopping first. I tried to change the inputstream with another stream but still the player play the first stream :( ..... p = Manager.createPlayer(newIS, "audio/wav"); p.addPlayerListener(this); p.realize(); p.prefetch(); p.start(); .... public void playerUpdate(Player player, String event, Object eventData) { if (event.equals(PlayerListener.END_OF_MEDIA)) { try { newIS = .... // I change newIS with stream from next song p.start(); } catch (Exception e) { } } } Have anyone tried it? Please share with me. Thanks |
|
I think you should use different players with different streams and synchronize them using the get/setTimeBase methods.
Daniel |
|
You can only create new player instances, you can't modify the input to an existing player. Just use Manager.createPlayer to get a new player for the new input stream. You can prefetch it so it is ready to start when the current player finishes.
|
|
Thanks for your reply, dcrocha and fmsware. I tried that way too, but it throws MediaException when I tried to play the second player. I played the second player when the first player reached the end of media. This is my code:
....... p2 = Manager.createPlayer(newIS, "audio/wav"); p2.addPlayerListener(this); p2.realize(); p2.prefetch(); try { p.close(); p = null; played = true; } catch (Exception e) {} p2.start(); ....... If I stopped the first player before played the second (before create p2), there's a delay between first song and the second one. |
|
You have to sync them using get/setTimeBase. Otherwise it won't work, or there will be a significant delay between players.
Please check the javadocs. Daniel |
|
I tried that way dcrocha,but when I tried to sync the timebase, it catch MediaException. I think it because the device cannot create 2 player in a time. so I can't do this :
.... p.setTimeBase(p2.getTimeBase()); .... I tried to save the timebase to variable too, the timebase was taken when the first player has reached the end of media, then I closed the first player, create the second one and set the second player timebase with the value from that variable. But still doesn't work. There's still a delay. Is there because of the device cannot play 2 player in one time? I use Nokia 6270. |
|
Phones I have tried seem to support more than one open player at a time (only one can be playing), but maybe this model does not. Prefetching a second player is the only way to minimize (but not eliminate) the delay. Working with the timebase would not help in this situation, and it is usually not implemented on j2me anyway.
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Nokia 6630 & 6680 media player | Gordon_Chen | Streaming and Video | 1 | 2007-06-12 19:19 |
| N70 - Cannot stream Real Player, why? | teura666 | Streaming and Video | 2 | 2006-01-19 10:19 |
| how to set new video player to the default player | rj55 | General Symbian C++ | 1 | 2005-06-16 13:15 |
| change the default real player? | lior_zilberg | General Symbian C++ | 0 | 2005-03-02 10:28 |
| 6310i -- Can it be used to stream audio files (music)? | mkavianpour | Mobile Java General | 1 | 2002-09-06 21:00 |