Чтобы указать, что ваше приложение поддерживает видео, добавьте XML-файл с именем automotive_app_desc.xml в каталог res/xml/ вашего проекта. В этом файле включите следующее содержимое:
Публикация приложений, поддерживающих аудио во время вождения, ограничена партнерами с ранним доступом. Пока эта функция находится в стадии бета-тестирования, вы можете подготовить свое приложение к поддержке, следуя указаниям в этом разделе.
Однако некоторые транспортные средства имеют возможность отображать оптимизированные для вождения элементы управления воспроизведением при активных ограничениях пользовательского опыта, что позволяет продолжать воспроизведение аудио.
Рисунок 1 : Оптимизированные элементы управления воспроизведением для приложения, поддерживающего воспроизведение звука во время вождения.
Кодовая лаборатория
Следуйте пошаговому руководству по внедрению поддержки звука во время вождения
arrow_forward
Укажите, что ваше приложение поддерживает воспроизведение звука во время вождения
Чтобы указать, что ваше приложение поддерживает воспроизведение звука во время вождения, добавьте в манифест следующий элемент <uses-feature> :
Поскольку действия вашего приложения скрыты системными ограничениями UX, ваше приложение должно поддерживать фоновое воспроизведение, чтобы продолжать воспроизводить аудио во время вождения. Подробнее о том, как это сделать с помощью библиотеки Media3, см. в разделе Фоновое воспроизведение с помощью MediaSessionService .
Ваше приложение должно публиковать уведомление MediaStyle , которое включает MediaSession вашего приложения. Если вы используете MediaSessionService , это обрабатывается для вас по умолчанию .
Определить поддержку
Чтобы определить, поддерживает ли устройство воспроизведение звука во время вождения, можно использовать класс CarFeatures из библиотеки androidx.car.app:app .
Используйте эту информацию для изменения поведения вашего приложения в зависимости от возможностей устройства, на котором оно запущено. На устройствах, которые не поддерживают аудио во время вождения, ваше приложение все равно должно соответствовать рекомендациям DD-2 .
Да, Widevine DRM L3 поддерживается в Android Automotive OS.
Контент и образцы кода на этой странице предоставлены по лицензиям. Java и OpenJDK – это зарегистрированные товарные знаки корпорации Oracle и ее аффилированных лиц.
Последнее обновление: 2025-07-29 UTC.
[null,null,["Последнее обновление: 2025-07-29 UTC."],[],[],null,["# Build video apps for Android Automotive OS\n\nIn addition to the guidelines described in [Build parked apps for Android\nAutomotive OS](/training/cars/parked/automotive-os), there are some requirements specific to video apps.\n| **Design guidelines:** Refer to [Adapt video apps](https://developers.google.com/cars/design/create-apps/parked-passenger-apps/overview) for UX guidance specific to video apps.\n| **Important:** Google takes driver distraction very seriously. Your app must meet specific criteria before it can be listed on Google Play for Android Automotive OS. By adhering to these requirements, you can make it easier to build and test your app. For more information, see [Android app quality for cars](/docs/quality-guidelines/car-app-quality?category=video).\n\nMark your app as a video app\n----------------------------\n\nTo indicate that your app supports video, add an XML file\nnamed `automotive_app_desc.xml` to the `res/xml/` directory in your project.\nIn this file, include the following content: \n\n \u003cautomotiveApp\u003e\n \u003cuses name=\"video\"/\u003e\n \u003c/automotiveApp\u003e\n\n| **Note:** You might see a lint error in Android Studio that says \"Expecting one of `media`, `notification`, `sms`, or `template` for the name attribute in uses tag.\" This can be safely ignored by adding `tools:ignore=\"InvalidUsesTagAttribute\"` to the `\u003cuses\u003e` element.\n\nThen, within the [`\u003capplication\u003e`](/guide/topics/manifest/application-element) element of your manifest, add the\nfollowing [`\u003cmeta-data\u003e`](/guide/topics/manifest/meta-data-element) element referencing the XML file: \n\n \u003cmeta-data\n android:name=\"com.android.automotive\"\n android:resource=\"@xml/automotive_app_desc\"/\u003e\n\nSupport audio while driving\n---------------------------\n\nAudio while driving is a beta feature \nPublishing apps that support audio while driving is limited to early access partners. While this feature is in beta, you can prepare your app for support by following the guidance in this section. \n[Nominate yourself to be an early access partner →](https://goo.gle/440dHqw) \n\nIn general, all video apps must pause playback when user experience restrictions\nare active, as described in [Meet driver distraction requirements](/training/cars/parked/automotive-os#driver-distraction).\n\nHowever, some vehicles have the ability to display driving-optimized playback\ncontrols while user experience restrictions are active, making it possible to\ncontinue playing audio.\n**Figure 1**: Driving optimized playback controls for an app that supports audio while driving. \n[Codelab\nFollow a step-by-step guide to implement support for audio while driving\narrow_forward](/codelabs/audio-while-driving)\n\n### Declare that your app supports audio while driving\n\nTo indicate that your app supports audio while driving, add the following\n[`\u003cuses-feature\u003e`](/guide/topics/manifest/uses-feature-element) element in your manifest: \n\n \u003capplication ...\u003e\n ...\n \u003cuses-feature android:name=\"com.android.car.background_audio_while_driving\" android:required=\"false\"\u003e\n ....\n \u003c/application\u003e\n\n| **Important:** Setting the `android:required` attribute to `false` ensures that your app can still be distributed to devices that don't support audio while driving.\n\n### Support background playback\n\nBecause your app's activities are hidden by the system UX restrictions, your app\nmust support background playback to continue playing audio while driving. See\n[Background playback with a MediaSessionService](/media/media3/session/background-playback) for details on how to\naccomplish this using the Media3 library.\n\nYour app must post a [`MediaStyle`](/reference/androidx/media/app/NotificationCompat.MediaStyle) notification that includes your app's\n`MediaSession`. If you're using `MediaSessionService`, this is [handled for you\nby default](/media/media3/session/background-playback#notification).\n| **Caution:** If you don't use a service for background playback, playback may continue for a short period of time, but your app will eventually be [cached](/guide/components/activities/process-lifecycle) by the system, causing playback to end.\n\n### Determine support\n\nTo determine if a device supports audio while driving, you can use the\n[`CarFeatures`](/reference/androidx/car/app/features/CarFeatures#summary) class from the [`androidx.car.app:app`](/jetpack/androidx/releases/car-app) library. \n\n CarFeatures.isFeatureEnabled(context, CarFeatures.FEATURE_BACKGROUND_AUDIO_WHILE_DRIVING)\n\nUse this information to modify your app's behavior depending on the capabilities\nof the device it's running on. On devices that don't support audio while\ndriving, your app must still meet the [`DD-2`](/docs/quality-guidelines/car-app-quality?category=video#DD-2) guideline.\n\n### Test audio while driving\n\nTo test your implementation, you can [simulate driving](/training/cars/testing/emulator#simulate-driving) can using an\n[emulator image that supports audio while driving](/training/cars/testing/emulator?filter=audio-while-driving#generic-images).\n| **Caution:** Be sure to test that your app still meets the [`DD-2`](/docs/quality-guidelines/car-app-quality?category=video#DD-2) guideline on devices that don't support audio while driving.\n\nFrequently asked questions\n--------------------------\n\n### Is Widevine DRM supported?\n\nYes, Widevine DRM L3 is supported on Android Automotive OS."]]