social media

Announcing Glance: Tiles For Wear OS Made Simple




Posted by Anna Bernbaum, Associate Product Manager


Last year we announced the Wear Tiles API. To complement that Java API, we are excited to announce that support for Wear OS Tiles has been added to Glance, a new framework built on top of Jetp...

Android Studio Bumblebee (2021.1.1) Stable




Posted by Adarsh Fernando, Product Manager, Android




The Android Studio team has been abuzz with the stable release of Android Studio Bumblebee (2021.1.1) 🐝 and Android Gradle plugin (AGP) 7.1.0; the latest versions of Android official IDE...

Android Basics And Training Update




Posted by Dan Galpin, Developer Relations Engineer




In October of 2021 we released the final unit of Android Basics in Kotlin, our free, self-paced programming course that makes Android development accessible to everyone. It teaches people ...

MAD Skills Gradle And AGP Build APIs Wrap Up!




Posted by Murat Yener, Android Developer Advocate





That’s a wrap! We’ve just finished a new MAD skills series on Gradle and Android Gradle plugin build APIs. In this series we shifted gears and took a look at how you can extend your build by u...

Announcing Jetpack Glance Alpha For App Widgets




Posted by Marcel Pintó Biescas, Developer Relations Engineer, @marxallski






Android 12 revamps a key feature for many Android users, App Widgets, making them more useful, beautiful, and discoverable (84% use at least 1 widget). Today,...

Rebuilding Our Guide To App Architecture




Posted by Manuel Vicente Vivo, Developer Relations Engineer,
@manuelvicnt







As Android apps grow in size, it's important to design the code with an architecture in place to allow the app to scale, improve quality and robustne...

Android Developer Relations Is Hiring




Posted by Maru Ahues Bouza, Director, Android Developer Relations




Apps are essential to making Android a platform people love - whether it’s on their phones, cars, TVs, or watches. As a popular mobile platform, Android is thriving with 1 i...

Beta 1 Update For 12L Feature Drop!




Posted by Maru Ahues Bouza, Director, Android Developer Relations




At Android Dev Summit in October we highlighted the growth we’re seeing in large screen devices like tablets, foldables, and Chromebooks. We talked about how we’re making ...

Improving App Startup: Lessons From The Facebook App





Posted by the Google and Facebook teams. Authored by Kateryna Semenova from the Google Android team and Tim Trueman, Steven Harris, Subramanian Ramaswamy from the Facebook team.



Introduction



Improving app startup time is not a trivial tas...

12L And New Android APIs And Tools For Large Screens




Posted by Dave Burke, VP of Engineering







There are over a quarter billion large screen devices running Android across tablets, foldables, and ChromeOS devices. In just the last 12 months we’ve seen nearly 100 million new Android tablet act...

Google Play Updates From #AndroidDevSummit




Posted by Alex Musil, Director of Product, Google Play






At this year’s Android Developer Summit, we shared new features we’ve been building to help power your growth on our platform, including enhancements to trust and safety, tools to ...

Introducing Jetpack Media3





Posted by Don Turner, Developer Relations Engineer










Introducing Jetpack Media3


Today, we're launching the first alpha of Jetpack Media3. It's a collection of support libraries for media playback, including ExoPlayer. This article will explain why we created Media3, what it contains, and how it can simplify your app architecture.




Why another media API?


We have several existing media APIs: Jetpack Media also known as MediaCompat, Jetpack Media2, and ExoPlayer. These libraries were developed with different goals, and have several areas of overlapping functionality.


For example, ExoPlayer and Media2 both contain UI components, and MediaCompat and Media2 contain classes for handling media sessions.


It can be challenging to decide which library to use for a given use case, and objects from different libraries are often not compatible, requiring adapters or connecting code. Media3 removes these challenges by providing a single set of libraries which work well together.


To create Media3 we:



Identified the common areas of functionality in our existing media libraries, including UI, playback and media session handling.

Refined and merged the best parts.

Created a common Player interface for all "player-like" objects (more on this later).





What's in the box


Media3 contains many libraries. The ones most relevant for simple media playback are shown below.

















Library name


Purpose


Useful classes for playback




media3-exoplayer


Objects for playing video and audio, provided by ExoPlayer. 


An ExoPlayer can be used for many playback use cases. Create one using an ExoPlayer.Builder




media3-ui


Views for displaying media playback controls, content and metadata. 


StyledPlayerView displays audio and video content from a Player




media3-session


