Skip to content

Commit

Permalink
Merge pull request #360 from stakwork/tt/fix/video-player-loading-wheel
Browse files Browse the repository at this point in the history
Video player loading wheel
  • Loading branch information
tomastiminskas authored Dec 3, 2021
2 parents 460dc82 + 1507c04 commit 2a81f31
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,8 @@ internal class VideoFeedWatchScreenFragment: BaseFragment<
YOUTUBE_WEB_VIEW_MIME_TYPE,
YOUTUBE_WEB_VIEW_ENCODING
)

} else {

layoutConstraintLoadingVideo?.visible
layoutConstraintVideoViewContainer.visible
webViewYoutubeVideoPlayer.gone

Expand All @@ -221,31 +220,35 @@ internal class VideoFeedWatchScreenFragment: BaseFragment<

onStopSupervisor.scope.launch(viewModel.mainImmediate) {
viewModel.playingVideoStateContainer.collect { viewState ->
@Exhaustive
when (viewState) {
is PlayingVideoViewState.Idle -> {}
binding.includeLayoutVideoPlayer.apply {
@Exhaustive
when (viewState) {
is PlayingVideoViewState.Idle -> { }

is PlayingVideoViewState.MetaDataLoaded -> {
binding.includeLayoutVideoPlayer.seekBarCurrentProgress.max = viewState.duration
binding.includeLayoutVideoPlayer.textViewCurrentTime.text = viewState.duration.toLong().toTimestamp()
// optimizeVideoSize()
}
is PlayingVideoViewState.CurrentTimeUpdate -> {
if (!dragging) {
binding.includeLayoutVideoPlayer.seekBarCurrentProgress.progress = viewState.currentTime
binding.includeLayoutVideoPlayer.textViewCurrentTime.text = (viewState.duration - viewState.currentTime).toLong().toTimestamp()
is PlayingVideoViewState.MetaDataLoaded -> {
layoutConstraintLoadingVideo?.gone

seekBarCurrentProgress.max = viewState.duration
textViewCurrentTime.text = viewState.duration.toLong().toTimestamp()
// optimizeVideoSize()
}
is PlayingVideoViewState.CurrentTimeUpdate -> {
if (!dragging) {
seekBarCurrentProgress.progress = viewState.currentTime
textViewCurrentTime.text = (viewState.duration - viewState.currentTime).toLong().toTimestamp()
}
}
is PlayingVideoViewState.ContinuePlayback -> {
textViewPlayPauseButton.text = binding.root.context.getString(R.string.material_icon_name_pause_button)
}
is PlayingVideoViewState.PausePlayback -> {
textViewPlayPauseButton.text = binding.root.context.getString(R.string.material_icon_name_play_button)
}
is PlayingVideoViewState.CompletePlayback -> {
seekBarCurrentProgress.progress = 0
textViewCurrentTime.text = 0L.toTimestamp()
textViewPlayPauseButton.text = binding.root.context.getString(R.string.material_icon_name_play_button)
}
}
is PlayingVideoViewState.ContinuePlayback -> {
binding.includeLayoutVideoPlayer.textViewPlayPauseButton.text = binding.root.context.getString(R.string.material_icon_name_pause_button)
}
is PlayingVideoViewState.PausePlayback -> {
binding.includeLayoutVideoPlayer.textViewPlayPauseButton.text = binding.root.context.getString(R.string.material_icon_name_play_button)
}
is PlayingVideoViewState.CompletePlayback -> {
binding.includeLayoutVideoPlayer.seekBarCurrentProgress.progress = 0
binding.includeLayoutVideoPlayer.textViewCurrentTime.text = 0L.toTimestamp()
binding.includeLayoutVideoPlayer.textViewPlayPauseButton.text = binding.root.context.getString(R.string.material_icon_name_play_button)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,27 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_constraint_loading_video"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:background="@color/selectedMessageBackground">

<ProgressBar
android:id="@+id/progress_bar_upload_profile_picture"
android:layout_width="50dp"
android:layout_height="50dp"
style="?android:attr/progressBarStyle"
android:indeterminateTint="@android:color/white"
android:indeterminate="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

<TextView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,27 @@
android:layout_height="match_parent"
app:layout_constraintTop_toTopOf="parent" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/layout_constraint_loading_video"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:background="@color/selectedMessageBackground">

<ProgressBar
android:id="@+id/progress_bar_upload_profile_picture"
android:layout_width="50dp"
android:layout_height="50dp"
style="?android:attr/progressBarStyle"
android:indeterminateTint="@android:color/white"
android:indeterminate="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

<TextView
Expand Down

0 comments on commit 2a81f31

Please sign in to comment.