音声操作をサポートする
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
音声操作をメディアアプリに統合して、ドライバーの注意散漫を最小限に抑え、安全性と利便性を高めます。Android Auto または Android Automotive OS(AAOS)が音声操作を検出して解釈すると、onPlayFromSearch
コールバックを介してアプリに操作が配信されます。
コールバックを受け取ると、アプリはクエリ文字列に一致するコンテンツを見つけて再生を開始します。アプリは、ジャンル、アーティスト、アルバム、曲名、ラジオ局、プレイリストなど、さまざまなクエリ カテゴリに対応する必要があります。また、アプリは、音楽の一般的なリクエストを示す空のクエリ文字列を処理する必要があります。
アプリがあるメディア アイテムを再生しているときに、ユーザーが車載ディスプレイを見たり触れたりせずに、「[曲名] を再生して」と発声して、別の曲の再生をアプリに指示できるようにします。ユーザーは、ハンドル上の該当するボタンをクリックするか起動ワード(「OK Google」)を言うことで、クエリを開始できます。
Android Auto または AAOS が音声操作を検出して解釈すると、Android Auto または AAOS は onPlayFromSearch
を介してその音声操作をアプリに配信します。このコールバックを受け取ると、アプリは query
文字列に一致するコンテンツを見つけて再生を開始します。
ユーザーは、ジャンル、アーティスト、アルバム、曲名、ラジオ局、プレイリストなど、クエリにさまざまなカテゴリの用語を指定できます。検索のサポートを構築する際は、アプリに適したすべてのカテゴリを考慮してください。Android Auto または AAOS は、クエリが特定のカテゴリに当てはまることを検出すると、extras
パラメータにエクストラを付加します。次の追加情報を送信できます。
空の query
文字列を考慮に入れます。ユーザーが検索キーワードを指定しなかった場合、Android Auto または AAOS によってこの文字列が送信されることがあります。たとえば、ユーザーが「音楽を再生して」と言った場合、この場合、アプリは最近再生したトラックまたは新しいトラックを開始できます。
アプリで検索を迅速に処理できない場合は、onPlayFromSearch
でブロックしないでください。代わりに、再生状態を STATE_CONNECTING
に設定し、非同期スレッドで検索を行います。
再生が開始されたら、メディア セッションのキューに関連コンテンツを入力することを検討してください。たとえば、ユーザーがアルバムの再生をリクエストした場合、アプリはそのアルバムのトラックリストをキューに入力できます。
「再生」クエリに加えて、Android Auto と AAOS は、「音楽を一時停止」や「次の曲」のような再生制御のための音声クエリを認識します。また、これらのコマンドを onPause
や onSkipToNext
のような該当するメディア セッション コールバックと照合します。
音声対応の再生操作の実装について詳しくは、Google アシスタントとメディアアプリをご覧ください。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-08-22 UTC。
[null,null,["最終更新日 2025-08-22 UTC。"],[],[],null,["# Support voice actions\n\nIntegrate voice actions into your media app to enhance driver safety and\nconvenience by minimizing distractions. When Android Auto or Android Automotive\nOS (AAOS) detects and interprets a voice action, they deliver the action to your\napp through the `onPlayFromSearch` callback.\n\nUpon receiving the callback, your app finds content that matches the query\nstring and then starts playback. Your app must account for various query\ncategories, such as genre, artist, album, song name, radio station, or playlist.\nAdditionally, your app must handle an empty query string, which indicates a\ngeneral request for music.\n\nIf your app is playing one media item, the user can say \"Play \\[song title\\]\"\nto tell your app to play a different song without looking at or touching the\ncar's display. Users can initiate queries by clicking the appropriate buttons\non their steering wheel or speaking the hotwords \"OK Google.\"\n| **Design guidelines:** To learn more, see [Create apps](/cars/design/create-apps).\n\nWhen Android Auto or AAOS detects and interprets a voice action, Android Auto or\nAAOS delivers that voice action to the app through [`onPlayFromSearch`](/reference/android/support/v4/media/session/MediaSessionCompat.Callback#onPlayFromSearch(java.lang.String,%20android.os.Bundle)). Upon\nreceiving this callback, the app finds content to match the `query` string and\nthen starts playback.\n\nUsers can specify different categories of terms in their query: genre, artist,\nalbum, song name, radio station, or playlist, among others. When building\nsupport for search, account for all the categories that make sense for your app.\nIf Android Auto or AAOS detects that a given query fits into a specific\ncategory, extras are appended in the `extras` parameter. You can send these\nextras:\n\n- [`EXTRA_MEDIA_ALBUM`](/reference/android/provider/MediaStore#EXTRA_MEDIA_ALBUM)\n- [`EXTRA_MEDIA_ARTIST`](/reference/android/provider/MediaStore#EXTRA_MEDIA_ARTIST)\n- [`EXTRA_MEDIA_GENRE`](/reference/android/provider/MediaStore#EXTRA_MEDIA_GENRE)\n- [`EXTRA_MEDIA_PLAYLIST`](/reference/android/provider/MediaStore#EXTRA_MEDIA_PLAYLIST)\n- [`EXTRA_MEDIA_TITLE`](/reference/android/provider/MediaStore#EXTRA_MEDIA_TITLE)\n\nAccount for an empty `query` string, which can be sent by Android Auto or AAOS\nif the user doesn't specify search terms. For example, if the user says\n\"Play some music.\" In this case, your app can start a recently played or new\ntrack.\n\nIf your app can't process a search quickly, don't block in `onPlayFromSearch`.\nInstead, set the playback state to [`STATE_CONNECTING`](/reference/android/support/v4/media/session/PlaybackStateCompat#STATE_CONNECTING()) and perform the\nsearch on an async thread.\n\nWhen playback starts, consider populating the media session's queue with\nrelated content. For example, if the user requests an album to be played, your\napp could fill the queue with the album's tracklist.\n\nIn addition to \"Play\" queries, Android Auto and AAOS recognize voice queries to\ncontrol playback like \"pause music\" and \"next song\" and match these commands to\nthe appropriate media session callbacks, such as `onPause` and `onSkipToNext`.\n\nTo learn more about implementing voice-enabled playback actions, see\n[Google Assistant and media apps](/media/implement/assistant)."]]