diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt index cbfaec7c8..8183613d4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PanoramaVideoActivity.kt @@ -12,10 +12,7 @@ import android.widget.RelativeLayout import android.widget.SeekBar import com.google.vr.sdk.widgets.video.VrVideoEventListener import com.google.vr.sdk.widgets.video.VrVideoView -import com.simplemobiletools.commons.extensions.getFormattedDuration -import com.simplemobiletools.commons.extensions.onGlobalLayout -import com.simplemobiletools.commons.extensions.showErrorToast -import com.simplemobiletools.commons.extensions.toast +import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_STORAGE import com.simplemobiletools.commons.helpers.isPiePlus import com.simplemobiletools.gallery.pro.R @@ -136,10 +133,14 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList setupTimer() } - if (mPlayOnReady) { + if (mPlayOnReady || config.autoplayVideos) { mPlayOnReady = false - playVideo() + mIsPlaying = true + resumeVideo() + } else { + video_toggle_play_pause.setImageResource(R.drawable.ic_play_outline) } + video_toggle_play_pause.beVisible() } override fun onCompletion() { @@ -190,13 +191,13 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList private fun togglePlayPause() { mIsPlaying = !mIsPlaying if (mIsPlaying) { - playVideo() + resumeVideo() } else { pauseVideo() } } - private fun playVideo() { + private fun resumeVideo() { video_toggle_play_pause.setImageResource(R.drawable.ic_pause_outline) if (mCurrTime == mDuration) { setVideoProgress(0) @@ -319,7 +320,7 @@ open class PanoramaVideoActivity : SimpleActivity(), SeekBar.OnSeekBarChangeList override fun onStopTrackingTouch(seekBar: SeekBar?) { mIsPlaying = true - playVideo() + resumeVideo() mIsDragged = false } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt index bc33713f3..a21c23d23 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/VideoPlayerActivity.kt @@ -232,6 +232,7 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen private fun videoPrepared() { if (!mWasVideoStarted) { + video_toggle_play_pause.beVisible() mDuration = (mExoPlayer!!.duration / 1000).toInt() video_seekbar.max = mDuration video_duration.text = mDuration.getFormattedDuration() @@ -241,11 +242,15 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen setLastVideoSavedPosition() } - playVideo() + if (config.autoplayVideos) { + resumeVideo() + } else { + video_toggle_play_pause.setImageResource(R.drawable.ic_play_outline) + } } } - private fun playVideo() { + private fun resumeVideo() { video_toggle_play_pause.setImageResource(R.drawable.ic_pause_outline) if (mExoPlayer == null) { return @@ -279,7 +284,7 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen private fun togglePlayPause() { mIsPlaying = !mIsPlaying if (mIsPlaying) { - playVideo() + resumeVideo() } else { pauseVideo() } @@ -305,7 +310,7 @@ open class VideoPlayerActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListen clearLastVideoSavedProgress() mCurrTime = (mExoPlayer!!.duration / 1000).toInt() if (config.loopVideos) { - playVideo() + resumeVideo() } else { video_seekbar.progress = video_seekbar.max video_curr_time.text = mDuration.getFormattedDuration() diff --git a/app/src/main/res/layout/bottom_video_time_holder.xml b/app/src/main/res/layout/bottom_video_time_holder.xml index 94f5b147e..69acead92 100644 --- a/app/src/main/res/layout/bottom_video_time_holder.xml +++ b/app/src/main/res/layout/bottom_video_time_holder.xml @@ -16,7 +16,8 @@ android:layout_marginTop="@dimen/activity_margin" android:background="?attr/selectableItemBackgroundBorderless" android:padding="@dimen/small_margin" - android:src="@drawable/ic_pause_outline"/> + android:src="@drawable/ic_pause_outline" + android:visibility="invisible"/>