Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Forward/Rewind #40

Merged
merged 10 commits into from
Jun 12, 2023
Merged

Feat: Forward/Rewind #40

merged 10 commits into from
Jun 12, 2023

Conversation

thalysmcarrara
Copy link
Contributor

@thalysmcarrara thalysmcarrara commented Jun 6, 2023

Description

  • implement forward/rewind functionality

Related Issues

Progress

Pull request checklist

  • Tests: This PR includes tests for covering the features or bug fixes (if applicable).
  • Docs: This PR updates/creates the necessary documentation.
  • CI: Make sure your Pull Request passes all CI checks. If not, clarify the motif behind that and the action plan to solve it (may reference a ticket)

How to test it

Visual reference

Screenrecorder-2023-06-08-15-20-30-642.mp4

@thalysmcarrara thalysmcarrara changed the base branch from main to feat/create-custom-scaffold June 6, 2023 13:17
@ricardodalarme ricardodalarme marked this pull request as draft June 6, 2023 13:20
@thalysmcarrara thalysmcarrara self-assigned this Jun 6, 2023
Base automatically changed from feat/create-custom-scaffold to main June 6, 2023 13:28
@thalysmcarrara thalysmcarrara changed the title WIP Feat: Forward/Rewind Jun 7, 2023
@thalysmcarrara thalysmcarrara added goal Feature to be delivered by the end of the sprint enhancement New feature or request labels Jun 7, 2023
@thalysmcarrara thalysmcarrara added this to the S04 milestone Jun 7, 2023
@thalysmcarrara thalysmcarrara marked this pull request as ready for review June 7, 2023 13:13
@@ -2,31 +2,48 @@ package com.profusion.androidenhancedvideoplayer.components

import android.content.res.Configuration.ORIENTATION_LANDSCAPE
import android.net.Uri
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.animation.* // ktlint-disable no-wildcard-imports
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: lint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we will have to disable this rule to reduce the number of imports, this file tends to be very large and therefore the number of imports too. in anova project we disabled this rule.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you @thalysmcarrara, but if you want to disable this rule, I'd prefer to disable it for the entire project

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can create a a new issue for that, because its not part of the current issue

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm outvoted, but I'd vouch for us keep following google's code-style convention: https://developer.android.com/kotlin/style-guide#import_statements

You can disable it on the IDE: Settings > Editor > Code Style > Kotlin > Imports

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not part of the current issue to add // ktlint-disable as well. We are not disabling rules in any part of the codebase. So, you either add a one-line configuration to the .editorconfig and remove the // ktlint-disable or adopt the ktlint rules of the project.

Copy link
Contributor Author

@thalysmcarrara thalysmcarrara Jun 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the lint rule in a .editorconfig file, I thought it would be more work, but it is a simple modification

@thalysmcarrara thalysmcarrara force-pushed the feat/forward-backward branch 7 times, most recently from d8f6129 to 7dabe86 Compare June 7, 2023 21:14
@@ -2,31 +2,48 @@ package com.profusion.androidenhancedvideoplayer.components

import android.content.res.Configuration.ORIENTATION_LANDSCAPE
import android.net.Uri
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.animation.* // ktlint-disable no-wildcard-imports
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you @thalysmcarrara, but if you want to disable this rule, I'd prefer to disable it for the entire project

