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 https://www.youtube.com/watch?v=svdq1BWl4r8&t=1990s
While I am following the above youtube link, especially the audio app part, I realize one thing, how do you pros add player control UI into this app?
e.g, the app is onDestory, user quits. Then user taps on the notification, back to the MainActivity, there is nothing there, it's an empty screen, question is, how do you add play control ui in here?
I have looked into https://github.com/googlesamples/android-UniversalMusicPlayer tyring to figure out this. However, the Universal Android Music Player Sample is using a giant notification (Not PlayerNotificationManager see on IO18) and custom player UI (Not ExoPlayer out of box control UI) which is confusing me a lot.
Please, please, please help. How to add player control ui in the following code. https://github.com/bizkitj/MediaSessionExoPlayer/tree/ExoPlayerGoogleIO2018
If you can , please not only show me how you do it, I also need to know why did you do it? Break into steps.
Version of ExoPlayer being used:
implementation 'com.google.android.exoplayer:exoplayer-core:2.8.0'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.8.0'
implementation 'com.google.android.exoplayer:extension-mediasession:2.8.0'
Please be noted, I am tyring to build things upon the googleIO18 demo app. This demo app is using exoPlayer's PlayerNotificationManager
which is great to keep sync with MediaSession
, I do not want to change this PlayerNotificationManager
to android Notification.MediaStyle
.
Thank you.