Building feature-rich media apps with ExoPlayer (Google I/O '18)

Android Developers · 53K views · 2018 · 39:22

Open on YouTube

Software (other)Software architecture & designtalkdated

Why Stack Overflow recommends it

Stack Overflow users link it when answering or asking about ExoPlayer background playback, notifications, caching and playlists, since it is the official walkthrough of those features.

Recommended by 7 people across 6 different months, 2018 to 2022.

What it is

A Google I/O 2018 session by Android Developers presenters Andrew Lewis and Marc Bachinger on building full-featured media apps with ExoPlayer. It covers caching and offline playback, foreground services with playback notifications, and extension modules for MediaSession, Cast and Interactive Media Ads.

What people said

Recommends Bizkit · 2018-06 · Stack Overflow · on “how to add player control ui in google IO18 audio App demo”

What am I trying to do: Using google exoPlayer to play music, foreground and background. Break into details: The app launches, google exoPlayer playback control UI should be visible and starts to play immediately. As soon as the player starts to play, we should see the notification (Using exoplayer's PlayerNotificationManager ) User exits the app either by pressing the back button or swipe from the recent task, the player service should keep running in foreground with notification. User taps the notification, it should bring up the app. What I have done: I followed google IO18 on this link [this video] While I am following the above youtube link, especially the audio app part, I realize one thing

Recommends UnknownUser · 2018-06 · Stack Overflow · on “Can I use Media Style notification with a podcast app I am developing using Exoplayer”

You can use PlayerNotificationManager with Exoplayer. In fact you can build feature-rich media apps with ExoPlayer [this video] including: Playback controls and info in notifiaction Make your service foreground Connect MediaSession Cast to other devices Cache online media for offline playback ExoPlayer take care of any of those things for you.

Recommends Alex Simion · 2018-07 · Stack Overflow · on “How to use ExoPlayer to play from server”

I can't get my mind around how to use ExoPlayer, I followed this tutorial [this video] but I can't get the player to work with my uri. This is my code (same as in the video but with different uri) : @Override protected void onStart() { super.onStart(); //player creation player = ExoPlayerFactory.newSimpleInstance(this, new DefaultTrackSelector()); //playerview binding with player playerView.setPlayer(player); //telling what we want to play DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "exoplayertest")); Uri uri = Uri.parse(" [LINK] "); Toast.makeText(this, uri.toString(), Toast.LENGTH_LONG).show(); ExtractorMediaSource mediaSource = new Ex

Recommends Waqas Yousaf · 2019-12 · Stack Overflow · on “Get uri from cached video ExoPlayer”

if you are using the simplecache then you can retrieve all url as keys of cache like below: abc.getcache(context).getKeys(); This will return you all the urls whose data is cached in you app cache. if you want the video to be cached then see the exoplayer video of google 2018. [this video] .

Recommends Ravi Kumar · 2020-06 · Stack Overflow · on “Will MediaPlayer continue to play in paused Android activity?”

If you want to play music if user moves to other app or locks the screen, use a foreground service and make sure to display a notification to user while the service is in foreground. It is not advisable to use different MediaPlayer objects to play music in loop. I suggest you to use ExoPlayer to achieve the above functionalities. You can use the below code to loop the music: exoPlayer!!.repeatMode = Player.REPEAT_MODE_ONE Watch this tutorial : Building feature-rich media apps with ExoPlayer (Google I/O '18) [this video] provided by Android Developers team at Google.

Recommends Harneev · 2020-12 · Stack Overflow · on “Android ExoPlayer demo: continue playback with screen locked”

That'll be activity lifecycle handling that you'll need to handle on your own. Methods like `onUserLeaveHint` can notify when user has pressed home or moved to another application or `onBackPressed` can notify when user moves back to previous activity or screen. This video might help you with your background playback implementation as well: [this video]

Recommends Tom3652 · 2021-01 · Stack Overflow · on “DummyDataSource cannot be opened : Android ExoPlayer”

Okay i simply must have removed the DefaultDataSourceFactory by mistake and forgot to set back an UpstreamDataSource to the CacheDataSource instance. Everything works fine now, hope this helps others. In code we need to add this : DefaultDataSourceFactory defaultDataSourceFactory = new DefaultDataSourceFactory(context, Util.getUserAgent(context, context.getString(R.string.app_name))); cacheDataSource.setUpstreamDataSourceFactory(defaultDataSourceFactory); I have also learn a lot about ExoPlayer watching this video [this video] , despite it was in 2018 with the exoplayer version 2.8. I am using the latest at the moment, meaning 2.12.3.

Cites Sebastian Pira · 2018-12 · Stack Overflow · on “Implementing audio app notification in Android”

The purpose of application is to play some radio stations via url streaming using exoplayer. The problem encountered is that when the app is running and the notification starts there are 2 different streams playing one by my button press from the radio UI and one by the notification. My question is how can I make it so when I press a button on the UI it changes the the stream on the notification player as well. P.S. I have tried importing one player however that proved from mainactivity.java by calling it a static however that causes a memory leak and the stream stop in the foreground service. I used the notificationPlayerManager(exoplayer) from here: [this video] Main Activity class: package----

Cites sparrow paul · 2019-11 · Stack Overflow · on “Exoplayer Audio not playing in background service”

@marcbaechinger Thanks it worked. i also used the steps in this video (**Building feature-rich media apps with ExoPlayer (Google I/O '18)**) [this video] to finish it up

Cites mitesh makwana · 2020-02 · Stack Overflow · on “How to implement Exoplayer 2.11.1 in android?”

I also faced this problem and this my solution Declaration [LINK] private val exoPlayer: SimpleExoPlayer by lazy { SimpleExoPlayer.Builder(this).build()} Play Song private fun prepareExoPlayerFromURL(url: String) { val dataSourceFactory = DefaultDataSourceFactory(this, Util.getUserAgent(this, resources.getString(R.string.app_name)), null) val extractorsFactory = DefaultExtractorsFactory() // val audioSource = ExtractorMediaSource(uri, dataSourceFactory, extractorsFactory, null, null) val concateMediaSource = ConcatenatingMediaSource() // to play from song list for (i in mSongList) { // song list song arraylist val mediaSource = ProgressiveMediaSource .Factory( DefaultDataSourceFactory(this,