@thalysmcarrara thalysmcarrara force-pushed the feat/forward-backward branch 4 times, most recently from 3672416 to 3e3f82b Compare June 8, 2023 12:06
) {
val isTapCountGreaterThanZero = tapCount > 0
Box(
modifier = modifier
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code adds fillMaxHeight, indication, etc to modifier argument. However, this couldn't be the desired behavior...
in order to combine the modifiers, it should be something like this:

Box(
  modifier = Modifier. <do the stuff> .then(modifier)

@@ -2,31 +2,48 @@ package com.profusion.androidenhancedvideoplayer.components

import android.content.res.Configuration.ORIENTATION_LANDSCAPE
import android.net.Uri
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.animation.* // ktlint-disable no-wildcard-imports
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm outvoted, but I'd vouch for us keep following google's code-style convention: https://developer.android.com/kotlin/style-guide#import_statements

You can disable it on the IDE: Settings > Editor > Code Style > Kotlin > Imports

@@ -2,31 +2,48 @@ package com.profusion.androidenhancedvideoplayer.components

import android.content.res.Configuration.ORIENTATION_LANDSCAPE
import android.net.Uri
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.animation.* // ktlint-disable no-wildcard-imports
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not part of the current issue to add // ktlint-disable as well. We are not disabling rules in any part of the codebase. So, you either add a one-line configuration to the .editorconfig and remove the // ktlint-disable or adopt the ktlint rules of the project.

@@ -64,7 +75,8 @@ fun EnhancedVideoPlayer(
soundOff = soundOff,
currentTimeTickInMs = currentTimeTickInMs,
controlsCustomization = controlsCustomization,
settingsControlsCustomization = settingsControlsCustomization
settingsControlsCustomization = settingsControlsCustomization,
transformSeekIncrementRatio = { transformSeekIncrementRatio(it) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
transformSeekIncrementRatio = { transformSeekIncrementRatio(it) }
transformSeekIncrementRatio = transformSeekIncrementRatio

@@ -113,6 +125,10 @@ fun EnhancedVideoPlayer(
)
}

fun setIsControlsVisible(value: Boolean) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: wrong english for isControls (plural). I'd rename to setControlsVisibility(visible: Boolean)

@@ -113,6 +125,10 @@ fun EnhancedVideoPlayer(
)
}

fun setIsControlsVisible(value: Boolean) {
isControlsVisible = value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, the variable name seems wrong as well. Nevermind

@@ -166,6 +177,15 @@ fun EnhancedVideoPlayer(
}
}
)

SeekHandler(
toggleIsControlsVisible = { isControlsVisible = !isControlsVisible },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some functions you are defining in the composable call and others in the EnhancedVideoPlayer component: toggleIsControlsVisible and setIsControlsVisible for example.

Is there a specific reason for that? I'd vouch for us to pick one of them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created the two functions because there are cases where I just want to toggle the variable value and there are cases where I explicitly need to set the variable value to false, I need to make a decision or pass the current value of the variable and add the logic inside the child component or create a function that already does this in the parent element.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it's better to pass just the setIsControlsVisible and create a function with the toggle logic in the SeekHandler component

exoPlayer = exoPlayer,
controlsCustomization = controlsCustomization,
setIsControlsVisible = ::setIsControlsVisible,
transformSeekIncrementRatio = { transformSeekIncrementRatio(it) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
transformSeekIncrementRatio = { transformSeekIncrementRatio(it) }
transformSeekIncrementRatio = transformSeekIncrementRatio

seekIcon = { controlsCustomization.rewindIconContent(it) }
)
Spacer(modifier = Modifier.weight(0.2f))
SeekClickableArea(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a parameter to disable or do not render this composable for the fast-forward if the playback has ended

@@ -166,6 +177,15 @@ fun EnhancedVideoPlayer(
}
}
)

SeekHandler(
toggleIsControlsVisible = { isControlsVisible = !isControlsVisible },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it's better to pass just the setIsControlsVisible and create a function with the toggle logic in the SeekHandler component


val transition = rememberInfiniteTransition(TRANSITION_LABEL)

val scale = transition.animateFloat(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto about the label
image

Comment on lines +48 to +62
onTap = if (isTapCountGreaterThanZero) {
if (disableSeekClick) {
null
} else { { onSeekSingleTap() } }
} else {
{ checkIfCanToggleIsControlsVisible() }
},
onDoubleTap = if (isTapCountGreaterThanZero) { null } else {
if (disableSeekClick) {
null
} else {
{ onSeekDoubleTap() }
}
}
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: now you have more than one state, so it would be better to use when instead of if 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now i need the if because this additional state needs to be nested 🤣

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that the check need to happen only when the isTapCountGreaterThanZero is true

Thalys Matias Carrara added 4 commits June 8, 2023 14:13
* disable no-wildcard-imports rule
* add insert_final_newline = true

Closes #15
@thalysmcarrara thalysmcarrara merged commit 08ac5e0 into main Jun 12, 2023
@thalysmcarrara thalysmcarrara deleted the feat/forward-backward branch June 12, 2023 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request goal Feature to be delivered by the end of the sprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Double Tap to FF or RWD
6 participants