Skip to content

Commit

Permalink
[ADD/#93] DIsposableEffect 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
Marchbreeze committed Jan 7, 2025
1 parent 2acf858 commit 43119a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
Expand All @@ -29,8 +30,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.scale
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.pointer.PointerEventPass
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -135,6 +134,12 @@ fun RhythmRoute(
}
}

DisposableEffect(Unit) {
onDispose {
viewModel.releaseMusicPlayers()
}
}

RhythmScreen(
rhythmState = rhythmState,
lottiePlaying = lottiePlaying,
Expand Down Expand Up @@ -239,7 +244,7 @@ internal fun RhythmScreen(
.fillMaxSize()
.background(Transparent50)
.padding(horizontal = 50.dp)
.clickableWithoutRipple { }
.clickableWithoutRipple { }
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ constructor(
}
}

fun releaseMusicPlayers() {
soundPool.release()
mediaPlayer.release()
}

fun playMusic() {
viewModelScope.launch {
if (rhythmState.value.isPlayerLoaded) {
Expand Down

0 comments on commit 43119a7

Please sign in to comment.