1*30877f79SAndroid Build Coastguard Worker# Media2 module 2*30877f79SAndroid Build Coastguard Worker 3*30877f79SAndroid Build Coastguard WorkerThe Media2 module provides builders for [SessionPlayer][] and 4*30877f79SAndroid Build Coastguard Worker[MediaSession.SessionCallback][] in the [Media2 library][]. 5*30877f79SAndroid Build Coastguard Worker 6*30877f79SAndroid Build Coastguard WorkerCompared to [MediaSessionConnector][] that uses [MediaSessionCompat][], this provides finer grained 7*30877f79SAndroid Build Coastguard Workercontrol for incoming calls, so you can selectively allow/reject commands per controller. 8*30877f79SAndroid Build Coastguard Worker 9*30877f79SAndroid Build Coastguard Worker## Getting the module 10*30877f79SAndroid Build Coastguard Worker 11*30877f79SAndroid Build Coastguard WorkerThe easiest way to get the module is to add it as a gradle dependency: 12*30877f79SAndroid Build Coastguard Worker 13*30877f79SAndroid Build Coastguard Worker```gradle 14*30877f79SAndroid Build Coastguard Workerimplementation 'com.google.android.exoplayer:extension-media2:2.X.X' 15*30877f79SAndroid Build Coastguard Worker``` 16*30877f79SAndroid Build Coastguard Worker 17*30877f79SAndroid Build Coastguard Workerwhere `2.X.X` is the version, which must match the version of the other media 18*30877f79SAndroid Build Coastguard Workermodules being used. 19*30877f79SAndroid Build Coastguard Worker 20*30877f79SAndroid Build Coastguard WorkerAlternatively, you can clone this GitHub project and depend on the module 21*30877f79SAndroid Build Coastguard Workerlocally. Instructions for doing this can be found in the [top level README][]. 22*30877f79SAndroid Build Coastguard Worker 23*30877f79SAndroid Build Coastguard Worker[top level README]: https://github.com/google/ExoPlayer/blob/release-v2/README.md 24*30877f79SAndroid Build Coastguard Worker 25*30877f79SAndroid Build Coastguard Worker## Using the module 26*30877f79SAndroid Build Coastguard Worker 27*30877f79SAndroid Build Coastguard Worker### Using `SessionPlayerConnector` 28*30877f79SAndroid Build Coastguard Worker 29*30877f79SAndroid Build Coastguard Worker`SessionPlayerConnector` is a [SessionPlayer][] implementation wrapping a given `Player`. 30*30877f79SAndroid Build Coastguard WorkerYou can use a [SessionPlayer][] instance to build a [MediaSession][], or to set the player 31*30877f79SAndroid Build Coastguard Workerassociated with a [VideoView][] or [MediaControlView][] 32*30877f79SAndroid Build Coastguard Worker 33*30877f79SAndroid Build Coastguard Worker### Using `SessionCallbackBuilder` 34*30877f79SAndroid Build Coastguard Worker 35*30877f79SAndroid Build Coastguard Worker`SessionCallbackBuilder` lets you build a [MediaSession.SessionCallback][] instance given its 36*30877f79SAndroid Build Coastguard Workercollaborators. You can use a [MediaSession.SessionCallback][] to build a [MediaSession][]. 37*30877f79SAndroid Build Coastguard Worker 38*30877f79SAndroid Build Coastguard Worker## Links 39*30877f79SAndroid Build Coastguard Worker 40*30877f79SAndroid Build Coastguard Worker* [Javadoc][]: Classes matching 41*30877f79SAndroid Build Coastguard Worker `com.google.android.exoplayer2.ext.media2.*` belong to this module. 42*30877f79SAndroid Build Coastguard Worker 43*30877f79SAndroid Build Coastguard Worker[Javadoc]: https://exoplayer.dev/doc/reference/index.html 44*30877f79SAndroid Build Coastguard Worker 45*30877f79SAndroid Build Coastguard Worker[SessionPlayer]: https://developer.android.com/reference/androidx/media2/common/SessionPlayer 46*30877f79SAndroid Build Coastguard Worker[MediaSession]: https://developer.android.com/reference/androidx/media2/session/MediaSession 47*30877f79SAndroid Build Coastguard Worker[MediaSession.SessionCallback]: https://developer.android.com/reference/androidx/media2/session/MediaSession.SessionCallback 48*30877f79SAndroid Build Coastguard Worker[Media2 library]: https://developer.android.com/jetpack/androidx/releases/media2 49*30877f79SAndroid Build Coastguard Worker[MediaSessionCompat]: https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat 50*30877f79SAndroid Build Coastguard Worker[MediaSessionConnector]: https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/ext/mediasession/MediaSessionConnector.html 51*30877f79SAndroid Build Coastguard Worker[VideoView]: https://developer.android.com/reference/androidx/media2/widget/VideoView 52*30877f79SAndroid Build Coastguard Worker[MediaControlView]: https://developer.android.com/reference/androidx/media2/widget/MediaControlView 53