Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    80

    Playing big audio file

    Hi,
    In my midlet small mp3 file play fine but I like to play 1.46 MB audio mp3 file, it throws out of memory.
    Is there any way to increase memory for my midlet? thanks

    player.addPlayerListener(this);

    player.prefetch(); // This throw exception

    volumeControl = (VolumeControl) player.getControl("VolumeControl");

    player.setMediaTime(0);

    volumeControl.setLevel(80);

    player.start();

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: Playing big audio file

    There is no way to "increase" the memory, the heap space on the phone is predefined and fixed.
    you can play the file either from the file system or from http url using progressive-download jad attribute

  3. #3
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    80

    Re: Playing big audio file

    Quote Originally Posted by shai.i View Post
    There is no way to "increase" the memory, the heap space on the phone is predefined and fixed.
    you can play the file either from the file system or from http url using progressive-download jad attribute
    Thanks, could you clarify the following

    1. How big file we can add to resource? Can we check it during run time?
    2. Storing mp3 file in net is not solution for me, what else option I have?
    3. Other platform, we can increase heap for app, for Midlet can we do that?

  4. #4
    Super Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,570

    Re: Playing big audio file

    No, you cannot increase the heap size. The max is what it is and you have to live with it. If you can't buffer the data partially in memory (then discard "used" data and load some more), then your only option is to reduce the amount/size. In the case of MP3 files, you can lower the quality, shorten the clip, or switch to a more compact format (such as MIDI, which, of course, is only useful for MIDI instrument sounds, and not general audio).

  5. #5
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: Playing big audio file

    We could help you more if you give us the backstory of what your trying to do...
    why cant you use network?
    is the bitrate & samplerate of your mp3 can be reduced?
    can you use another format?
    etc.

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,789

    Re: Playing big audio file

    Quote Originally Posted by aktarjahan2003 View Post
    1. How big file we can add to resource? Can we check it during run time?
    These are two different things:
    - your .jar file can not grow indefinitely, there is a size limit for the devices, like 2-4-5 megabytes - however you succeeded with deploying the application, and 1.46 megabytes is not that large
    - here and now you are running out of memory in runtime because the player tries to load the entire file by default. Try what Shai.i suggested, it is described here: http://developer.nokia.com/Community..._(Known_Issue)
    2. Storing mp3 file in net is not solution for me, what else option I have?
    Here and now this is not the issue, but if you ever reach the .jar size limit, you can still store data as files or as RMS records - however in this case they will have to be downloaded, so your application will need Internet access at least once.
    3. Other platform, we can increase heap for app, for Midlet can we do that?
    Those are smartphone platforms, focusing more to run 3rd party applications. Series 40 and Asha devices are getting "stronger" but they are still feature phones, primarily focusing on telephony and multimedia services, and their support for running applications is an extra.

  7. #7
    Registered User
    Join Date
    Jun 2013
    Posts
    46

    Re: Playing big audio file

    Quote Originally Posted by shai.i View Post
    There is no way to "increase" the memory, the heap space on the phone is predefined and fixed.
    Nokia devices are so limited. If only we were developing for iPhone, then we could just download more ram.

    http://www.downloadmoreram.com/

    ;-)

  8. #8
    Registered User
    Join Date
    Jun 2013
    Posts
    46

    Re: Playing big audio file

    Quote Originally Posted by aktarjahan2003 View Post
    1. How big file we can add to resource? Can we check it during run time?
    2. Storing mp3 file in net is not solution for me, what else option I have?
    I'd like to ask if it absolutely has to be an mp3 file. If it is music for a game, how about having a musician create a MIDI file for you instead?

    Alternatively you might be able to find a (already JavaME optimized) MIDI file at www.IndieGameMusic.com that fits your game style.

  9. #9
    doc.brown
    Guest

    Re: Playing big audio file

    Quote Originally Posted by petrib View Post
    If you can't buffer the data partially in memory (then discard "used" data and load some more)
    I think this is possible writing a "ChunkedInputStream" that loads only small parts of the file:

    - load first chunk
    - create Player for first chunk
    - play chunk 1 while loading chunk 2
    - create Player for second chunk
    and so on...

    I use this technique to stream (arbitrary long) internet radio streams. One problem remains as there is a small gap between the player switch which can be heard.

  10. #10
    Registered User
    Join Date
    Aug 2011
    Posts
    39

    Re: Playing big audio file

    Just wondering, why do you do that ? It is possible to do progressive playback for radio streams.

Similar Threads

  1. Getting MediaException while playing .3gp audio file
    By bhakki in forum Mobile Java General
    Replies: 6
    Last Post: 2011-10-31, 21:52
  2. Playing an audio file with APS
    By etayg in forum Symbian
    Replies: 1
    Last Post: 2010-08-10, 14:51
  3. Playing audio file with APS
    By Digish in forum Symbian
    Replies: 3
    Last Post: 2009-04-23, 09:24
  4. Playing Audio file
    By Tatavarthi in forum Symbian
    Replies: 7
    Last Post: 2009-04-04, 13:37
  5. Playing Audio File
    By Kavit Patel in forum Symbian
    Replies: 10
    Last Post: 2008-01-05, 11: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
  •  
×