Implementation of media player on google action

https://developers.google.com/actions/assistant/responses#json

Nodejs code for media player on google action:

if (!conv.surface.capabilities.has(‘actions.capability.MEDIA_RESPONSE_AUDIO’)) {
conv.ask(‘Sorry, this device does not support audio playback.’);
return;
}
conv.ask(new MediaObject({
name: ‘Jazz in Paris’,
url: ‘https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3’,
description: ‘A funky Jazz tune’,
icon: new Image({
url: ‘https://storage.googleapis.com/automotive-media/album_art.jpg’,
alt: ‘Album cover of an ccean view’,
}),
}));

Dialog flow code for media player on google action:

{
“payload”: {
“google”: {
“expectUserResponse”: true,
“richResponse”: {
“items”: [
{
“mediaResponse”: {
“mediaType”: “AUDIO”,
“mediaObjects”: [
{
“contentUrl”: “https://storage.googleapis.com/automotive-media/Jazz_In_Paris.mp3”,
“description”: “A funky Jazz tune”,
“icon”: {
“url”: “https://storage.googleapis.com/automotive-media/album_art.jpg”,
“accessibilityText”: “Ocean view”
},
“name”: “Jazz in Paris”
}
]
}
}
]
},
“userStorage”: “{“data”:{}}”
}
},
“outputContexts”: [
{
“name”: “/contexts/_actions_on_google”,
“lifespanCount”: 99,
“parameters”: {
“data”: “{}”
}
}
]
}

1 Like