×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    12

    What happens when play media from InputStream?

    I want to find out the way that MMAPI play media through InputStream.
    So I made an adapter to wrap the real InputStream:

    InputStream is = getClass().getResourceAsStream("x.mpg");
    mis = new MyInputStream(is);
    p = Manager.createPlayer(mis, "video/mpeg");
    p.realize();
    p.prefetch();
    .....
    p.play();

    I run the code on Emulator.

    class MyInputStream simply wraps InputStream and make some output to help me find which InputStream method is called and when called.
    When p.realize() is called, as a result, the InputStream.read() is called many times, and I find that all data in x.mpg is read. After realize returned , no more stream method called.

    There must be a large buffer to hold the data, but on real device, its imposible.
    So I'm wondering what happens on real device. Will the data be read only when needed? Read some data, play it , then read more, then play?
    And how about CreatePlayer through http?

    thanks.

  2. #2
    Regular Contributor
    Join Date
    Aug 2006
    Posts
    307

    Re: What happens when play media from InputStream?

    The InputStream supports native media player (i.e. a mobile OS component which is actually processing media on mobile phone) with the data from the specifyed source. InputStream is the basic way to support media player with data. However, there are other ways to support media player with data (through URL and customized DataSources), but they all are finally utilizing InputStream(s).

    The realize() method simply does a connection to the media, and retrieves enough information about it (length, video size, sound quality, etc.)

    The prefetch() method produces enough data (i.e. frames and audio data) to start the playback, but nothing more.

    The start() method starts playback and launches process of producing new video frames and audio data, so we can see video or listen to audio in our mobile phones.

    The native media player implementation is hidden from the user (and Java), and vary from mobile platform to mobile platform. The internal data buffers are no exception.

    The only main feature of the Java mobile player is amount of supported formats and mediums. Also there is a "progressive downloading" feature which becomes highly available on many mobile platforms. It allows to play media while it wasn't yet fully downloaded (either from local file or from the network). Of course, it's implementation is hidden from the Java programmers.

    The old mobile platforms are usually loading media-file into the memory before they will start playing it, but such functionality is still presented even on some new mobile phones. In this case to play a big media file with Java player, you must ensure that mobile phone's memory heap-size is bigger than your media file's size.
    Last edited by axs; 2007-04-05 at 08:32.

  3. #3
    Registered User
    Join Date
    Jul 2005
    Posts
    48

    Re: What happens when play media from InputStream?

    Does anyone know if it is possible to create a custom DataSource and SourceStream that would assist in speeding up the process of loading a video file into the media player off a phones storage?

    I have a similar issue as described above where I find when I pass a stream to the Manager.createPlayer that it loads the whole file into memory before playing and this can take a while on a 2-3MB file.

  4. #4
    Regular Contributor
    Join Date
    Aug 2006
    Posts
    307

    Re: What happens when play media from InputStream?

    Quote Originally Posted by sinkers
    Does anyone know if it is possible to create a custom DataSource and SourceStream that would assist in speeding up the process of loading a video file into the media player off a phones storage?

    I have a similar issue as described above where I find when I pass a stream to the Manager.createPlayer that it loads the whole file into memory before playing and this can take a while on a 2-3MB file.
    You are absolutely free to create a customized DataSource with N SourceStreams, but such solution will go through the same native player. So, if a native player is able to utilize N SourceStreams, it will, but in many cases it just loading data through the one SourceStream (aka InputStream), and limitations of the native media player (and mobile operating system's too) also will "work" here.

Similar Threads

  1. Recording in Amr Format
    By losym in forum Symbian Media (Closed)
    Replies: 12
    Last Post: 2009-03-26, 06:41
  2. cannot able to play a video file.
    By shalini.mishra in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2006-11-13, 16:54
  3. SIP content type
    By hlothman in forum Symbian Networking & Messaging (Closed)
    Replies: 8
    Last Post: 2006-05-17, 09:26
  4. can't play file from inputstream (no ending)
    By aluckybird in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2005-12-02, 07:49
  5. 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
  •  
×