Sunday, April 22, 2007

JAVA 認證心得 -- SCMAD (10)

MMAPI (Media using MIDP 2.0 and Mobile Media API)

##CONTINUE##

  • DataSource is available. DataSource.getStreams() be used to Get the collection of streams that this source manages. The collection of streams is entirely content dependent. The MIME type of this DataSource provides the only indication of what streams may be available on this connection.
  • Player’s Lifecycle
  • Controllable Interface is the base interface.

    Ø Player implements the interface and plays media data.

    Ø SourceStream implements the interface and provides custom protocol support. Not in MIDP 2.0.

    Ø DataSource is a class used to provide custom media protocols. Not in MIDP 2.0.

           javax.microedition.media.protocol.DataSource

  • Control interface is the super-interface for all controls that can be implemented by a Player. Only the identified controls are supported in MIDP 2.0.

    Ø Audio Controls

    - ToneControl controls the Tone Seqeuence format. Supported in MIDP 2.0.(setSequence(byte[] seq) can be called in UNREALIZED and REALIZED)

    - VolumeControl controls the Player’s volume. Supported in MIDP 2.0.

    - MIDIControl controls MIDI playback.

    - PitchControl controls the pitch of a MIDI note.

    - TempoControl controls the tempo of a MIDI note.

    Ø Video Controls

    - VideoControl controls video media playback.

    - FramePositioningControl controls the framing of video.

    Ø General Controls

    - StopTimeControl allows you to set a preset stop time. This is like a sleep-time.

    - RateControl is used in conjunction with TimeBase to calibrate time used by Player. It controls the playback rate of a Player. Rates are specified in “milli-percetage”

    - GUIControl is used to display a user interface for the associated Player.

    - RecordControl is used to record the media played by the Player.

    - MetaDataControl can be used to get some general meta-data information about the media content.

  • PitchControl raises or lowers the playback pitch of audio without changing the playback speed. PitchControl does not influence playback volume in any way.
  • PitchControl can be implemented in Players for MIDI media or sampled audio. It is not possible to set audible output to an absolute pitch value. This control raises or lowers pitch relative to the original.
  • The pitch change is specified in number of "milli- semitones" to raise the pitch. A Player which supports only 0 pitch change must not implement PitchControl.
  • MetaDataControl is used to retrieve metadata information included within the media streams. A MetaDataControl object recognizes and stores metadata and provides XML-like accessor methods to retrieve this information. Predefined keys are provided to refer to commonly used metadata fields (title, copyright, data, author).
  • The USE_GUI_PRIMITIVE constant defines a mode on how the GUI is displayed.
Manager
  • Manager class is a factory to get Player implementations.

Ø Default constants provided for Tone Sequence (TONE_DEVICE_LOCATOR) and MIDI playback (MIDI_DEVICE_LOCATOR). MIDI is not supported in MIDP 2.0.

  • Manager.playTone(int note, int duration, int volume) can be used to generate simple monotones.
  • Class Manager

    static Player createPlayer(InputStream stream, String type)

    static Player createPlayer(String locator)

Player
  • Player class is used to play media data. An implementation is obtained from the Manager factory.

Ø TimeBase is used by the Player to track time.

  • MIDP media API supports only InputStream where data is streamed sequentially.
  • Random seeking capabilities are provided in the DataSource and SourceStream classes, which are provided in the MMAPI.
  • Convenience constants MIDI_DEVICE_LOCATOR and TONE_DEVICE_LOCATOR can be used to get a MIDI (audio/midi) or Tone Sequence (audio/x-tone-seq) Player.
  • A TimeBase is a constantly ticking source of time. It measures the progress of time and provides the basic means of synchronizing media playback for Players.
  • In STARTED The following methods will throw an IllegalStateException if invoked .

    Ø setTimeBase()

    Ø setLoopCount()

  • PlayerListener is a listener interface that can be implemented and registered to a Player to listen to the Player’s events.
  • PlayerListener can have more than one associated listener. Only one method called playerUpdate()

Read more!

No comments: