4

I have a Google Action that plays some pre-recorder stories. I use mediaObject to play them. Something like:

conv.ask(new MediaObject({
        name: title,
        url: storia,
        description: autore,
        image: new Image({
            url: largeImageUrl,
            alt: title,
        }),
    }));

I since some stories are longer than 4 minutes, I've split them in two, and use a media status control:

app.intent('Media Status', (conv) => {
const mediaStatus = conv.arguments.get('MEDIA_STATUS');
if (mediaStatus && mediaStatus.status === 'FINISHED') {
    console.log(`track finished: ${conv.user.storage.track}`);
    console.log(`storia2: ${conv.data.storia2}`);
    if (conv.data.storia2 !== undefined) {
        secondaParte =  `<audio src="` + randomPhrase(continuaFavola) + `">
                    <desc>Vediamo come va a finire...</desc>
                    </audio>`;
        storia = conv.data.storia2;
        conv.data.storia2 = undefined;
        conv.ask(new SimpleResponse('<speak>' + secondaParte +'</speak>'));
    }  else {
        conv.close(new SimpleResponse('<speak>' + goodnight  +'</speak>'));
    }
} else {
    conv.ask('Media Status ignoto');
}

});

It works.

The problem is that sometimes, while the media object is playing, if I say the "stop" command, the media object stops, but the stop intent is not triggered (it should say "Ok, goodbye" and close the action), so the action remains waiting for a prompt. A second stop actually execute the stop intent. So basically I need to stop it twice.

In the log I can't see any trace of the first stop command (that has been clearly received since the media object has stopped), only the second one.

Even worse, when I play the second half of the story, this time the command is supposed to close:

conv.close(new MediaObject({ ... );

If I say "OK Google, stop", instead of stopping the playback, the action ends but the media object keeps playing (I know the action is quit because I can give standard commands, like "what's the time" or "set an alarm".

What a mess.

So is there a way to close the action, and force stop of any currently playing media object?

Sairaj Sawant
  • 1,842
  • 1
  • 12
  • 16

0 Answers0