×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    47

    is it possible to play mp3 file direct from server in j2me?

    hi

    i want to play streaming audio.i am using cirularbytebuffer class for managing buffer.

    but i am getting Exception javax.microedition.media.MediaException: Failed to fetch media data.

    so can anybody help me how can i do it.

    thankx.

  2. #2
    Regular Contributor
    Join Date
    May 2010
    Posts
    94

    Re: is it possible to play mp3 file direct from server in j2me?

    You can Put Url Directly in the Player Class.
    Tested in Simulator perfectly. Not tested in Device.
    You can try this.

  3. #3
    Super Contributor
    Join Date
    May 2008
    Location
    Helsinki, Finland
    Posts
    1,100

    Re: is it possible to play mp3 file direct from server in j2me?

    Hi,

    Just adding...

    javax.microedition.media.Manager.createPlayer(String aUrl) should make the JSR-135 implementation stream the audio data located at the url.

    check out this too:
    http://discussion.forum.nokia.com/fo...eaming-in-j2me

    BR Marko
    [FONT="Comic Sans MS"][COLOR="Blue"][/COLOR][I]Marko Lumivuori
    Technical Support
    +358 40 8019330
    [email]marko.lumivuori@nokia.com[/email][/I][/FONT]

  4. #4
    Registered User
    Join Date
    Nov 2010
    Posts
    47

    Re: is it possible to play mp3 file direct from server in j2me?

    hi
    Even i am not able to play simple file.

    if i play the file as inputstrem i got the exception "javax.microedition.media.MediaException: MUS". i am not able to understand what is the meaning of "MUS". anybody here to help me?

  5. #5
    Regular Contributor
    Join Date
    May 2010
    Posts
    94

    Re: is it possible to play mp3 file direct from server in j2me?

    Can you show here what are you doing in your code.

  6. #6
    Registered User
    Join Date
    Nov 2010
    Posts
    47

    Re: is it possible to play mp3 file direct from server in j2me?

    here is the code:
    player=Manager.createPlayer(this.getClass().getResourceAsStream("/sample.mp3"),"audio/mpeg");
    player.realize();
    player.prefetch();
    player.start();

    where sample.mp3 is under res folder in eclipse project.

  7. #7
    Regular Contributor
    Join Date
    May 2010
    Posts
    94

    Re: is it possible to play mp3 file direct from server in j2me?

    Just try this.

    player=Manager.createPlayer("/sample.mp3");
    player.realize();
    player.prefetch();
    player.start();

  8. #8
    Registered User
    Join Date
    Nov 2010
    Posts
    47

    Re: is it possible to play mp3 file direct from server in j2me?

    hi nitin,
    if i am using player=Manager.createPlayer("/sample.mp3"); or player=Manager.createPlayer("sample.mp3"); it gives me invalid locator.

    and for player=Manager.createPlayer("file:///E:/sample.mp3"); it gives me
    javax.microedition.media.MediaException: MUS.

  9. #9
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: is it possible to play mp3 file direct from server in j2me?

    If you wanna play the mp3 file which is present there in the resource/jar file, then you can use the code below,
    PHP Code:
    public void run()
    {
      try
      {
        
    InputStream is getClass().getResourceAsStream("/your.mp3");
        
    player Manager.createPlayer(is,"audio/mpeg");

        
    player.realize();
        
    // get volume control for player and set volume to max
        
    vc = (VolumeControlplayer.getControl("VolumeControl");
        if(
    vc != null)
        {
          
    vc.setLevel(100);
        }
        
    player.prefetch();
        
    player.start();
      }
      catch(
    Exception e)
      {}

    However when reading your post number 1 and as per the suggestion of Mavric, you are not passing the valid locator. In that case you need to pass the complete URL of the media file, like
    PHP Code:
    Player p Manager.createPlayer("http://webserver/music.mp3"); 
    Is this helpful for you?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  10. #10
    Regular Contributor
    Join Date
    May 2010
    Posts
    94

    Re: is it possible to play mp3 file direct from server in j2me?

    You are not Specifing the mp3 file path.

  11. #11
    Registered User
    Join Date
    Nov 2010
    Posts
    47

    Re: is it possible to play mp3 file direct from server in j2me?

    hi
    if the files are under "res" folder means it included in jar file,so for that we can simply put "/" before filename.

  12. #12
    Regular Contributor
    Join Date
    May 2010
    Posts
    94

    Re: is it possible to play mp3 file direct from server in j2me?

    I use the NEtBeans and if I have the res Folder then I use
    res/....mp3

  13. #13
    Registered User
    Join Date
    Nov 2010
    Posts
    47

    Re: is it possible to play mp3 file direct from server in j2me?

    thankx nitin and raj both of you
    anyway the problem is with emulator.
    in device it works fine.
    I think it happens because there is no audio driver in my pc.

  14. #14
    Registered User
    Join Date
    Nov 2010
    Posts
    47

    Re: is it possible to play mp3 file direct from server in j2me?

    hi,
    If your os didnt have installed audio drivers you'll get "javax.microedition.media.MediaException: MUS" exception.

    Enjoy!

Similar Threads

  1. i can't play mp3 file from server
    By meoconbatchut in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2010-04-22, 06:59
  2. How to play mp3 file?
    By SymbianTH in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2009-06-29, 16:28
  3. how to play mp3 file and play long wav file
    By changsshuai in forum Symbian
    Replies: 6
    Last Post: 2008-09-02, 09:50
  4. i can't play a mp3 file
    By mrshine in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2006-12-11, 17:54
  5. how to play mp3 file?
    By zwgoal in forum Symbian Media (Closed)
    Replies: 3
    Last Post: 2005-11-14, 08:21

Posting Permissions

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