Fixed deprecated ExoPlayer

This commit is contained in:
Adolfo Santiago 2022-06-19 08:42:39 +02:00
parent 8d750f0dd7
commit f81a60fc46
No known key found for this signature in database
GPG key ID: 244D6F9A317B4A65

View file

@ -32,10 +32,10 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.MediaController import android.widget.MediaController
import com.google.android.exoplayer2.ExoPlayer
import com.google.android.exoplayer2.MediaItem import com.google.android.exoplayer2.MediaItem
import com.google.android.exoplayer2.PlaybackException import com.google.android.exoplayer2.PlaybackException
import com.google.android.exoplayer2.Player import com.google.android.exoplayer2.Player
import com.google.android.exoplayer2.SimpleExoPlayer
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
import com.keylesspalace.tusky.R import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.ViewMediaActivity import com.keylesspalace.tusky.ViewMediaActivity
@ -63,7 +63,7 @@ class ViewVideoFragment : ViewMediaFragment() {
private lateinit var mediaController: MediaController private lateinit var mediaController: MediaController
private var isAudio = false private var isAudio = false
private var exoPlayer: SimpleExoPlayer? = null private var exoPlayer: ExoPlayer? = null
private val playbackStateListener: Player.Listener = playbackStateListener() private val playbackStateListener: Player.Listener = playbackStateListener()
private var playWhenReady = true private var playWhenReady = true
private var currentWindow = 0 private var currentWindow = 0
@ -124,7 +124,7 @@ class ViewVideoFragment : ViewMediaFragment() {
setParameters(buildUponParameters().setMaxVideoSizeSd()) setParameters(buildUponParameters().setMaxVideoSizeSd())
} }
exoPlayer = SimpleExoPlayer.Builder(requireActivity()) exoPlayer = ExoPlayer.Builder(requireActivity())
.setTrackSelector(trackSelector) .setTrackSelector(trackSelector)
.build() .build()
.also { player -> .also { player ->
@ -143,7 +143,6 @@ class ViewVideoFragment : ViewMediaFragment() {
} }
videoControls.player = videoView.player videoControls.player = videoView.player
//videoView.requestFocus()
if(arguments!!.getBoolean(ARG_START_POSTPONED_TRANSITION)) { if(arguments!!.getBoolean(ARG_START_POSTPONED_TRANSITION)) {
mediaActivity.onBringUp() mediaActivity.onBringUp()