×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    37

    Question Change stream without stopping the player?

    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

  2. #2
    Nokia Developer Expert
    Join Date
    Jun 2005
    Posts
    923

    Re: Change stream without stopping the player?

    I think you should use different players with different streams and synchronize them using the get/setTimeBase methods.

    Daniel

  3. #3
    Regular Contributor
    Join Date
    Feb 2004
    Posts
    90

    Re: Change stream without stopping the player?

    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.

  4. #4
    Registered User
    Join Date
    Jul 2003
    Posts
    37

    Question Re: Change stream without stopping the player?

    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.

  5. #5
    Nokia Developer Expert
    Join Date
    Jun 2005
    Posts
    923

    Re: Change stream without stopping the player?

    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

  6. #6
    Registered User
    Join Date
    Jul 2003
    Posts
    37

    Question Re: Change stream without stopping the player?

    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.

  7. #7
    Regular Contributor
    Join Date
    Feb 2004
    Posts
    90

    Re: Change stream without stopping the player?

    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.

Similar Threads

  1. Nokia 6630 & 6680 media player
    By Gordon_Chen in forum Streaming and Video
    Replies: 1
    Last Post: 2007-06-12, 18:19
  2. N70 - Cannot stream Real Player, why?
    By teura666 in forum Streaming and Video
    Replies: 2
    Last Post: 2006-01-19, 09:19
  3. Replies: 1
    Last Post: 2005-06-16, 12:15
  4. change the default real player?
    By lior_zilberg in forum Symbian
    Replies: 0
    Last Post: 2005-03-02, 09:28
  5. 6310i -- Can it be used to stream audio files (music)?
    By mkavianpour in forum Mobile Java General
    Replies: 1
    Last Post: 2002-09-06, 20:00

Posting Permissions

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