zt
06/27/2022, 2:16 AMChrimaeon
06/27/2022, 5:59 AMrememberState
in the composeabe or maybe a view model?fengdai
06/27/2022, 9:54 AMste
06/27/2022, 10:07 AMduration
and currentPosition
are best handled using a Handler
in loop: https://github.com/vfsfitvnm/ViMusic/blob/master/app/src/main/kotlin/it/vfsfitvnm/vimusic/utils/PlayerState.kt#L84zt
06/27/2022, 11:23 PMfengdai
06/28/2022, 3:17 AMdispose
function for removing the callback from the Handler
when PlayState
is no longer used. Or Handler
will cause leaking.zt
06/28/2022, 3:21 AMfengdai
06/28/2022, 3:29 AMste
06/28/2022, 8:55 AMdispose
function accordinglyzt
06/29/2022, 4:47 AMste
06/29/2022, 8:45 AMcurrentPosition
, you must poll it. You can either use a Handler
or whatever you like - e.g. you could also poll it within the rememeberPlayerState
using produceState