×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    14

    playing two mp3 files at the same time

    hello everybody.
    i am newbie in j2me and trying to write a program about screen reading.

    in my program there are some stringitems on the screen such as:

    first
    second
    third

    i want to hear "first.mp3" when i am on "first" string, "second.mp3" when i am on "second" string...

    for this purpose i used keyPressed function but it played first and second at the same time. what can i do to solve my problem. please help me. thanx

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    104

    Re: playing two mp3 files at the same time

    if you can provide your piece of code, which contains you logic.
    http://celluleus.blogspot.com

  3. #3
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: playing two mp3 files at the same time

    Probably you've missed some player-related operations, like stopping the current playing player. Anyway, as pointed out by chanderk, posting your code could be useful to better help you

    Pit

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    14

    Re: playing two mp3 files at the same time

    i have a simple magic =( the code is here:
    as you said, i could not stop the first file play. when i used the "wait" command, it didn't play any of the files.

    for(int i=0; i<kacSesli; i++){
    try{
    InputStream is = getClass().getResourceAsStream(heceleriTut[i]+".mp3");
    player = Manager.createPlayer(is, "audio/mpeg");

    player.prefetch();
    player.realize();
    player.start();

    }
    catch(Exception ex){}
    }

    heceleriTut is my array which holds the player list. thank you =)

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    14

    Re: playing two mp3 files at the same time

    i found a solution to this problem, it is not very effective but it works fine. for the people who have the same trouble with me:

    after player.start() command i put a loop which wastes time. so, you can listen players one by one.

  6. #6
    Nokia Developer Expert
    Join Date
    May 2007
    Location
    Mexico D.F
    Posts
    351

    Re: playing two mp3 files at the same time

    Hello irkara... please post only in ONE forum

    Here's a much better sollution using the JSR 135

    You can set a PlayerListener interface to your Player... in this way you will be notified each time a media reaches the end and then start the following media.

    So have a look at the following methos and classes:

    Class Player:
    Method: void addPlayerListener(PlayerListener playerListener)

    Class PlayerListener
    Method: void playerUpdate(Player player, String event, Object eventData)


    There you can use something like this:

    if (eventType == PlayerListener.END_OF_MEDIA) {...}

    You can get the JSR 135 specification here:

    http://www.jcp.org/en/jsr/detail?id=135

    Have fun

    :Ruben

Similar Threads

  1. what i need to install to play mp3 files
    By ravibabu in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2006-10-18, 06:04
  2. mp3 files & nokia 6101
    By suzanehanna in forum General Development Questions
    Replies: 2
    Last Post: 2005-12-20, 11:29
  3. Probem playing mp3 files on nokia 6630?
    By nimishjain15882 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2005-08-25, 08:16
  4. DRM with mp3 files?
    By ipohfly in forum Digital Rights Management & Content Downloading
    Replies: 0
    Last Post: 2005-03-09, 03:52
  5. Playing wav files on Nokia 6600
    By rotkappchen in forum Audio
    Replies: 0
    Last Post: 2003-11-29, 22:54

Posting Permissions

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