0

I am developing a music action. I use MediaObject to return and play audio. When I try actions on google home hub, at the bottom of the screen has 2 buttons for next and previous. Although there are more audio and I can say 'Next' for another audio, both of the buttons are disabled. How can I enable it? Thanks in advance!

two muppets

app.intent('Default Welcome Intent', async (conv) => {
    console.log(`Welcome: ${conv.user.last.seen}`);
    // Check if the device supports media playback
    if (!conv.surface.capabilities.has('actions.capability.MEDIA_RESPONSE_AUDIO')) {
        conv.close('Sorry, this device does not support audio playback.');
        return;
    }

    let audioData = await fetchData()

    // Initialize the index of first audioData
    console.log('Initialize the index for first time')
    conv.user.storage.track = 1
    conv.user.storage.audioData = audioData

    conv.ask(getRandomPrompt(conv, 'welcome'));
    // conv.ask(getRandomPrompt(conv, 'intro'));
    nextTrack(conv);
});

const nextTrack = (conv) => {
    console.log(`nextTrack: ${conv.user.storage.track}`);
    let audioData = conv.user.storage.audioData
    let track = audioData[0];
    // Persist the selected track in user storage
    if (conv.user.storage.track) {
        conv.user.storage.track = parseInt(conv.user.storage.track, 10);
        conv.user.storage.track++;
        if (conv.user.storage.track > audioData.length) {
            // Loop the tracks
            conv.user.storage.track = 1;
        }
        track = audioData[conv.user.storage.track - 1];
    } else {
        conv.user.storage.track = 1;
    }

    let hasScreen = conv.surface.capabilities.has('actions.capability.SCREEN_OUTPUT')
    console.log(`Current news: ${util.inspect(track)}`)
    if (hasScreen) {
        conv.ask('Has screen')
        // Create a media response
        // https://developers.google.com/actions/assistant/responses#media_responses
        conv.ask(new MediaObject({
            name: track.name,
            url: track.titleLink,
            icon: new Image({
                url: 'https://storage.googleapis.com/automotive-media/album_art.jpg',
                alt: 'Media icon'
            })
        }));
        // Add suggestions to continue the conversation
        if (supportsMore) {
            // Set the context to allow matching agent intents
            conv.contexts.set('more', 5);
            conv.ask(conv.user.storage.track === 1 ? suggestions1 : suggestions2);
        } else {
            conv.ask(suggestions3);
        }
    } else {
        conv.ask('There is no screen')
        // Create a media response
        // https://developers.google.com/actions/assistant/responses#media_responses
        conv.ask(new MediaObject({
            name: track.name,
            url: track.titleLink
        }));
    }
};

duy le
  • 53
  • 7
  • 1
    The buttons are always disabled. You can't actually modify their activity. – Nick Felker Jun 24 '19 at 15:22
  • When I say good morning to Google Home Hub, It will return some news( in video format). I can click next and previous button to navigate to the another news. You can see in this image (https://imgur.com/aLTo4TT). In my code, I just return an audio, and when the audio is finished, I return another audio. (I implement Media Status intent for checking status of current playing audio). So media player cannot know if there are other news or not. I think I need a way to tell media player that there are more news so it will enable next button for user to click. Is that right? How can I do that? – duy le Jun 25 '19 at 03:42
  • There is no way to provide that additional metadata. – Nick Felker Jun 25 '19 at 13:43
  • As I mentioned above, when I say good morning to Google Home Hub, It will return some news( in video format). I can click next and previous button in the screen to navigate to another news. Do you know how to do that??? – duy le Jun 25 '19 at 15:45
  • Developers cannot provide this info – Nick Felker Jun 25 '19 at 16:17
  • Do you mean at that time only developer who develop built-in actions( for google assistant or google home...) can make media player with next and previous button that can be clicked? Developers develop third-party application cannot do that? – duy le Jun 25 '19 at 17:12
  • That's the current status of the API, yes. – Nick Felker Jun 25 '19 at 17:51
  • Thank you very much! Let's post your answer at the answer section so I can mark it as resolved. – duy le Jun 26 '19 at 00:48

1 Answers1

1

The buttons are always disabled, as third-party developers are unable to provide metadata that there is another or previous track. Developers building a media response in their Action should expect this behavior, as it's the current state of the API.

Nick Felker
  • 11,536
  • 1
  • 21
  • 35