简体   繁体   English

将我的应用定义为Google智能助理的默认音乐服务

[英]Define my app as Google Assistant's default music service

I am developping an Android Music Player application. 我正在开发Android音乐播放器应用程序。 I'd like to integrate it with Google Assistant to control playback and search songs by voice. 我想将其与Google智能助理集成,以控制播放和按语音搜索歌曲。 I already implemented a Media Session in my app according to instructions from the official documentation . 我已根据官方文档中的说明在我的应用中实现了媒体会话。

When requesting the Assistant to play something with my app, I have to say something like "Play some artist on MyApp ". 当请求助理使用我的应用程序播放内容时,我不得不说“在MyApp上播放一些艺术家 ”之类的内容。 When I say "Play some artist ", Assistant tells me that I don't have configured a default music provider. 当我说“播放一些艺术家 ”时,助理告诉我我没有配置默认音乐提供商。

This leads me to the following screen in the Google Assistant app: 这会将我引导至Google智能助理应用中的以下屏幕:

在此输入图像描述

I note that MyApp is not listed in "Your music services". 我注意到MyApp未列在“您的音乐服务”中。 My question is the following: what do I have to change in my app for it to be choosable as the default music service ? 我的问题如下:我在应用程序中需要更改哪些内容才能将其作为默认音乐服务进行选择?

For your information, here is the Manifest file: 有关您的信息,这里是清单文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="fr.nihilus.music">

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <uses-feature
        android:name="android.hardware.audio.output"
        android:required="true" />

    <application
        android:name=".NihilusMusicApplication"
        android:allowBackup="true"
        android:fullBackupContent="@xml/backup"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:ignore="GoogleAppIndexingWarning">

        <!-- Main activity for music browsing. -->
        <activity
            android:name=".HomeActivity"
            android:launchMode="singleTop"
            android:theme="@style/AppTheme.NoActionBar">

            <!-- Make this Activity visible in launcher -->
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <!-- Make this activity available as the default music app. -->
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.APP_MUSIC" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

            <!-- Intent filter that enables voice searches, such as "Play the Beatles" -->
            <intent-filter>
                <action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

            <meta-data
                android:name="android.app.default_searchable"
                android:value=".ui.SearchResultActivity" />
            <meta-data
                android:name="android.app.shortcuts"
                android:resource="@xml/shortcuts" />
        </activity>

        <!-- Activity showing detail and tracks of an album. -->
        <activity
            android:name=".ui.albums.AlbumDetailActivity"
            android:parentActivityName=".HomeActivity"
            android:theme="@style/AppTheme.NoActionBar" />

        <!-- Activity for toggling user preferences. -->
        <activity
            android:name=".settings.SettingsActivity"
            android:label="@string/action_settings"
            android:parentActivityName=".HomeActivity" />

        <!--
            Activity to be opened as a dialog window when a track is selected
            from the file explorer.
         -->
        <activity android:name=".FileViewerActivity"
            android:theme="@style/AppTheme.FileViewer"
            android:excludeFromRecents="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />

                <data
                    android:mimeType="audio/*"
                    android:scheme="content" />
            </intent-filter>
        </activity>

        <!--
            Main music service, provides media browsing and media playback services to
            consumers through MediaBrowserService and MediaSession. Consumers connect to it through
            MediaBrowser (for browsing) and MediaController (for play session control)
        -->
        <service
            android:name=".service.MusicService"
            android:exported="true"
            android:label="@string/playback_service_label"
            android:process=":musicplayer"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.media.browse.MediaBrowserService" />
            </intent-filter>
        </service>

        <!--
            A receiver that will receive media buttons and send as intents to MusicService.
            Required on pre-Lollipop.
        -->
        <receiver android:name="android.support.v4.media.session.MediaButtonReceiver">
            <intent-filter>
                <action android:name="android.intent.action.MEDIA_BUTTON" />
            </intent-filter>
        </receiver>
    </application>

</manifest>

Google assistant at the moment allows certain partner apps in the list. 目前,Google助理允许列表中的某些合作伙伴应用。 To partner I'm not sure exactly what you do. 对伙伴我不确定你做了什么。 If you are at one of the large music provider companies you probably already have a Google Business Development rep who should be able to connect you with the right people. 如果您是大型音乐提供商公司之一,那么您可能已经拥有了Google Business Development代表,他们应该能够将您与合适的人联系起来。

If you aren't already in touch with Google somehow, there are various contact options on this page: https://developers.google.com/actions/ in the "Get the support you need from day one" section. 如果您尚未以某种方式与Google保持联系,则此页面上有各种联系方式: https//developers.google.com/actions/在“从第一天获得您需要的支持”部分。 I'd try on or more of these, which hopefully will get you to the right team. 我会尝试或更多这些,希望能让你找到合适的团队。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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