×

Discussion Board

Results 1 to 15 of 15

Thread: MP3 player

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    39

    MP3 player

    My handset supports MP3 (audio/mpeg). The native music player plays MP3 (file in memory card or phone memory);
    I wrote a J2ME code for audio player which works fine for AMR files but not MP3. For MP3, my code reaches realize () call but never comes out of realize (). I used these constructor types "createPlayer ("<URI to MP3>")" as well as "createPlayer (inputStream, "audio/mpeg")".

    Question:
    a) What else option available for "Manager.createPlayer ()".
    b) How to "createPlayer" for "audio/x-ms-wma" type since my handset supports this file type also;

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: MP3 player

    Check what your device supports from java apps using:

    Code:
    String[] supportedTypes = Manager.getSupportedContentTypes(null);
    Are you sure that realize() is not throwing an exception? (Or an OutOfMemoryError, if the MP3 file is large.)

    Graham.

  3. #3
    Registered User
    Join Date
    Dec 2010
    Posts
    39

    Re: MP3 player

    The System.out.println () given before realize is displayed. But the System.out.println () given after realize is displayed. Meaning, system enters into "realize" but didnt come out. The same mp3 (size 6MB+) works fine with native player. As I already said, getSupportedContentTypes ("file:") returns many types in addition to "audio/mpeg".

    Is there any way to "look inside" of realize what's happening ?

  4. #4
    Registered User
    Join Date
    Dec 2010
    Posts
    39

    Re: MP3 player

    I meant, system.out.println () after realize is not at all appear in the handset.
    I gave try & catch (MediaException) block for realize alone. There's no exception thrown. So, realize started but is not ending. The same MP3 works fine with native built-in media player in the handset.

    Any further ways to createPlayer (); How to look into the inside of "realize" operation. Help please !!!

  5. #5
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: MP3 player

    If you only catch MediaException, you only know that MediaException is not being thrown. There are many other types of exception. Catch Throwable to make sure nothing is being thrown.

    What device are you using?

    Graham.

  6. #6
    Registered User
    Join Date
    Dec 2010
    Posts
    39

    Re: MP3 player

    Im using Samsung CORBY txt GT-B3270.

    im checking for - how to do the Throwable that u have suggested; but if i catch (Exception e) and print e.toString () will that be not enough.

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

    Re: MP3 player

    Why don't you take a small file and check if the same issue is arriving?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  8. #8
    Registered User
    Join Date
    Dec 2010
    Posts
    39

    Re: MP3 player

    The issue occurs for all "mp3s". I checked with a 1175 KB file (1+ MB) which works in mobile native player but not in my J2ME app; while the same MP3 file - if i convert to "AMR" - my app plays the file.

  9. #9
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: MP3 player

    Code:
    try {
        // do something
    } catch (Throwable t) {
        // handle it
    }
    Try a file much smaller. Your device only has a 2Mb Java heap, so I'm not surprised if it rejects anything larger.

    Also: your device is a Samsung, and this is the Nokia Forum. Try the Samsung Mobile Innovator site.

    Graham.

  10. #10
    Registered User
    Join Date
    Dec 2010
    Posts
    39

    Re: MP3 player

    I'll try with "very small" MP3. My concern is - when the MP3 plays well with native music player in the handset, why not it plays in J2ME app. - any reason for this ??? while the same MP3 - if converted to AMR - it plays fine in the J2ME app.

  11. #11
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: MP3 player

    It is not unusual, especially on low-end devices, for them to play more formats in their music player, but be able to play only a subset from a Java application.

    Graham.

  12. #12
    Registered User
    Join Date
    Dec 2010
    Posts
    39

    Re: MP3 player

    Graham, thanks for the inputs & the "Throwable" idea. I found "realize" returns OutOfMemory error.

    The question is - why I didnt got this OutOfMemory issue while catch "Exception" ?
    How to overcome OutOfMemory error.
    The freeMem in my handset is 2020668 while TotalMem is 2097316.

    As of now, I'll try with very some small MP3 as suggested by RAJ.

    Pl provide inputs. Thank you.

  13. #13
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: MP3 player

    OutOfMemoryError is not an exception (it's not a subclass of Exception), it's an Error. Both Exception and Error are subclasses of Throwable - Throwable is the ultimate superclass of everything that can be thrown and caught.

    The only way to avoid an OutOfMemoryError is to use less memory. That means (you guessed it) a smaller MP3. Probably less than half the size of the available heap memory.

    Graham.

  14. #14
    Registered User
    Join Date
    Dec 2010
    Posts
    39

    Re: MP3 player

    Thank you for the valuable inputs.
    I've tested my app, and it plays good - MP3s of smaller size (700 kb);

    So, how else to make audio players that can play bigger MP3s - via J2ME or any other technology ???
    What's the technology used in media player in mobile ?

  15. #15
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: MP3 player

    The built-in media player will be a native application, not Java. So far as I know, that device does not permit you to develop your own native apps, it's Java only. Check the Samsung developer site for more information about your device.

    Graham.

Similar Threads

  1. MP3 Player!
    By neilruparel in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2007-04-10, 04:51
  2. MP3 player
    By cindul in forum Symbian
    Replies: 0
    Last Post: 2004-12-30, 05:10
  3. mp3 player
    By delboy73 in forum General Development Questions
    Replies: 0
    Last Post: 2003-05-23, 00:39

Posting Permissions

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