Creating a media sequence

You can use the MediaSequence subclass of MediaType to create a sequence of other MediaType objects. This class has only one constructor method, which takes no parameters and creates an empty sequence. You then add MediaType objects to the sequence using the setNewMediaItem() method. Each new MediaType object is added to the end of the sequence.
Note: You must not add null objects to a MediaSequence, as this will cause a NullPointerException.

Obviously creating a media sequence using the MediaSequence class could be quite a lengthy procedure. A much quicker way to create a media sequence is to use an array of MediaTypes. This array can be played by any method which accepts MediaTypes as parameters.

For example, the following array of MediaTypes says “Today’s date is… and the temperature is 32 degrees Celsius.”

public class InApp extends WVRApplication {
  .
  .
  .
  // Create a string to represent the voice segment category.
  public String category = new String("TempTodaySegments");
  // Create the Today, Temperature and Degrees voice segment objects
  public VoiceSegment vs_today			= new VoiceSegment(category, "Today");
  public VoiceSegment vs_temperature	= new VoiceSegment(category, "Temperature");
  public VoiceSegment vs_degrees_c		= new VoiceSegment(category, "Degrees");
	
  // Create media objects to play the date and temperature
  public AudioDate date				= new AudioDate();
  public AudioNumber temperature	= new AudioNumber(32);
	
  // Create a media sequence
  public MediaType[] tempToday = { VS_TODAY, date, VS_TEMPERATURE, temperature, VS_DEGREES_C};	
  .
  .
  .
  //Play the media sequence
  call.play(tempToday);
  .
  .
  .
}

The voice segments need to be recorded but the temperature is ‘spoken’ uses voice segments supplied with Blueworx Voice Response. The date is created dynamically at runtime based on the default timezone and is ‘spoken’ using supplied voice segments.