Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AudioAttributes - class encapsulating information about the audio stream
- main params
- - usage - like USAGE_MEDIA, USAGE_ALARM etc.
- - content type - like CONTENT_TYPE_MOVIE, CONTENT_TYPE_MUSIC
- @ServiceScoped
- @Provides
- fun providesAudioAttributes() = AudioAttributes.Builder()
- .setContentType(C.CONTENT_TYPE_MUSIC)
- .setUsage(C.USAGE_MEDIA)
- .build()
- -------------------------------
- Exoplayer - the thing which will be actually palying the music
- Needs
- - Application Context
- - AudioAttributes
- @ServiceScoped
- @Provides
- fun providesExoPlayer(@ApplicationContext context: Context, audioAttributes: AudioAttributes) = Exoplayer.Builder(context).build.apply {
- setAudioAttributes(audioAttributes, true),
- setHandleAudioBecomingNoisy(true)
- }
- -------------------------------
- DataSourceFactory - Firebase wil be our data source
- @ServiceScoped
- @Provides
- fun providesDataSourceFactory(@ApplicationContext context: Context) = DefaultDataSource.Factory(context)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement