The instructor walks through the steps needed to set up your MediaSession in code and in the manifest file. Learn about all of the different types of actions that the media session can handle.
- [Instructor] The media session is bit complex … so we'll be going through the process of creating one. … To begin with you'll need to add the media compat library. … Open your application and go to the app's … build.gradle file. … Add the following library. … Support-media-compat version 28.0.0. … Sync your gradle files. … Next decide where you want to use your media session. … Usually if you have an audio app with playback … happening in the service you would want … to have it in the service. … If you have a video player you can … add it to your activity. … Add the following variable to your class. … Media session is MediaSessionCompat and set it to null. … We'll be using the MediaSessionCompat class … from the media compat library. … This class handles all current Android versions. … Before we get into creating the media session … we need a callback. … This will be a inner class. … This callback just listens for key events … and calls our play, pause and stop methods. … Notice that we have to actually listen …
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 example usage