mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2024-12-27 08:43:21 +01:00
loop videos after ending if desired
This commit is contained in:
parent
677e68332c
commit
7d758178d5
@ -242,7 +242,7 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
|
||||
return
|
||||
}
|
||||
|
||||
val wasEnded = videoEnded()
|
||||
val wasEnded = didVideoEnd()
|
||||
if (wasEnded) {
|
||||
setPosition(0)
|
||||
}
|
||||
@ -259,7 +259,7 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
|
||||
}
|
||||
|
||||
mIsPlaying = false
|
||||
if (!videoEnded()) {
|
||||
if (!didVideoEnd()) {
|
||||
mExoPlayer?.playWhenReady = false
|
||||
}
|
||||
|
||||
@ -288,17 +288,29 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
|
||||
}
|
||||
|
||||
private fun videoCompleted() {
|
||||
if (mExoPlayer == null) {
|
||||
return
|
||||
}
|
||||
|
||||
clearLastVideoSavedProgress()
|
||||
mCurrTime = (mExoPlayer!!.duration / 1000).toInt()
|
||||
if (config.loopVideos) {
|
||||
playVideo()
|
||||
} else {
|
||||
video_seekbar.progress = video_seekbar.max
|
||||
video_curr_time.text = mDuration.getFormattedDuration()
|
||||
pauseVideo()
|
||||
}
|
||||
}
|
||||
|
||||
private fun videoEnded(): Boolean {
|
||||
private fun didVideoEnd(): Boolean {
|
||||
val currentPos = mExoPlayer?.currentPosition ?: 0
|
||||
val duration = mExoPlayer?.duration ?: 0
|
||||
return currentPos != 0L && currentPos >= duration
|
||||
}
|
||||
|
||||
private fun saveVideoProgress() {
|
||||
if (!videoEnded()) {
|
||||
if (!didVideoEnd()) {
|
||||
config.apply {
|
||||
lastVideoPosition = mExoPlayer!!.currentPosition.toInt() / 1000
|
||||
lastVideoPath = mUri.toString()
|
||||
@ -306,6 +318,13 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen
|
||||
}
|
||||
}
|
||||
|
||||
private fun clearLastVideoSavedProgress() {
|
||||
config.apply {
|
||||
lastVideoPosition = 0
|
||||
lastVideoPath = ""
|
||||
}
|
||||
}
|
||||
|
||||
private fun setVideoSize() {
|
||||
val videoProportion = mVideoSize.x.toFloat() / mVideoSize.y.toFloat()
|
||||
val display = windowManager.defaultDisplay
|
||||
|
Loading…
Reference in New Issue
Block a user