mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
fix video autoplay in slideshows
This commit is contained in:
parent
8843a4a006
commit
bd0f540460
1 changed files with 8 additions and 3 deletions
|
@ -8,6 +8,7 @@ import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
|
import android.support.annotation.RequiresApi
|
||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
import android.view.*
|
import android.view.*
|
||||||
import android.view.animation.AnimationUtils
|
import android.view.animation.AnimationUtils
|
||||||
|
@ -44,6 +45,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
||||||
private var mStoredShowExtendedDetails = false
|
private var mStoredShowExtendedDetails = false
|
||||||
private var wasEncoded = false
|
private var wasEncoded = false
|
||||||
private var wasInit = false
|
private var wasInit = false
|
||||||
|
private var isPrepared = false
|
||||||
private var mStoredExtendedDetails = 0
|
private var mStoredExtendedDetails = 0
|
||||||
private var mCurrTime = 0
|
private var mCurrTime = 0
|
||||||
private var mDuration = 0
|
private var mDuration = 0
|
||||||
|
@ -395,7 +397,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
||||||
}
|
}
|
||||||
|
|
||||||
fun playVideo() {
|
fun playVideo() {
|
||||||
if (mMediaPlayer != null) {
|
if (mMediaPlayer != null && isPrepared) {
|
||||||
mIsPlaying = true
|
mIsPlaying = true
|
||||||
mMediaPlayer?.start()
|
mMediaPlayer?.start()
|
||||||
} else {
|
} else {
|
||||||
|
@ -471,13 +473,15 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun videoPrepared(mediaPlayer: MediaPlayer) {
|
private fun videoPrepared(mediaPlayer: MediaPlayer) {
|
||||||
|
isPrepared = true
|
||||||
mDuration = mediaPlayer.duration / 1000
|
mDuration = mediaPlayer.duration / 1000
|
||||||
addPreviewImage()
|
addPreviewImage()
|
||||||
setupTimeHolder()
|
setupTimeHolder()
|
||||||
setProgress(mCurrTime)
|
setProgress(mCurrTime)
|
||||||
|
|
||||||
if (mIsFragmentVisible && (context!!.config.autoplayVideos || mPlayOnPrepare))
|
if (mIsFragmentVisible && (context!!.config.autoplayVideos || mPlayOnPrepare)) {
|
||||||
playVideo()
|
playVideo()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun videoCompleted() {
|
private fun videoCompleted() {
|
||||||
|
@ -509,6 +513,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
||||||
releaseMediaPlayer()
|
releaseMediaPlayer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||||
private fun setVideoSize() {
|
private fun setVideoSize() {
|
||||||
if (mSurfaceHolder == null)
|
if (mSurfaceHolder == null)
|
||||||
mSurfaceHolder = mSurfaceView!!.holder
|
mSurfaceHolder = mSurfaceView!!.holder
|
||||||
|
@ -526,7 +531,7 @@ class VideoFragment : ViewPagerFragment(), SurfaceHolder.Callback, SeekBar.OnSee
|
||||||
val screenWidth: Int
|
val screenWidth: Int
|
||||||
val screenHeight: Int
|
val screenHeight: Int
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
if (activity!!.isJellyBean1Plus()) {
|
||||||
val realMetrics = DisplayMetrics()
|
val realMetrics = DisplayMetrics()
|
||||||
display.getRealMetrics(realMetrics)
|
display.getRealMetrics(realMetrics)
|
||||||
screenWidth = realMetrics.widthPixels
|
screenWidth = realMetrics.widthPixels
|
||||||
|
|
Loading…
Reference in a new issue