kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fade out video player controls on playback.
2 second delay, cancelable if the video is paused or finished.main
rodzic
c218e22566
commit
af89d85696
|
@ -98,6 +98,8 @@ public abstract class MediaPreviewFragment extends Fragment {
|
|||
boolean singleTapOnMedia();
|
||||
void onMediaNotAvailable();
|
||||
void onMediaReady();
|
||||
void onPlaying();
|
||||
void onStopped();
|
||||
default @Nullable VideoControlsDelegate getVideoControlsDelegate() {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.thoughtcrime.securesms.mms.PartAuthority
|
|||
import org.thoughtcrime.securesms.permissions.Permissions
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.DateUtils
|
||||
import org.thoughtcrime.securesms.util.Debouncer
|
||||
import org.thoughtcrime.securesms.util.FullscreenHelper
|
||||
import org.thoughtcrime.securesms.util.LifecycleDisposable
|
||||
import org.thoughtcrime.securesms.util.MediaUtil
|
||||
|
@ -49,6 +50,7 @@ import org.thoughtcrime.securesms.util.StorageUtil
|
|||
import org.thoughtcrime.securesms.util.ViewUtil
|
||||
import java.util.Locale
|
||||
import java.util.Optional
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), MediaPreviewFragment.Events {
|
||||
private val TAG = Log.tag(MediaPreviewV2Fragment::class.java)
|
||||
|
@ -56,6 +58,8 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
|||
private val lifecycleDisposable = LifecycleDisposable()
|
||||
private val binding by ViewBinderDelegate(FragmentMediaPreviewV2Binding::bind)
|
||||
private val viewModel: MediaPreviewV2ViewModel by viewModels()
|
||||
private val debouncer = Debouncer(2, TimeUnit.SECONDS)
|
||||
|
||||
|
||||
private lateinit var fullscreenHelper: FullscreenHelper
|
||||
|
||||
|
@ -337,6 +341,14 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
|
|||
viewModel.setMediaReady()
|
||||
}
|
||||
|
||||
override fun onPlaying() {
|
||||
debouncer.publish { fullscreenHelper.hideSystemUI() }
|
||||
}
|
||||
|
||||
override fun onStopped() {
|
||||
debouncer.clear()
|
||||
}
|
||||
|
||||
private fun forward(mediaItem: MediaDatabase.MediaRecord) {
|
||||
val attachment = mediaItem.attachment
|
||||
val uri = attachment?.uri
|
||||
|
|
|
@ -74,10 +74,12 @@ public final class VideoMediaPreviewFragment extends MediaPreviewFragment {
|
|||
if (!isVideoGif && activity instanceof VoiceNoteMediaControllerOwner) {
|
||||
((VoiceNoteMediaControllerOwner) activity).getVoiceNoteMediaController().pausePlayback();
|
||||
}
|
||||
events.onPlaying();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopped() {
|
||||
events.onStopped();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -107,7 +107,11 @@ public class VideoPlayer extends FrameLayout {
|
|||
switch (playbackState) {
|
||||
case Player.STATE_READY:
|
||||
playerCallback.onReady();
|
||||
if (playWhenReady) playerCallback.onPlaying();
|
||||
if (playWhenReady) {
|
||||
playerCallback.onPlaying();
|
||||
} else {
|
||||
playerCallback.onStopped();
|
||||
}
|
||||
break;
|
||||
case Player.STATE_ENDED:
|
||||
playerCallback.onStopped();
|
||||
|
|
Ładowanie…
Reference in New Issue