performance optimization

This commit is contained in:
Li ZongYing
2024-01-28 16:00:33 +08:00
parent bcf9bab25f
commit cc2514a81a
10 changed files with 147 additions and 59 deletions
@@ -74,23 +74,22 @@ class PlayerFragment : Fragment() {
@OptIn(UnstableApi::class)
fun play(tvViewModel: TVViewModel) {
this.tvViewModel = tvViewModel
val videoUrlCurrent = tvViewModel.getVideoUrlCurrent()
playerView?.player?.run {
setMediaItem(MediaItem.fromUri(videoUrlCurrent))
setMediaItem(MediaItem.fromUri(tvViewModel.getVideoUrlCurrent()))
prepare()
}
}
override fun onStart() {
super.onStart()
if (playerView != null) {
if (playerView != null && playerView!!.player?.isPlaying == false) {
playerView!!.player?.play()
}
}
override fun onStop() {
super.onStop()
if (playerView != null) {
if (playerView != null && playerView!!.player?.isPlaying == true) {
playerView!!.player?.stop()
}
}