Skip to content

Commit

Permalink
Autoplay all videos.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-signal committed Nov 7, 2022
1 parent 5d76f13 commit 74c5420
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
Expand Up @@ -8,7 +8,6 @@ import org.thoughtcrime.securesms.util.MediaUtil

class MediaPreviewV2Adapter(val fragment: Fragment) : FragmentStateAdapter(fragment) {
private var items: List<Attachment> = listOf()
private var autoPlayPosition = -1

override fun getItemCount(): Int {
return items.count()
Expand All @@ -22,7 +21,7 @@ class MediaPreviewV2Adapter(val fragment: Fragment) : FragmentStateAdapter(fragm
MediaPreviewFragment.DATA_URI to attachment.uri,
MediaPreviewFragment.DATA_CONTENT_TYPE to contentType,
MediaPreviewFragment.DATA_SIZE to attachment.size,
MediaPreviewFragment.AUTO_PLAY to (position == autoPlayPosition),
MediaPreviewFragment.AUTO_PLAY to true,
MediaPreviewFragment.VIDEO_GIF to attachment.isVideoGif,
)
val fragment = if (MediaUtil.isVideo(contentType)) {
Expand All @@ -44,8 +43,4 @@ class MediaPreviewV2Adapter(val fragment: Fragment) : FragmentStateAdapter(fragm
notifyDataSetChanged()
}
}

fun setAutoPlayItemPosition(position: Int) {
autoPlayPosition = position
}
}
Expand Up @@ -178,7 +178,6 @@ class MediaPreviewV2Fragment : Fragment(R.layout.fragment_media_preview_v2), Med
val currentPosition = currentState.position
val fragmentAdapter = binding.mediaPager.adapter as MediaPreviewV2Adapter

fragmentAdapter.setAutoPlayItemPosition(currentPosition)
val backingItems = currentState.mediaRecords.mapNotNull { it.attachment }
if (backingItems.isEmpty()) {
onMediaNotAvailable()
Expand Down

0 comments on commit 74c5420

Please sign in to comment.