简体   繁体   中英

Google home action play/resume, forward/backward

Hello I am implementing a google home action, I already have it working but now I will like to add some more "intents", my action hits a webhook that return SSML like the one below, the audio starts to play right away, which is right.

<speech>Some text
  <audio src="https://example.com/mp3">Couldn't load the audio></audio>
<speech>

My intent it is not market as "end of conversation" is it possible to implement intents to pause the current audio file been played? (when I ask to pause, the assistant replies, nothing is playing and stops playing my file), how about moving forward or backwards 20s for instance?. All this capabilities are supported by alexa and that make me thought it will be possible here.

Thanks in advance for any tips

Not using the SSML tags, no. The SSML <audio> tag is more intended for short audio effects that enhance the text that goes with it. It is also limited to 120 seconds.

If you want to play an audio segment and have a little more control over the audio, take a look at the Media response . On a mobile device, it shows a basic audio player with some basic controls, although you do not have the same kind of control as you do with a native audio widget.

With this, you'll send back information as part of the richResponse in addition to at least one simpleResponse containing the text message:

"mediaResponse": {
  "mediaType": "AUDIO",
  "mediaObjects": [{
    "name": "Song One",
    "description": "This is the song", //optional
    "largeImage": {  // Or "icon", but these are optional
      "url": "https://...jpg"
    },
    "contentUrl": "https://...mp3"
  }]
}

Users can give commands such as "start over" and "pause" and they will be handled on the device. Other commands interrupt the audio and are sent back to the Assistant. So if you're playing an audio, you can have it respond to the user saying "hey google, play something else".

Note that the latter is different than Alexa's implementation. With Alexa, once you've started an audio stream - you're limited to audio controls. On the Assistant, you can issue any command that the Action supports and it will trigger the corresponding Intent that you've created.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM