اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release
بدلاً من aosp-main
لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
تنفيذ الراديو باستخدام "الوسائط"
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يتم تنفيذ واجهة مستخدم الراديو كتطبيق مستقل. يمكن العثور على تعليمات حول كيفية دمج واجهة مستخدم
الراديو مع جهاز الراديو في مقالة تنفيذ الراديو.
يوضّح القسم التالي كيفية دمج واجهة مستخدِم "الراديو" مع الوسائط لتقديم تجربة
سلسة تتيح للمستخدمين التفاعل مع مصادر الوسائط والراديو كما لو كان
تطبيقًا واحدًا.
يوضِّح المخطّط البياني التالي كيفية تنفيذ عملية التنفيذ المرجعية لتطبيق "الراديو والوسائط"
لمسار المستخدم في تبديل التطبيقات.

الشكل 1: مسار المستخدم في تبديل مصدر الوسائط
لتوفير انتقال سلس بين "الراديو" والتطبيقات الأخرى في "الوسائط"، تحدِّد مكتبة
car-media-common
أهداف Android التي يمكن استخدامها لبدء أداة اختيار
مصدر الوسائط. في AOSP، يتم تنفيذ هذا الاختيار في "مشغّل التطبيقات"، ما يعرض واجهة المستخدم نفسها
لتشغيل التطبيقات، ولكن يتم فلترتها لعرض مصادر الوسائط فقط.
يمكن لمصنّعي المعدّات الأصلية اختيار استخدام ميزة "مشغّل التطبيقات" الحالية كما هي، أو استخدام أداة اختيار مخصّصة
لمصدر الوسائط.
يمكن أن يعمل أداة الاختيار بوضعَين:
- المسار العادي: بعد استخدام أداة الاختيار، يتم عرض المصدر المحدّد في "الوسائط" كي تتمكّن
من تصفّح محتواه.
- بصفتك مفتاح تبديل: يتم استخدام أداة اختيار للتبديل بين المصادر، ولكن لا يتم عرض الوسائط
للمستخدم. وينطبق ذلك على رمز أداة الاختيار في الصفحة الرئيسية. بعد اختيار مصدر، يتم عرض
أحدث شاشة سابقة للمستخدم (في هذه الحالة، الصفحة الرئيسية).
يمكن الحصول على النية المستخدَمة للتبديل بين مصادر الوسائط من الطريقة
MediaSource#getSourceSelectorIntent()
التي تقبل popup
قيمة منطقية تعرض نية لبدء كل عملية من عمليات البث الموضّحة أعلاه.
يتم تحديد النوايا الفعلية على الرابط
packages/apps/Car/libs/car-media-common/res/values/config.xml
. لأجل
تخصيص هذا الإعداد، استخدِم الصور المتراكبة في وقت الإنشاء.
استبدال تطبيق "راديو Google"
بما أنّ تطبيق "الراديو" ينفِّذ ميزتَي "تصفُّح الوسائط" و"جلسة الوسائط"، يتم عرض تطبيق "الراديو"
في مشغِّل التطبيقات. لمنع تشغيل الوسائط عندما ينقر المستخدم على الرمز، يجب توفُّر عنصرين. يجب أن يستوفي الراديو الشروط التالية:
- أن يكون لديك نشاط مشغِّل
- أن يتمّ الإقرار به كـ مصدر مخصّص لإجراء ذلك، أضِف اسم المكوّن إلى مفتاح
custom_media_packages
في car-media-common/res/values/config.xml
.
القيود المفروضة على تجربة المستخدِم
يجب أن تلتزم الوسائط بجميع القيود المفروضة على تجربة المستخدم في ما يتعلّق بإلهاء السائقين. لتنفيذ ذلك، يجب أن يستمع Media إلى CarUXRestrictionManager وينفّذ جميع سياساته.
- يجب أن تتصل الوسائط بمكتبة Car
وتحصل على مثيل من
CarUXRestrictionManager.
- يجب أن تشترك الوسائط في التحديثات في قائمة
CarUxRestrictions
وتنفذها على النحو الموضّح في المستندات.
- من المهم بشكل خاص بالنسبة إلى الوسائط ما يلي:
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Implement radio with Media\n\nThe Radio UI is implemented as an independent app. Instructions on how to integrate a\nRadio UI to the radio hardware can be found at\n[Implement radio](/docs/automotive/broadcast-radio).\n\nThe following section describes how to integrate Radio UI with Media to provide users with a\nseamless experience that enables users to interact with media sources and radio as if they were a\nsingle app.\n\nMedia source switching user flow\n--------------------------------\n\nThe following diagram illustrates how the reference implementation of Radio and Media implements\nthe app switching user flow.\n\n**Figure 1.** Media source switching user flow\n\nTo provide a seamless transition between Radio and other apps in Media, the\n`car-media-common` library defines Android intents that can be used to launch a media\nsource selector. In AOSP, this selector is implemented in the App Launcher, presenting the same UI\nfor launching apps but filtered to display only media sources.\n\nOEMs can opt to take the current App Launcher implementation as is, or implement a customized\nmedia source selector.\n\nThe selector can act in two modes:\n\n- **Normal flow.** After using the selector, the selected source is displayed in Media so the user can browse its content.\n- **As a switch.** A selector is used to switch sources, but the media is not displayed to the user. This is true of the Selector icon on the Home Page. After selecting a source, the most recent previous screen is displayed to the user (in this case, the Home page).\n\nThe intent used to switch between media sources can be obtained from the\n`MediaSource#getSourceSelectorIntent()` method, which accepts a `popup`\nBoolean that returns an intent to launch each of the flows described above.\n\nThe actual intents are defined at\n`packages/apps/Car/libs/car-media-common/res/values/config.xml`. To\ncustomize this configuration, use build-time overlays.\n\n### Replace the Radio app\n\nGiven that the Radio app implements Media Browse and Media Session, Radio is displayed\nin the App launcher. To prevent launching Media when a user clicks the icon, two elements\nare required. Radio *must*:\n\n- Have a *launcher* activity.\n- Be declared as a *custom source* . To do so, add the component name to the `custom_media_packages` key in `car-media-common/res/values/config.xml`.\n\nUX driving restrictions\n-----------------------\n\nMedia must observe all UX driving distraction restrictions. To do so, Media must listen to the\n[CarUXRestrictionManager](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictionsManager)\nand implement all its policies.\n\n- Media must connect to the [Car](https://developer.android.com/reference/android/car/Car) library and get an instance of [CarUXRestrictionManager](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictionsManager).\n- Media must subscribe to updates in the list of [CarUxRestrictions](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions) and implement them as documented.\n- Particularly important for Media are:\n - [UX_RESTRICTIONS_NO_SETUP](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions.html#UX_RESTRICTIONS_NO_SETUP). In this case, the sign-in flow must be disabled.\n - [UX_RESTRICTIONS_LIMIT_STRING_LENGTH](https://developer.android.com/reference/android/car/drivingstate/CarUxRestrictions.html#UX_RESTRICTIONS_LIMIT_STRING_LENGTH). Error messages and other text provided by the media apps must be limited to the given length."]]