mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
add skip forward/backward at panorama videos
This commit is contained in:
parent
0cb212947c
commit
3ee3887754
3 changed files with 22 additions and 2 deletions
|
@ -25,6 +25,7 @@ import com.simplemobiletools.gallery.extensions.hideSystemUI
|
||||||
import com.simplemobiletools.gallery.extensions.navigationBarHeight
|
import com.simplemobiletools.gallery.extensions.navigationBarHeight
|
||||||
import com.simplemobiletools.gallery.extensions.showSystemUI
|
import com.simplemobiletools.gallery.extensions.showSystemUI
|
||||||
import com.simplemobiletools.gallery.helpers.HIDE_PLAY_PAUSE_DELAY
|
import com.simplemobiletools.gallery.helpers.HIDE_PLAY_PAUSE_DELAY
|
||||||
|
import com.simplemobiletools.gallery.helpers.MIN_SKIP_LENGTH
|
||||||
import com.simplemobiletools.gallery.helpers.PATH
|
import com.simplemobiletools.gallery.helpers.PATH
|
||||||
import com.simplemobiletools.gallery.helpers.PLAY_PAUSE_VISIBLE_ALPHA
|
import com.simplemobiletools.gallery.helpers.PLAY_PAUSE_VISIBLE_ALPHA
|
||||||
import kotlinx.android.synthetic.main.activity_panorama_video.*
|
import kotlinx.android.synthetic.main.activity_panorama_video.*
|
||||||
|
@ -113,6 +114,9 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
||||||
|
|
||||||
intent.removeExtra(PATH)
|
intent.removeExtra(PATH)
|
||||||
|
|
||||||
|
video_curr_time.setOnClickListener { skip(false) }
|
||||||
|
video_duration.setOnClickListener { skip(true) }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val options = VrVideoView.Options()
|
val options = VrVideoView.Options()
|
||||||
options.inputType = VrVideoView.Options.TYPE_MONO
|
options.inputType = VrVideoView.Options.TYPE_MONO
|
||||||
|
@ -209,6 +213,7 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun playVideo() {
|
private fun playVideo() {
|
||||||
|
video_play_outline.setImageResource(R.drawable.ic_pause)
|
||||||
if (mCurrTime == mDuration) {
|
if (mCurrTime == mDuration) {
|
||||||
setVideoProgress(0)
|
setVideoProgress(0)
|
||||||
mPlayOnReady = true
|
mPlayOnReady = true
|
||||||
|
@ -216,7 +221,6 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
||||||
}
|
}
|
||||||
|
|
||||||
vr_video_view.playVideo()
|
vr_video_view.playVideo()
|
||||||
video_play_outline.setImageResource(R.drawable.ic_pause)
|
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,6 +290,22 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun skip(forward: Boolean) {
|
||||||
|
if (forward && mCurrTime == mDuration) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val curr = vr_video_view.currentPosition
|
||||||
|
val twoPercents = Math.max((vr_video_view.duration / 50).toInt(), MIN_SKIP_LENGTH)
|
||||||
|
val newProgress = if (forward) curr + twoPercents else curr - twoPercents
|
||||||
|
val roundProgress = Math.round(newProgress / 1000f)
|
||||||
|
val limitedProgress = Math.max(Math.min(vr_video_view.duration.toInt(), roundProgress), 0)
|
||||||
|
setVideoProgress(limitedProgress)
|
||||||
|
if (!mIsPlaying) {
|
||||||
|
togglePlayPause()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
|
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
|
||||||
if (fromUser) {
|
if (fromUser) {
|
||||||
setVideoProgress(progress)
|
setVideoProgress(progress)
|
||||||
|
|
|
@ -38,7 +38,6 @@ import java.io.File
|
||||||
|
|
||||||
class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, SeekBar.OnSeekBarChangeListener {
|
class VideoFragment : ViewPagerFragment(), TextureView.SurfaceTextureListener, SeekBar.OnSeekBarChangeListener {
|
||||||
private val PROGRESS = "progress"
|
private val PROGRESS = "progress"
|
||||||
private val MIN_SKIP_LENGTH = 2000
|
|
||||||
|
|
||||||
private var mTextureView: TextureView? = null
|
private var mTextureView: TextureView? = null
|
||||||
private var mCurrTimeView: TextView? = null
|
private var mCurrTimeView: TextView? = null
|
||||||
|
|
|
@ -88,6 +88,7 @@ const val DRAG_THRESHOLD = 8
|
||||||
const val MONTH_MILLISECONDS = MONTH_SECONDS * 1000L
|
const val MONTH_MILLISECONDS = MONTH_SECONDS * 1000L
|
||||||
const val HIDE_PLAY_PAUSE_DELAY = 500L
|
const val HIDE_PLAY_PAUSE_DELAY = 500L
|
||||||
const val PLAY_PAUSE_VISIBLE_ALPHA = 0.8f
|
const val PLAY_PAUSE_VISIBLE_ALPHA = 0.8f
|
||||||
|
const val MIN_SKIP_LENGTH = 2000
|
||||||
|
|
||||||
const val DIRECTORY = "directory"
|
const val DIRECTORY = "directory"
|
||||||
const val MEDIUM = "medium"
|
const val MEDIUM = "medium"
|
||||||
|
|
Loading…
Reference in a new issue