Advertisement
alphawoop20s

Untitled

Dec 11th, 2022
1,175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.98 KB | None | 0 0
  1. AudioAttributes - class encapsulating information about the audio stream
  2.  
  3. main params
  4.     - usage - like USAGE_MEDIA, USAGE_ALARM etc.
  5.     - content type - like CONTENT_TYPE_MOVIE, CONTENT_TYPE_MUSIC
  6.  
  7.  
  8.  
  9. @ServiceScoped
  10. @Provides
  11. fun providesAudioAttributes() = AudioAttributes.Builder()
  12.     .setContentType(C.CONTENT_TYPE_MUSIC)
  13.     .setUsage(C.USAGE_MEDIA)
  14.     .build()
  15.  
  16.  
  17.  
  18.    
  19. -------------------------------
  20.  
  21. Exoplayer - the thing which will be actually palying the music
  22.  
  23. Needs
  24. - Application Context
  25. - AudioAttributes
  26.  
  27. @ServiceScoped
  28. @Provides
  29. fun providesExoPlayer(@ApplicationContext context: Context, audioAttributes: AudioAttributes) = Exoplayer.Builder(context).build.apply {
  30.     setAudioAttributes(audioAttributes, true),
  31.     setHandleAudioBecomingNoisy(true)
  32.     }
  33.    
  34.    
  35. -------------------------------
  36.  
  37. DataSourceFactory - Firebase wil be our data source
  38.  
  39. @ServiceScoped
  40. @Provides
  41. fun providesDataSourceFactory(@ApplicationContext context: Context) = DefaultDataSource.Factory(context)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement