קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
המדריך הזה מניח שיש לכם אפליקציית מדיה שמפעילה אודיו בטלפון, ושאפליקציית המדיה שלכם תואמת לארכיטקטורת אפליקציות המדיה של Android. בנוסף, תוכלו ללמוד מה האפליקציה שלכם צריכה מ-MediaBrowserService ומ-MediaSession כדי לפעול ב-Android Auto או ב-AAOS. אחרי שתשלימו את התשתית הבסיסית של המדיה, תוכלו להוסיף תמיכה ב-Android Auto וב-AAOS לאפליקציית המדיה שלכם.
אם האפליקציה מתמקדת בהפעלת מדיה של אודיו, כדאי להשתמש בכלים שמתוארים כאן. יש שתי דרכים ליצור אפליקציות מדיה לרכב:
משתמשים ב-MediaBrowserService וב-MediaSession כדי ליצור אפליקציה שאפשר להתחבר אליה ב-Android Auto וב-AAOS. כך ממשק מסך המידע והבידור יכול להציג ממשקי משתמש של חיפוש והפעלה של מדיה שעברו אופטימיזציה לשימוש ברכב.
במדריך הזה אנחנו מניחים שיש לכם אפליקציית מדיה שמפעילה אודיו בטלפון, ושאתם משתמשים באפליקציית מדיה שתואמת לארכיטקטורת אפליקציות המדיה של Android. במדריך הזה מתוארים הרכיבים הנדרשים של MediaBrowserService ושל MediaSession שהאפליקציה צריכה כדי להיות תואמת ל-Android Auto או ל-AAOS. אחרי שמשלימים את התשתית הבסיסית של המדיה, אפשר להוסיף תמיכה ב-Android Auto ולהוסיף תמיכה ב-AAOS לאפליקציית המדיה.
יצירת אפליקציות מדיה עם סרטונים
אם התוכן העיקרי שמוצג באפליקציה הוא סרטון, כדאי לעיין במאמרים הבאים:
המונחים האלה משמשים בהקשר של פיתוח אפליקציות מדיה לרכב:
דפדפן מדיה
API שמשמש אפליקציות מדיה כדי לגלות שירותים של דפדפן מדיה ולהציג את התוכן שלהם. Android Auto ו-AAOS משתמשים בדפדפן מדיה כדי למצוא את שירות דפדפן המדיה של האפליקציה.
דפדפן המדיה מארגן את התוכן במבנה עץ של אובייקטים מסוג MediaItem. פריט מדיה יכול להכיל את אחד מהדגלים האלה או את שניהם. פריט מדיה שאפשר לעיין בו ולהפעיל אותו, פועל כמו פלייליסט. אפשר לבחור את הפריט כדי להפעיל את כל הפריטים שמופיעים מתחתיו, או לעיין בפריטים שמופיעים מתחתיו.
FLAG_PLAYABLE מציין שהפריט הוא עלה בעץ התוכן.
הפריט מייצג זרם אודיו יחיד, כמו שיר באלבום, פרק בספר אודיו או פרק בפודקאסט.
FLAG_BROWSABLE מציין שהפריט הוא צומת בעץ התוכן ויש לו צאצאים. לדוגמה, הפריט מייצג אלבום, והפריטים שנגזרים ממנו הם השירים באלבום.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-08-22 (שעון UTC).
[null,null,["עדכון אחרון: 2025-08-22 (שעון UTC)."],[],[],null,["# Media apps for cars overview\n\nThis guide assumes you have a media app that plays audio on a phone and that\nyour media app conforms to Android media app architecture. You also learn what\nyour app needs from `MediaBrowserService` and `MediaSession` to run on Android\nAuto or AAOS. When you complete the core media infrastructure, you can add\nsupport for Android Auto and AAOS to your media app.\n| **Caution:** Google takes driver distraction seriously. Your app must meet specific design requirements before it can be listed on Google Play for Android Auto or AAOS. By adhering to these requirements, you can make it more straightforward to build and test your app. To learn more, see [Android app quality for cars](/docs/quality-guidelines/car-app-quality?category=media).\n\nContents\n--------\n\nThese pages detail how to work with the media apps:\n\n- [Configure the manifest file](/training/cars/media/configure-manifest)\n- [Enable playback controls](/training/cars/media/enable-playback)\n- [Support voice actions](/training/cars/media/voice-actions)\n- [Implement distraction safeguards](/training/cars/media/distraction-safeguards)\n- [Handle errors](/training/cars/media/errors)\n\nCreate audio media apps\n-----------------------\n\nIf your app focuses on playing audio media, use the tools described here. You\ncan create media apps for cars in one of two ways:\n\n1. Use `MediaBrowserService` and a `MediaSession` to create an app that Android\n Auto and AAOS can connect to. This allows the infotainment screen interface\n to render media browsing and playback user interfaces optimized for in-car\n use.\n\n *or*\n2. Use the [Cars App Library](/training/cars/apps) templates to build apps with a customized\n media browsing and playback experience, including custom actions. To learn\n more, see [Build a templated media app](/training/cars/apps/media).\n\n | **Note:** Templated media apps are supported only on Android Auto.\n\n| **Caution:** Aside from [voice guidance audio for navigation apps](/training/cars/apps/navigation#voice-guidance) and the media apps described here, in-app media playback while driving is **not** permitted.\n\nThis guide assumes you have a media app that plays audio on a phone and that\nyour media app conforms to Android [media app architecture](/guide/topics/media-apps/media-apps-overview). This guide\ndescribes the required components of a `MediaBrowserService` and `MediaSession`\nneeded by your app to be compatible with Android Auto or AAOS. After you\ncomplete the core media infrastructure, you can\n[add support for Android Auto](/training/cars/media/auto) and [add support for AAOS](/training/cars/media/automotive-os) to your media\napp.\n\nCreate video media apps\n-----------------------\n\nIf the primary content provided by your app is video, see:\n\n- [Build video apps for Android Automotive OS](/training/cars/parked/video)\n- [Build parked apps for cars](/training/cars/parked)\n\nBefore you start\n----------------\n\nBe sure to consult:\n\n- [Android media API documentation](/guide/topics/media-apps/media-apps-overview)\n- Design guidance: [Create media apps](https://developers.google.com/cars/design/create-apps/app-types/media)\n- Terminology: [Key terms and concepts](#terms-concepts)\n\nLearn key terms and concepts\n----------------------------\n\nThese terms are used in relation to building media apps for cars:\n\nMedia browser\n: An API used by media apps to discover media browser services and to display\n their content. Android Auto and AAOS use a media browser to\n find your app's media browser service.\n\nMedia browser service\n: An Android service implemented by your media app that complies with the\n [`MediaBrowserServiceCompat`](/reference/androidx/media/MediaBrowserServiceCompat) API. Your app uses this service to expose\n content. We also support [\\`MediaLibrarySerice'](/training/cars/media/configure-manifest).\n\nMedia item\n\n: The media browser organizes content in a tree of [`MediaItem`](/training/cars/parked/video) objects. A\n media item can have either or both of these flags. A media item that can\n be browsed for **and** played operates like a playlist. You can select the item\n to play all of its descendants, or you can browse its descendants.\n\n- `FLAG_PLAYABLE` indicates that the item is a leaf on the content tree.\n The item represents a single sound stream, such as a song on an album,\n a chapter in an audio book, or an episode of a podcast.\n\n- `FLAG_BROWSABLE` indicates that the item is a node on the content tree\n and has descendants. For example, the item represents an album, and its\n descendants are the songs on the album.\n\nSee additional resources\n------------------------\n\nFor additional information, see:\n\n- [Universal Media Player sample](//github.com/googlesamples/android-UniversalMusicPlayer)\n- [Audio app overview](/training/managing-audio)\n- [ExoPlayer overview](/guide/topics/media/exoplayer)"]]