diff --git a/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java b/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java index 75eb91849..43f27becc 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java +++ b/app/src/main/java/com/simplemobiletools/gallery/fragments/VideoFragment.java @@ -23,6 +23,7 @@ import android.widget.ImageView; import android.widget.SeekBar; import android.widget.TextView; +import com.simplemobiletools.gallery.Config; import com.simplemobiletools.gallery.Constants; import com.simplemobiletools.gallery.R; import com.simplemobiletools.gallery.Utils; @@ -52,6 +53,7 @@ public class VideoFragment extends ViewPagerFragment private boolean mIsPlaying; private boolean mIsDragged; private boolean mIsFullscreen; + private boolean mIsFragmentVisible; private int mCurrTime; private int mDuration; @@ -87,6 +89,17 @@ public class VideoFragment extends ViewPagerFragment initTimeHolder(); } + @Override + public void setMenuVisibility(boolean menuVisible) { + super.setMenuVisibility(menuVisible); + mIsFragmentVisible = menuVisible; + if (menuVisible) { + if (getContext() != null && Config.newInstance(getContext()).getAutoplayVideos()) { + playVideo(); + } + } + } + public void itemDragged() { pauseVideo(); } @@ -255,6 +268,7 @@ public class VideoFragment extends ViewPagerFragment public void onPause() { super.onPause(); pauseVideo(); + mIsFragmentVisible = false; } @Override @@ -394,5 +408,8 @@ public class VideoFragment extends ViewPagerFragment addPreviewImage(); setupTimeHolder(); setProgress(mCurrTime); + + if (mIsFragmentVisible) + playVideo(); } }