Jovo 4 Google Media Response

v4

#1

Hi, I’m trying to transition from Jovo 3 to Jovo 4.
In my action I need to play a long audio, in Jovo 3 I used the “mediaResponse” object:

this.$googleAction.$mediaResponse.playAudio({
name: “”,
description: “”,
url: “”,
image: {
large: {
alt: ‘’,
height: 0,
url: “”,
width: 0,
},
},
},
offset,
[
‘STOPPED’,
‘PAUSED’
],
);

I didn’t find in the new documentation how I can achieve the same result in Jovo4, I only saw the example for the Alexa Skill

this.$send(AudioPlayerPlayOutput, {
    message: 'Starting audio',
    audioItem: {
      stream: {
        url: 'https://s3.amazonaws.com/jovo-songs/song1.mp3',
      },
    },
  })

Can someone help me to understand how can I use MediaObjects with Jovo4 for my Google Action?


#2

Hi @radiosa,

Currently, Jovo v4 does not come with convenience support for Google Media Response like it does for Alexa AudioPlayer. However, similar to how you could do it for Alexa, you could build your own output using the nativeResponse property.

For example, you can add the response JSON sample code to an output template:

{
  platforms: {
    googleAssistant: {
      prompt: {
        override: false,
        content: {
          media: {
            mediaObjects: [
              // ...
            ],
          },
        }, 
     },
  },
}

#3

Hi @jan, thanks!
I managed to make it work with the Native Response. I have a problem with the Alexa AudioPlayer:
Like suggested in the guide, I have imported:
import { AudioPlayerPlayOutput } from ‘@jovotech/platform-alexa’;

In my JS code I have:

But I’m getting this error on the console:

The “AudioPlayer” interface is already enabled in the Alexa developer console.

Also, the following property “this.$alexa.audioPlayer;” is not working for me at the moment, I only managed to access to the AudioPlayer property using “this.$alexa.$request.context.AudioPlayer.offsetInMilliseconds;”
Am I missing something? Thanks in advance


#4

This is weird. We’ll take a look.

Does it work if you use this example? https://github.com/jovotech/jovo-framework/blob/v4/latest/examples/typescript/alexa/audioplayer/src/components/AudioPlayerComponent.ts