Learn what the MediaSession and MediaSessionCompat classes are. See how to use them to talk to media controllers, listen for Bluetooth events, and maintain the state of your media.
- [Narrator] To play media in the background, … we need to discuss a system class that is used … for talking to different parts of the device. … MediaSession … But, before we move forward, please keep in mind, … that MediaSession is a very complex class. … I've used MediaSession in exercise file projects, … to connect UI controls to Bluetooth devices, … and notifications. … So, the code is there for you to reference. … But, outside of the examples we're about to discuss, … we're not going to take a deep dive into MediaSession. … This class would warrant a course of it's own. … If you want to find out more about MediaSession, … check out the documentation at developer.android.com. … The two class options are MediaSession … or MediaSessionCompat. … We'll be using MediaSessionCompat, … as that works with all versions of Android. … This class is used to talk to media controllers, … handles different media events and buttons, … and works with other Bluetooth devices, … like Watch OS and Android Auto. …
Author
Released
4/16/2019- Why your app needs audio and video
- Controlling volume with AudioManager
- Playing audio with MediaPlayer
- Playing multiple sound files at once with SoundPool
- Creating a VideoView UI
- Playing media in the background
- Audio and video formats
- Working with ExoPlayer
Skill Level Intermediate
Duration
Views
Related Courses
-
Effective Android Testing for Mobile Developers
with Chiu-Ki Chan2h 56m Intermediate
-
Android Multimedia
-
1. Android Multimedia
-
Playing audio and video2m 23s
-
2. AudioManager
-
AudioManager overview2m 28s
-
Set the volume1m 47s
-
Audio focus3m 25s
-
Abandoning audio focus1m 38s
-
-
3. MediaPlayer
-
Setup3m 48s
-
States2m 8s
-
Loading files2m 45s
-
Playing media2m 6s
-
-
4. SoundPool
-
SoundPool overview2m 45s
-
Load files with SoundPool5m 24s
-
Play files with SoundPool3m 53s
-
-
5. VideoView
-
VideoView overview2m 17s
-
Create a VideoView UI2m 30s
-
-
6. MediaSession
-
MediaSession overview4m 22s
-
MediaSession example usage2m 39s
-
-
7. Playing Media in the Background
-
Channels2m 13s
-
Notifications4m 25s
-
Background services3m 21s
-
Create MediaPlayer3m 37s
-
Create play method3m 10s
-
-
8. Formats
-
Audio formats1m 15s
-
Video formats1m 47s
-
-
9. ExoPlayer
-
Overview and library setup1m 55s
-
Initialization1m 28s
-
Load and play media2m 44s
-
Create media sources3m 55s
-
Set up players4m 21s
-
-
Conclusion
-
Next steps40s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: MediaSession overview