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

标签 android actions-on-google android-music-player assistant

我正在开发一个 Android 音乐播放器应用程序。我想将它与 Google Assistant 集成,以通过语音控制播放和搜索歌曲。 我已经根据 official documentation 的说明在我的应用程序中实现了媒体 session 。 .

当请求智能助理用我的应用播放某些内容时,我必须说“在 MyApp 上播放一些艺术家”。当我说“播放一些艺术家”时,Google 助理告诉我我没有配置默认音乐提供商。

这会将我带到 Google 助理应用中的以下屏幕:

enter image description here

我注意到 MyApp 没有列在“您的音乐服务”中。 我的问题如下:我必须在我的应用程序中进行哪些更改才能将其选为默认音乐服务?

供您引用,这是 list 文件:

<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 助手目前允许列表中的某些合作伙伴应用。合作伙伴我不确定你到底在做什么。如果您在一家大型音乐提供商公司工作,您可能已经有一位 Google 业务发展代表,他应该能够为您联系合适的人。

如果您还没有以某种方式与 Google 取得联系,此页面上有各种联系方式:https://developers.google.com/actions/在“从第一天起就获得所需的支持”部分。我会尝试其中的一个或多个,希望这会让您加入合适的团队。

关于android - 将我的应用定义为 Google 助理的默认音乐服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47962336/

相关文章:

google-cloud-platform - Dialogflow Google Assistant Alpha 版本始终失败并显示以下消息 : "For en: Your sample pronunciations are structured incorrectly."

java - 从 Intent 中获取额外(变量)

android - 样式化 Android ProgressDialog

node.js - 在 Google Home 助理上播放 MP3 列表

actions-on-google - 关闭 Google 助理的问候语/欢迎语

android - 使用 Android Intent 播放多首歌曲

Android - 从立体声 .mp3 中提取一个 channel ,通过 AudioStream 的两个 channel 应用它

java - 播放音乐的服务+ Activity

android - 在android中使用ormlite执行查询的问题

android - 如何临时释放相机?