برنامه خود را به عنوان یک برنامه ویدیویی علامت گذاری کنید
برای نشان دادن اینکه برنامه شما از ویدیو پشتیبانی می کند، یک فایل XML به نام automotive_app_desc.xml را به فهرست res/xml/ پروژه خود اضافه کنید. در این فایل مطالب زیر را قرار دهید:
انتشار برنامههایی که از صدا در حین رانندگی پشتیبانی میکنند به شرکای دسترسی اولیه محدود میشود. در حالی که این ویژگی در مرحله آزمایشی است، میتوانید با دنبال کردن دستورالعملهای موجود در این بخش، اپلیکیشن خود را برای پشتیبانی آماده کنید.
به طور کلی، همه برنامههای ویدیویی باید وقتی محدودیتهای تجربه کاربر فعال هستند، پخش را متوقف کنند، همانطور که در Meet نیازمندیهای حواسپرتی راننده توضیح داده شده است.
با این حال، برخی از وسایل نقلیه این توانایی را دارند که کنترلهای پخش بهینهشده رانندگی را در حالی که محدودیتهای تجربه کاربر فعال هستند، نمایش دهند که ادامه پخش صدا را ممکن میسازد.
شکل 1 : رانندگی کنترلهای پخش بهینه برای برنامهای که از صدا در حین رانندگی پشتیبانی میکند.
Codelab
برای اجرای پشتیبانی از صدا در حین رانندگی، یک راهنمای گام به گام را دنبال کنید
arrow_forward
اعلام کنید که برنامه شما از صدا در حین رانندگی پشتیبانی می کند
برای نشان دادن اینکه برنامه شما هنگام رانندگی از صدا پشتیبانی می کند، عنصر <uses-feature> زیر را در مانیفست خود اضافه کنید:
از آنجایی که فعالیتهای برنامه شما توسط محدودیتهای UX سیستم پنهان است، برنامه شما باید از پخش پسزمینه برای ادامه پخش صدا در حین رانندگی پشتیبانی کند. برای جزئیات در مورد نحوه انجام این کار با استفاده از کتابخانه Media3، به پخش پسزمینه با MediaSessionService مراجعه کنید.
برنامه شما باید یک اعلان MediaStyle ارسال کند که شامل MediaSession برنامه شما باشد. اگر از MediaSessionService استفاده می کنید، این به طور پیش فرض برای شما انجام می شود.
پشتیبانی را تعیین کنید
برای تعیین اینکه آیا دستگاهی هنگام رانندگی از صدا پشتیبانی می کند یا خیر، می توانید از کلاس CarFeatures از کتابخانه androidx.car.app:app استفاده کنید.
از این اطلاعات برای تغییر رفتار برنامه خود بسته به قابلیت های دستگاهی که روی آن اجرا می شود استفاده کنید. در دستگاههایی که هنگام رانندگی از صدا پشتیبانی نمیکنند، برنامه شما همچنان باید دستورالعمل DD-2 را رعایت کند.
بله، Widevine DRM L3 در سیستم عامل Android Automotive پشتیبانی می شود.
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی."],[],[],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."]]