×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Mar 2011
    Location
    Final Fantasy Land
    Posts
    31

    Exclamation Play large media files

    I want to make a program that can play large media files. When I use InputStream to load data from files, it'll load all data into InputStream. So it will take much time to run and doesn't run well. It play more slowly than normal.
    Now, I want to load a part of data into InputStream (like buffer) and play with this InputStream? After player finish a data, program will load next data to InputStream and play.
    How can I do that?

    PS: Sorry for my English.
    Last edited by Eagle King; 2011-05-09 at 10:55.

  2. #2
    Registered User
    Join Date
    Dec 2009
    Posts
    376

    Re: Play large media files

    This is the code for inputstream
    inputstream = connection.openInputStream();
    int length = (int) connection.getLength();
    if (length != -1)
    {
    byte incomingData[] = new byte[length];
    inputstream.read(incomingData);
    str = new String(incomingData);


    what you can do here when you read the data here in incomeing data let it be completely read but when you load it break this in array in particular size for e.g 1MB and now play this intervals one after another to achive more good response you can read data itself in chunks

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

    Re: Play large media files

    Quote Originally Posted by Eagle King View Post
    I want to make a program that can play large media files.
    Where are these files? In the JAR, in the file system, or on a remote server?

    Quote Originally Posted by Eagle King View Post
    It play more slowly than normal.
    How do you mean? I don't see how it can play slowly.

    Quote Originally Posted by Eagle King View Post
    Now, I want to load a part of data into InputStream (like buffer) and play with this InputStream? After player finish a data, program will load next data to InputStream and play.
    I'm afraid you cannot stream the audio data unless you're using a streaming protocol, or unless you create the media Player object from an unbuffered InputStream. Whether or not the InputStream is buffered depends on where the data is, and on the implementation.

    Graham.

  4. #4
    Registered User
    Join Date
    Mar 2011
    Location
    Final Fantasy Land
    Posts
    31

    Re: Play large media files

    These files are in the file system. I give the player file's path.
    It play interruptedly. It play and stop then play and stop... It acted like that. If the file is bigger than 45 MB, It won't play (opening video file error)

    Quote Originally Posted by grahamhughes View Post
    I'm afraid you cannot stream the audio data unless you're using a streaming protocol, or unless you create the media Player object from an unbuffered InputStream. Whether or not the InputStream is buffered depends on where the data is, and on the implementation.
    Graham.
    Could you tell me How I can do to use a streaming protocol? The file data is too large (about 100 MB) and the player can't play it normally.

    Quote Originally Posted by prssupe View Post
    str = new String(incomingData);
    I can't run this code. It throw Uncaught exception java/lang/OutOfMemoryError.

    Quote Originally Posted by prssupe View Post
    what you can do here when you read the data here in incomeing data let it be completely read but when you load it break this in array in particular size for e.g 1MB and now play this intervals one after another to achive more good response you can read data itself in chunks
    How can I put the chunk data into inputstream to play it?
    Last edited by Eagle King; 2011-05-11 at 11:39.

Similar Threads

  1. How to play media file in System media player in j2me????
    By mohammad_kaied in forum Mobile Java Media (Graphics & Sounds)
    Replies: 13
    Last Post: 2014-03-21, 16:53
  2. Media Player fails to play some sp midi files (S60) - JNI and a Prefetch error (-20)
    By kishban in forum Series 40 & S60 Platform Feedback Archive
    Replies: 0
    Last Post: 2009-01-19, 14:23
  3. Replies: 1
    Last Post: 2008-10-15, 16:08
  4. Replies: 0
    Last Post: 2005-06-08, 10:19

Posting Permissions

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