×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    26

    AAC Audio Streaming OutOfMemoryError

    Hi All,
    I am trying to stream an audio content (AAC) from server. The player starts without any problem, and after some time throws OutOfMemoryError. I think I need to buffer the audio. Any one please guide me to implement (or get rid-of this error) buffering.

    Here is my code.
    Code:
                    HttpConnection c = null; 
    		InputStream is = null;
    
    		try {
    			c = (HttpConnection) Connector.open(streamURL, 
                        Connector.READ_WRITE);
    			int rc = c.getResponseCode(); 
    			System.out.println("Response Code " + rc);
    
    			if (rc != HttpConnection.HTTP_OK) {
    				showAlert("Server error returned");
    
    			} else {
    				playerForm.append("openInputStream");
    				is = c.openInputStream();
    				player = Manager.createPlayer(is, "audio/aac");
    				player.realize();
    				
    				 // get volume control for player and set volume to max
    				VolumeControl vc = (VolumeControl) player.getControl("VolumeControl");
                    if(vc != null)
                    {
                      vc.setLevel(100);
                    }
                  
                    
                    player.prefetch();
                    
    				player.start();
    			} 
    		} catch (Exception f) {
    			playerForm.append("Exception in player " + f.getMessage() + "\n");
    		} finally { // Aufräumarbeiten ausführen
    			if (is != null)
    				try {
    					is.close();					
    				} catch (IOException e) {
    				}
    			if (c != null)
    				try {
    					c.close();					
    				} catch (IOException e) {
    				}
    		}
    Thanks in advance.

    Regards
    Anish.

  2. #2
    Nokia Developer Expert
    Join Date
    May 2012
    Posts
    224

    Re: AAC Audio Streaming OutOfMemoryError

    Hi anishk,

    you can take look into "fetching content from a specified HTTP URL in the form of InputStream objects" here

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    26

    Re: AAC Audio Streaming OutOfMemoryError

    Thanks bandarap. I will check it and get back to you.

    Thanks and Regards
    Anish

  4. #4
    Registered User
    Join Date
    Mar 2009
    Posts
    26

    Re: AAC Audio Streaming OutOfMemoryError

    Hi bandarap, I checked that link, but it seems
    private InputStream urlToStream(String url) method first reads all data from server and writes it to the ByteArrayOutputStream.
    In my case the server file is a radio channel file whose file size is very larger and updates periodically. So i think it will not work for me.

    Thanks and Regards
    Anish

  5. #5
    Nokia Developer Expert
    Join Date
    May 2012
    Posts
    224

    Re: AAC Audio Streaming OutOfMemoryError

    same kind of your problem is already discussed in this thread

Similar Threads

  1. j2me audio streaming in audio call
    By wasantha.uwu in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2010-06-08, 11:33
  2. Replies: 1
    Last Post: 2009-02-19, 13:53
  3. Client-less streaming (streaming audio from a web page)
    By nfogel in forum Streaming and Video
    Replies: 0
    Last Post: 2008-06-15, 15:17

Posting Permissions

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