Skip to content

Commit

Permalink
🐛 fix(repository): Prevent multiple YouTube initializations (Fixed An…
Browse files Browse the repository at this point in the history
…droid Auto online content when logged in)
  • Loading branch information
maxrave-dev committed Jan 31, 2025
1 parent 45fcf74 commit 3ce7f1f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ class MainRepository(
private val database: MusicDatabase,
private val context: Context,
) {
var init = false

fun initYouTube(scope: CoroutineScope) {
if (init) return
init = true
youTube.cacheControlInterceptor =
object : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ class SimpleMediaSessionCallback(
) : MediaLibrarySession.Callback {
var toggleLike: () -> Unit = {}
private val scope = CoroutineScope(Dispatchers.Main + Job())
val searchTempList = mutableListOf<Track>()
val listHomeItem = mutableListOf<HomeItem>()
private val searchTempList = mutableListOf<Track>()
private val listHomeItem = mutableListOf<HomeItem>()

init {
if (!mainRepository.init) {
mainRepository.initYouTube(scope)
}
}

override fun onConnect(
session: MediaSession,
Expand Down

0 comments on commit 3ce7f1f

Please sign in to comment.