You Are Here:

Community: Developer Discussion Boards

#1 Old Question Change stream without stopping the player? - 2006-02-22, 03:51

Join Date: Jul 2003
Posts: 37
cars2003
Offline
Registered User
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
Reply With Quote

#2 Old Re: Change stream without stopping the player? - 2006-02-22, 15:24

Join Date: Jun 2005
Posts: 928
dcrocha's Avatar
dcrocha
Offline
Forum Nokia Expert
I think you should use different players with different streams and synchronize them using the get/setTimeBase methods.

Daniel
Reply With Quote

#3 Old Re: Change stream without stopping the player? - 2006-02-22, 16:46

Join Date: Feb 2004
Posts: 90
fmsware
Offline
Regular Contributor
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.
Reply With Quote

#4 Old Question Re: Change stream without stopping the player? - 2006-02-23, 07:40

Join Date: Jul 2003
Posts: 37
cars2003
Offline
Registered User
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.
Reply With Quote

#5 Old Re: Change stream without stopping the player? - 2006-02-23, 15:02

Join Date: Jun 2005
Posts: 928
dcrocha's Avatar
dcrocha
Offline
Forum Nokia Expert
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
Reply With Quote

#6 Old Question Re: Change stream without stopping the player? - 2006-02-24, 07:40

Join Date: Jul 2003
Posts: 37
cars2003
Offline
Registered User
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.
Reply With Quote

#7 Old Re: Change stream without stopping the player? - 2006-02-26, 19:24

Join Date: Feb 2004
Posts: 90
fmsware
Offline
Regular Contributor
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 With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
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

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia