Fix auto play when swiping between attachments (#3077)

* Fix auto play when swiping between attachments

Fixes an issue where attachment doesn't autoplay when swiping left/right from initial attachment.

Fixes #3066

* Fix lint error for wild card imports
This commit is contained in:
Eric Frohnhoefer 2022-12-30 02:22:39 -08:00 committed by GitHub
parent 65e95a7858
commit 3170e1ce71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -66,19 +66,21 @@ class ViewVideoFragment : ViewMediaFragment() {
videoActionsListener = context as VideoActionsListener videoActionsListener = context as VideoActionsListener
} }
override fun setUserVisibleHint(isVisibleToUser: Boolean) { override fun onResume() {
// Start/pause/resume video playback as fragment is shown/hidden super.onResume()
super.setUserVisibleHint(isVisibleToUser)
if (_binding == null) {
return
}
if (isVisibleToUser) { if (_binding != null) {
if (mediaActivity.isToolbarVisible) { if (mediaActivity.isToolbarVisible) {
handler.postDelayed(hideToolbar, TOOLBAR_HIDE_DELAY_MS) handler.postDelayed(hideToolbar, TOOLBAR_HIDE_DELAY_MS)
} }
binding.videoView.start() binding.videoView.start()
} else { }
}
override fun onPause() {
super.onPause()
if (_binding != null) {
handler.removeCallbacks(hideToolbar) handler.removeCallbacks(hideToolbar)
binding.videoView.pause() binding.videoView.pause()
mediaController.hide() mediaController.hide()
@ -161,9 +163,6 @@ class ViewVideoFragment : ViewMediaFragment() {
binding.progressBar.hide() binding.progressBar.hide()
mp.isLooping = true mp.isLooping = true
if (requireArguments().getBoolean(ARG_START_POSTPONED_TRANSITION)) {
binding.videoView.start()
}
} }
if (requireArguments().getBoolean(ARG_START_POSTPONED_TRANSITION)) { if (requireArguments().getBoolean(ARG_START_POSTPONED_TRANSITION)) {