Objects for creating and interacting with a media session.


MediaSession for advertising what you're playing
MediaLibraryService for advertising your content library

















A common Player


Our existing media APIs have a lot of objects which accept playback commands, like "play," "pause," and "skip". Identifying these "player-like" objects and ensuring that they implement a common Player interface was one of the biggest undertakings in the development of Media3.


We've updated, enhanced, and streamlined the Player interface from ExoPlayer to act as the common Player interface for Media3.


Classes such as MediaController and MediaSession that previously contained references to other "player-like" objects have been updated to reference the new player.


This is useful when communicating with UI components. Both ExoPlayer and MediaController now implement Player, so either one of them can be used to communicate with StyledPlayerView or other UI components.



Diagram showing how MediaController and ExoPlayer implement the Player interface and can be used to communicate with UI components, like StyledPlayerView



Simplified architecture


Using this Player interface avoids the need for connecting components, allowing for less code and a simpler app architecture.


In particular, this makes working with media sessions easier. Instead of using the MediaSessionConnector extension, or writing your own "player to media session" connector, you can create a MediaSession using a Player, like this:




player = ExoPlayer.Builder(context).build()
session = MediaSession.Builder(context, player).build()



Now your media session will automatically reflect the state of your player, and any commands sent to your media session will be automatically forwarded to your player. All that in just two lines of code!


Providing a content library


If your app needs to expose its content library to other apps, like Android Auto, use MediaLibraryService, rather than a MediaBrowserService from MediaCompat.


You'll then create a MediaLibrarySession and implement a MediaLibrarySessionCallback whose methods will be called by the browsing app to obtain your content tree.



Diagram showing how MediaLibraryService can be used to expose a content library



Easier updates


One of the key benefits of using Jetpack libraries is API stability. If you use symbols that are part of the stable API, you generally don't need to update your code to use a new release of that library within the same major version.


In Media3, some of the most commonly used objects are marked as stable, including the Player API and media session classes.


Most of ExoPlayer's API surface is marked as unstable.




Diagram showing stable and unstable areas of the Media3 API




To use an unstable method or class you'll need to add the OptIn annotation before using it.




@androidx.annotation.OptIn(UnstableApi::class)
private fun initializeExoPlayer() {
// ...
}



If your project uses a lot of unstable methods it may be more convenient to add this suppression to your project-wide lint.xml.




<issue id="UnsafeOptInUsageError">
<ignore
regexp='\(markerClass = androidx\.media3\.common\.util\.UnstableApi\.class\)' />
</issue>



Just because part of an API is marked as unstable doesn't mean that the API is unreliable or that you shouldn't use it - it's just a way of informing you that it might change in the future.



Getting started


Media3 is released today in alpha and we'd love you to try it out.


One of the best ways to do this is to check out the demo app, which shows how to play video and audio, and integrate with a media session.


You can add the Media3 dependencies to your app by adding the following artifacts to your build.gradle:




implementation 'androidx.media3:media3-ui:1.0.0-alpha01'
implementation 'androidx.media3:media3-exoplayer:1.0.0-alpha01'
implementation 'androidx.media3:media3-session:1.0.0-alpha01'



If you have feedback or run into problems, please file an issue. We'd really love to hear from you.


For more information check out the “What's next for AndroidX Media and ExoPlayer” talk from Android Dev Summit 2021 and the Media3 release notes.




Watch Out For Wear OS At Android Dev Summit 2021




Posted by Jeremy Walker, Developer Relations Engineer





This year’s Android Dev Summit had many exciting announcements for Android developers, including some major updates for the Wear OS platform. At Google I/O, we announced the launch of th...

What’s New In Scalable Automated Testing




Posted by Arif Sukoco, Android Studio Engineering Manager (@GoogArif) & Jolanda Verhoef, Developer Relations Engineer (@Lojanda)





We know it can be challenging to run Android instrumented tests at scale, especially when you have a big test sui...

Here’s How To Watch The 2021 Android Dev Summit!





Posted by The Android Team



We’re less than 24 hours away from kicking off the 2021 Android Dev Summit, broadcasting live online on October 27 & 28. The summit kicks off on October 27 at 10AM PDT with a 50-minute technical keynote, The Android ...

Evolving Our Business Model To Address Developer Needs




Posted by Sameer Samat, Vice President, Product Management


When we started Android and Google Play more than a decade ago, we made a bet that a free and open mobile ecosystem could compete with the proprietary walled gardens that dominated the ind...