Discussion Board

Results 1 to 3 of 3

Thread: openInputStream

  1. #1
    Registered User
    Join Date
    Apr 2007


    i have used the following code in a file browser, to look for a song through the file directory, and select a file:

    try {
    if (fileName.endsWith(".mp3") || fileName.endsWith(".amr") || fileName.endsWith(".wma"))
    is = null;
    FileConnection fc =
    (FileConnection)Connector.open("file://localhost/" + currDirName + fileName);
    is = fc.openInputStream();

    and the following code to play the selected file:

    private void doPlay() {
    try {
    player = Manager.createPlayer(fileConnection.get_IS(), "audio/amr");
    } catch (IOException x) {

    With this coding, i am getting different outcomes on different phones.

    On Nokia N70, there is 15second wait before the song starts playing.
    On Nokia N91, the song does not play at all.
    On Sony K800i, the song plays immediately.

    I feel this has something to do with the openOutputStream method.
    Can somebody please help me with this.

  2. #2
    Regular Contributor
    Join Date
    Aug 2006

    Re: openInputStream

    Probably the reason is in the progressive loading feature which is available on most Sony Ericsson mobile phones, and on some N-series mobile phones from Nokia.

    IMHO the best way to create a player for the multi-platformed J2ME application is by providing Manager with the file URI only. In many cases the mobile platform is able to play files immediatelly and optimize playback speeds only through the URI interface.

  3. #3
    Registered User
    Join Date
    Dec 2004

    Re: openInputStream

    i agree with axs
    not to mention "audio/amr" as a content type may not work for all 3 file format u selected across platforms (like nokia had problems audio/x-wav on some phones and used audio/wav)

Similar Threads

  1. openinputstream() returns null
    By linne345 in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2006-06-08, 15:16
  2. openinputstream
    By Huack in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2005-08-16, 15:33
  3. HttpConnection in Nokia6600
    By sujithkumar in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2005-01-02, 15:40
  4. Trouble using openInputStream() with Nokia 12
    By fpaaske in forum Nokia M2M
    Replies: 5
    Last Post: 2004-04-28, 19:20
  5. 7650 openInputStream throws exception -20015
    By antmanes in forum Mobile Java General
    Replies: 5
    Last Post: 2003-04-07, 01: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