Migrate to androidx-media3 video player (#3857)

Behaviour is consistent with previous player except that:

- Swapping apps while a video is playing, and then returning to Tusky,
will keep the seek position in the video instead of returning to the
start
- The controls/media description can be shown by tapping anywhere, not
just on the video itself
- The media description is on-screen for the same duration as the player
controls (5 seconds here, 3 seconds in the previous code)
- The user has options to control the playback speed
- Rotating the device does not squash/stretch the video
- Show the media preview when playing audio-only files

Fixes https://github.com/tuskyapp/Tusky/issues/3329,
https://github.com/tuskyapp/Tusky/issues/3141,
https://github.com/tuskyapp/Tusky/issues/3126,
https://github.com/tuskyapp/Tusky/issues/2753,
https://github.com/tuskyapp/Tusky/issues/3508,
https://github.com/tuskyapp/Tusky/issues/3291

---------

Co-authored-by: mcc <andi.m.mcclure@gmail.com>
This commit is contained in:
Nik Clayton 2023-08-10 19:31:55 +02:00 committed by GitHub
commit 8529f309ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 314 additions and 212 deletions

View file

@ -1,41 +0,0 @@
package com.keylesspalace.tusky.view
import android.content.Context
import android.util.AttributeSet
import android.widget.VideoView
class ExposedPlayPauseVideoView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) :
VideoView(context, attrs, defStyleAttr) {
private var listener: PlayPauseListener? = null
private var playing = false
fun setPlayPauseListener(listener: PlayPauseListener) {
this.listener = listener
}
override fun start() {
super.start()
if (!playing) {
playing = true
listener?.onPlay()
}
}
override fun pause() {
super.pause()
if (playing) {
playing = false
listener?.onPause()
}
}
interface PlayPauseListener {
fun onPlay()
fun onPause()
}
}