Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Media

Media responses let your Actions play audio content with a playback duration longer than the 240-second limit of SSML. Media responses work on both audio-only devices and devices that can display visual content. On a display, media responses are accompanied by a visual component with media controls and (optionally) a still image.

When defining a media response, use a candidate with both the RICH_RESPONSE and LONG_FORM_AUDIO surface capabilities so that Google Assistant only returns the rich response on supported devices. You can only use one rich response per content object in a prompt.

Audio for playback must be in a correctly formatted MP3 file. MP3 files must be hosted on a web server and be publicly available through an HTTPS URL. Live streaming is only supported for the MP3 format.

example
app.handle('media', (conv) => {
  conv.add('This is a media response');
  conv.add(new Media({
    mediaObjects: [
      {
        name: 'Media name',
        description: 'Media description',
        url: 'https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3',
        image: {
          large: JAZZ_IN_PARIS_IMAGE,
        }
      }
    ],
    mediaType: 'AUDIO',
    optionalMediaControls: ['PAUSED', 'STOPPED'],
    startOffset: '2.12345s'
  }));
});
see

Developer Documentation

Hierarchy

Implements

Properties

Optional firstMediaObjectIndex

firstMediaObjectIndex: number

0-based index of the first Media Object in media_objects to play. If unspecified, zero or out-of-bounds, playback starts at the first media object in media_objects.

Optional mediaObjects

mediaObjects: MediaObject[]

List of Media Objects

Optional mediaType

Optional optionalMediaControls

optionalMediaControls: OptionalMediaControl[]

Optional media control types this media response session can support. If set, request will be made to 3p when a certain media event happens. If not set, 3p must still handle two default control type, FINISHED and FAILED.

Optional repeatMode

repeatMode: All | Off | RepeatModeUnspecified

Repeat mode for the list of Media Objects.

Optional startOffset

startOffset: string

Start offset of the first media object.

Generated using TypeDoc