×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Feb 2007
    Posts
    4

    AMR audio streaming player

    Hello,

    we are making AMR based audio streaming player (j2me), because it supports streaming via HTTP. (source: MIDP: Mobile Media API Developer's Guide v2.0, page 20
    "Note: HTTP streaming is supported for the content type "audio/amr" from the S60 3rd Edition onwards.")

    We have Nokia N80 phone, so S60 3rd demand is not problem. But, we have some problems with player; It downloads whole file first, and then player plays it. We definied buffer size, but it didnt helped.

    Here's code about buffer and player itself:

    Buffer:

    private InputStream urlToStream(String url) throws IOException
    {
    // Open connection to the http url...
    HttpConnection connection = (HttpConnection) Connector.open(url);
    DataInputStream dataIn = connection.openDataInputStream();
    byte[] buffer = new byte[1000];
    int read = -1;
    int lk = 0;
    // Read the content from url.
    ByteArrayOutputStream byteout = new ByteArrayOutputStream();
    while ((read=dataIn.read(buffer))>=0)
    {
    lk++;
    form.append("Lukumaara: " + lk);
    byteout.write(buffer, 0, read);
    }
    dataIn.close();
    connection.close();
    // Fill InputStream to return with content read from the URL.
    ByteArrayInputStream byteIn =
    new ByteArrayInputStream(byteout.toByteArray());
    return byteIn;
    }


    Player:

    public void play(String url) {
    try {

    String murl = new String("http://xxx.xxx.xxx.xxx/What_Love.amr");
    HttpConnection conn = (HttpConnection) Connector.open(murl, Connector.READ_WRITE);
    form.append(murl);
    InputStream is = urlToStream(murl);

    player = Manager.createPlayer(is, "audio/amr");
    player.addPlayerListener(this);
    player.realize();



    player.prefetch();
    player.start();
    }
    catch(Throwable t) {
    reset();
    }
    }


    That "lukumaara: + lk" is our "debug"; With that we can see, is there really buffering. In test phase we saw that there's really buffering, so it seems to work.

    We have definied Mime type audio/amr to our server, so that's not the problem. So, any ideas where is a problem, is there something what we havent noticed?

  2. #2
    Registered User
    Join Date
    Feb 2007
    Posts
    5

    Re: AMR audio streaming player

    hi, antix!

    A little correction, not take bad!..but listen here: There is no need of doing a transforming DataInputStream to InputStream in the way your are doing it.
    THe idea is right, read all of the data input stream, put in on an ByteArrayOutputStream, then you get the byte array and uses to construct a byteArrayInputStream.
    But if you want a InputStream why you don't use the method of the HttpConection OpenInputStream () directly instaed of OpenDataInputStream () . The InputStream if the mother class of all stream that for input. You can create a dataInputStream using an InputStream as parameter in the constructor, but there is no way back (and is logical). Sadly building an ByteArrayInputStream with an InputStream it's not directly and in that case, yes...you must do what you do. =D.

    So...after that...i suggest to use httpConnection.OpenInputStream ().
    I guess, that for streaming a media or data in general, you must have connection establish with the site where you are downloading that data. In your case you only get 1000 bytes, and then you close the connection. So there will be no more further streaimng of data.

    I suggest, to use InputStream in = httpConnection.OpenInputStream ().
    Then use it Manager.CreatePlayer(in,"data_format");
    after that the realize () prefetch () and start ()....as you did.

    Finaly close the connection later...
    I hope this help.
    Cya!

  3. #3
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: AMR audio streaming player

    antix, I am afraid that there is a typo in the MMAPI developer's manual. I need to doublecheck that from the documentation team, but HTTP streaming should be available only from 3rd Edition FP1 onwards.
    That's also the way HTTP streaming support is described in http://www.forum.nokia.com/document/...opers_Library/ MMAPI implementation notes.

    Hartti

  4. #4
    Registered User
    Join Date
    Feb 2007
    Posts
    4

    Re: AMR audio streaming player

    Quote Originally Posted by hartti
    antix, I am afraid that there is a typo in the MMAPI developer's manual. I need to doublecheck that from the documentation team, but HTTP streaming should be available only from 3rd Edition FP1 onwards.
    That's also the way HTTP streaming support is described in http://www.forum.nokia.com/document/...opers_Library/ MMAPI implementation notes.

    Hartti
    Hello,

    now we have a new situation: We noticed that phone can upgrade now to N80 Internet Edition via Nokia Software Updater, so we of course updated that asap, because it has Feature Pack 1, so that AMR streaming should be possible via HTTP. Update was successfull, I got now nice Internet folder in menu

    But, we have still problems with streaming: It still downloads whole file first, and then it plays it. We dont have any idea, where is the problem.

    Phone's version is V 4.0632.0.38, which should be N80 Internet Edition's software, right?

    Thanks,
    Antix

    EDIT:

    I have changed the code so that it uses locator when the player is created Manager.createPlayer("http://someurl/audio.amr"). In the nokia's document http://www.forum.nokia.com/document/...6B8928BB4C.pdf on page 15 it is stated that way. But same result, it still downloads whole file first.

    "S60 3rd Ed. FP 1 on page 6: HTTP streaming player is created using the Manager.createPlayer method with the locator starting "http://"."
    and "HTTP Streaming is supported only for the content types audio/amr and audio/amr-wb. With other types, the media data is downloaded completely before playing."
    Last edited by antix; 2007-03-12 at 20:57.

  5. #5
    Registered User
    Join Date
    Feb 2007
    Posts
    4

    Re: AMR audio streaming player

    Im confused now. I installed 3rd Edition FP1 SDK (nS60_jme_sdk_3rd_e_FP1.zip), and tried that program with emulator. It worked perfectly! I limited download speed to 10k/s, and the streaming worked still well (file was ~5MB). I installed same program to my phone, and it still download whole file..

    So, this tells that program works well, but in some reason my phone doesnt use that "fp1" feature, which makes possible to stream amr files via HTTP. I updated my phone to version is V 4.0632.038 (via Nokia Software Updater), which is N80IE software. Earlier version was N80's software.

    (information about update http://discussions.europe.nokia.com/...cending&page=1)

    So, where is my FP1 features?

  6. #6
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: AMR audio streaming player

    antix,

    N80 is NOT a 3rd Edition Feature Pack 1 phone. it is a S60 3rd Edition phone. It (or the Java implementation on it) does NOT support HTTP streaming.

    Nokia publishes phones which belong to a certain Edition (like 3rd edition) of a certain platform (for example S60). Additionally there are smaller updates to the platform editions, which are called feature packs (like Feature Pack 1). A phone cannot be upgraded to a newer edition (or feature pack level of the platform). As N80 is a S60 3rd Edition phone, it does not support the features which were added in the 3rd Edition Feature Pack 1 release. The Internet Edition is still a 3rd Edition release.

    Hope this clarifies the situation.
    Hartti

Similar Threads

  1. Half Duplex Audio Streaming
    By subhrajyotisaha in forum Symbian Media (Closed)
    Replies: 0
    Last Post: 2006-05-25, 04:39
  2. Creating a Streaming Player that support New Audio Codec
    By seechuny in forum Streaming and Video
    Replies: 0
    Last Post: 2005-07-25, 04:13
  3. Replies: 0
    Last Post: 2005-06-28, 15:57
  4. Is Audio Player Utility to play AMR Files is developed by anybody for Series 40
    By amitkumar_j2me in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2005-06-28, 15:56
  5. Streaming AMR audio with 6630?
    By nevis01 in forum Symbian Media (Closed)
    Replies: 0
    Last Post: 2004-12-03, 08:24

Posting Permissions

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