Convenience players

The time-media frameworks provide convenience classes for playing and recording the three supported data types: audio, video, and MIDI. These convenience classes prepackage media networks for playing and recording, setting up the players, media stream, and other necessary components.

These components are automatically wired together so that all you need to provide is a media clip, or sequence, of the appropriate type. You can use these classes:

Because the convenience classes derive from TPlayer, you can synchronize them with players of any type.


If you do not need to control the individual components or connections, these classes provide an easy way to play and record time-media data. For more advanced applications, you would explicitly create and connect media components, forming your own media networks. (For more information about media components and networks, read Chapter 12, "Time-media overview.")

Getting started with audio

The simplest way to play and record audio is to use an instance of TSound. TSound automatically creates the correct audio stream and the necessary audio components to play and record the file. Conceptually, a TSound contains a microphone, an audio player, a speaker, and a gain factor that controls the input and output levels. TSound is derived from TPlayer:


Playing an audio clip

To play an audio clip with TSound:

  1. Instantiate TSound with the name of the file that contains the clip.
  2. Call Play or PlayFromBegin on the TSound.
For example, if you have a sound file named soundFile, to create a TSound instance and play the file:

      TStandardText soundFile("soundFile");
      TSound aSound(soundFile);
      aSound.PlayFromBegin();

TSound::PlayFromBegin is a shortcut for playing the file from the beginning--it is the same as seeking to the beginning of the file and calling the Play function. Play plays the file from the current position in the file. (When you first instantiate a TSound, the position is TTime::kZero.)

TSound can play the following audio file formats:

NOTE QuickTime files must be self-contained. For information on creating self-contained QuickTime files, see "QuickTime movie files" on page 319.

Recording audio

To record audio data with TSound:

  1. Create a TSound with the name of the file you want to record into.
  2. Call TSound::AdviseWillRecord to notify the TSound that recording is about to commence.
  3. Call TSound::Record.
    Recording stops when you run out of space or TSound::Stop() is called.
      TSound  aSound(soundFile, MOpenFile::kReadWrite);
      aSound.AdviseWillRecord();
      aSound.Record();
      // ...
      aSound.Stop();

Getting started with video

The simplest way to play video data, such as a QuickTime movie, is to create a TMovie instance. TMovie automatically creates the correct video stream and the necessary audio and video components to play the file. Conceptually, a TMovie contains a graphic player, a graphic view, and a TSound. TMovie is derived from TPlayer:


Playing a video clip

You must call TMovie::CreateView to create a view to display the video part of the movie. You then adopt the resulting view into the root view for the presentation in which you want it to appear. For example, you might set up the movie view as a child view of your document content view and call the TMovie::Play function from the HandleDo function of a command bound to a menu or button. TMovie makes all of the connections needed to play the movie.

NOTE You can only use movie files in the QuickTime Video format with TMovie.

To play a video clip with TMovie:

  1. Instantiate TMovie with the name of the file that contains the clip.
  2. Call TMovie::CreateView and adopt the resulting view into your root view.
  3. Call TMovie::Play on the movie.
For example, if you have a QuickTime movie file named movieFile, you can create a TMovie instance and play the movie.

      TStandardText movieFile("movieFile");
      TMovie  myMovie(movieFile);
      TView* movieView = myMovie.CreateView
      // Adopt view into root view
      myMovie.Play();

Recording a video clip

To record video data with
TMovie:

  1. Create a TMovie with the name of the file you want to record into.
  2. Call TMovie::AdviseWillRecord to notify the TMovie that recording is about to commence.
  3. Call TMovie::Record.
    Recording stops when you TMovie::Stop is called or you run out of space.
NOTE Recording with TMovie creates very large data files. TMovie currently does not support real-time compression.

      TMovie  aMovie(movieFile, MOpenFile::kReadWrite);
      aMovie.AdviseWillRecord();
      aMovie.Record();
      // ...
      aMovie.Stop();

Getting started with MIDI

The simplest way to play and record MIDI data in the CommonPoint application system is to create an instance of TMIDI. TMIDI automatically creates the correct MIDI stream and the necessary components to play and record MIDI data. Conceptually, a TMIDI object contains a MIDI player, and a MIDI interface. TMIDI is derived from TPlayer:


Playing a MIDI clip

To play a MIDI clip with TMIDI:

  1. Instantiate TMIDI with the name of the file that contains the clip.
  2. Call Play on the TMIDI.
For example, if you have a sound file named MIDIFile, to create a TMIDI object and play the file:

      TStandardText MIDIFile("MIDIFile");
      TMIDI aMIDI(MIDIFile);
      aMIDI.Play();

Recording MIDI

To record MIDI data with TMIDI:

  1. Create a TMIDI with the name of the file you want to record into.
  2. Call TMIDI::AdviseWillRecord to notify the TMIDI that recording is about to commence.
  3. Call TMIDI::Record.
    Recording stops when TMIDI::Stop() is called or you run out of space.
      TMIDI aMIDI(MIDIFile, MOpenFile::kReadWrite);
      aMIDI.AdviseWillRecord();
      aMIDI.Record();
      // ...
      aMIDI.Stop();


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker