Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Hướng dẫn này giả định rằng bạn có một ứng dụng đa phương tiện phát âm thanh trên điện thoại và ứng dụng đa phương tiện đó phù hợp với cấu trúc ứng dụng đa phương tiện của Android. Bạn cũng sẽ tìm hiểu những gì ứng dụng của bạn cần từ MediaBrowserService và MediaSession để chạy trên Android Auto hoặc AAOS. Khi hoàn thành cơ sở hạ tầng đa phương tiện cốt lõi, bạn có thể thêm tính năng hỗ trợ Android Auto và AAOS vào ứng dụng đa phương tiện của mình.
Nội dung
Các trang này trình bày chi tiết cách sử dụng các ứng dụng đa phương tiện:
Nếu ứng dụng của bạn tập trung vào việc phát nội dung nghe nhìn, hãy sử dụng các công cụ được mô tả tại đây. Bạn có thể tạo ứng dụng đa phương tiện cho ô tô theo một trong hai cách sau:
Sử dụng MediaBrowserService và MediaSession để tạo một ứng dụng mà Android Auto và AAOS có thể kết nối. Nhờ đó, giao diện màn hình thông tin giải trí có thể hiển thị giao diện người dùng duyệt xem và phát nội dung nghe nhìn được tối ưu hoá để sử dụng trong xe.
Hướng dẫn này giả định rằng bạn có một ứng dụng đa phương tiện phát âm thanh trên điện thoại và ứng dụng đa phương tiện đó phù hợp với cấu trúc ứng dụng đa phương tiện của Android. Hướng dẫn này mô tả các thành phần bắt buộc của MediaBrowserService và MediaSession mà ứng dụng của bạn cần để tương thích với Android Auto hoặc AAOS. Sau khi hoàn thành cơ sở hạ tầng đa phương tiện cốt lõi, bạn có thể thêm tính năng hỗ trợ Android Auto và thêm tính năng hỗ trợ AAOS vào ứng dụng đa phương tiện của mình.
Tạo ứng dụng đa phương tiện dạng video
Nếu nội dung chính mà ứng dụng của bạn cung cấp là video, hãy xem:
Các thuật ngữ này được dùng liên quan đến việc tạo ứng dụng đa phương tiện cho ô tô:
Trình duyệt nội dung đa phương tiện
Đây là một API được các ứng dụng đa phương tiện dùng để khám phá dịch vụ trình duyệt nội dung đa phương tiện và hiển thị nội dung của các ứng dụng đó. Android Auto và AAOS dùng một trình duyệt nội dung đa phương tiện để tìm dịch vụ trình duyệt nội dung đa phương tiện của ứng dụng.
Dịch vụ trình duyệt nội dung đa phương tiện
Đây là một dịch vụ Android do ứng dụng đa phương tiện của bạn triển khai và tuân thủ API MediaBrowserServiceCompat. Ứng dụng của bạn dùng dịch vụ này để hiển thị nội dung. Chúng tôi cũng hỗ trợ `MediaLibrarySerice'.
Mục nội dung đa phương tiện
Trình duyệt nội dung đa phương tiện sắp xếp nội dung theo cây đối tượng MediaItem. Một mục nội dung đa phương tiện có thể chứa một hoặc cả hai cờ này. Một mục nội dung đa phương tiện vừa có thể duyệt xem vừa có thể phát hoạt động như một danh sách phát. Bạn có thể chọn mục đó để phát tất cả các phần tử con hoặc bạn có thể duyệt qua các phần tử con.
FLAG_PLAYABLE cho biết mục là một lá trên cây nội dung.
Mục này biểu thị một luồng âm thanh duy nhất, chẳng hạn như một bài hát trong đĩa nhạc, một chương trong sách nói hoặc một tập podcast.
FLAG_BROWSABLE cho biết mục là một nút trên cây nội dung và có các phần tử con. Ví dụ: mục này biểu thị một đĩa nhạc và các phần tử con của đĩa nhạc đó là các bài hát trong đĩa nhạc.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-08-22 UTC.
[null,null,["Cập nhật lần gần đây nhất: 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)"]]