-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
06b49d9
to
68404bf
Compare
3022035
to
b8f1a89
Compare
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: lint
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
d8f6129
to
7dabe86
Compare
androidenhancedvideoplayer/src/main/res/values-pt-rBR/controls_strings.xml
Outdated
Show resolved
Hide resolved
@@ -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 |
There was a problem hiding this comment.
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
...r/src/main/java/com/profusion/androidenhancedvideoplayer/repository/VideoPlayerRepository.kt
Outdated
Show resolved
Hide resolved
.../java/com/profusion/androidenhancedvideoplayer/components/playerOverlay/SeekClickableArea.kt
Outdated
Show resolved
Hide resolved
.../java/com/profusion/androidenhancedvideoplayer/components/playerOverlay/SeekClickableArea.kt
Show resolved
Hide resolved
...yer/src/main/java/com/profusion/androidenhancedvideoplayer/components/EnhancedVideoPlayer.kt
Outdated
Show resolved
Hide resolved
...yer/src/main/java/com/profusion/androidenhancedvideoplayer/components/EnhancedVideoPlayer.kt
Outdated
Show resolved
Hide resolved
...c/main/java/com/profusion/androidenhancedvideoplayer/components/playerOverlay/PlayerIcons.kt
Outdated
Show resolved
Hide resolved
...c/main/java/com/profusion/androidenhancedvideoplayer/components/playerOverlay/PlayerIcons.kt
Outdated
Show resolved
Hide resolved
...yer/src/main/java/com/profusion/androidenhancedvideoplayer/components/EnhancedVideoPlayer.kt
Outdated
Show resolved
Hide resolved
...yer/src/main/java/com/profusion/androidenhancedvideoplayer/components/EnhancedVideoPlayer.kt
Outdated
Show resolved
Hide resolved
...yer/src/main/java/com/profusion/androidenhancedvideoplayer/components/EnhancedVideoPlayer.kt
Outdated
Show resolved
Hide resolved
...yer/src/main/java/com/profusion/androidenhancedvideoplayer/components/EnhancedVideoPlayer.kt
Outdated
Show resolved
Hide resolved
...yer/src/main/java/com/profusion/androidenhancedvideoplayer/components/EnhancedVideoPlayer.kt
Outdated
Show resolved
Hide resolved
...rc/androidTest/java/com/profusion/androidenhancedvideoplayer/test/EnhancedVideoPlayerTest.kt
Show resolved
Hide resolved
.../java/com/profusion/androidenhancedvideoplayer/components/playerOverlay/SeekClickableArea.kt
Outdated
Show resolved
Hide resolved
3672416
to
3e3f82b
Compare
...eoplayer/src/main/java/com/profusion/androidenhancedvideoplayer/utils/ExecuteAfterTimeout.kt
Outdated
Show resolved
Hide resolved
.../java/com/profusion/androidenhancedvideoplayer/components/playerOverlay/SeekClickableArea.kt
Outdated
Show resolved
Hide resolved
.../java/com/profusion/androidenhancedvideoplayer/components/playerOverlay/SeekClickableArea.kt
Outdated
Show resolved
Hide resolved
.../java/com/profusion/androidenhancedvideoplayer/components/playerOverlay/SeekClickableArea.kt
Outdated
Show resolved
Hide resolved
...c/main/java/com/profusion/androidenhancedvideoplayer/components/playerOverlay/SeekHandler.kt
Outdated
Show resolved
Hide resolved
...c/main/java/com/profusion/androidenhancedvideoplayer/components/playerOverlay/PlayerIcons.kt
Show resolved
Hide resolved
...rc/androidTest/java/com/profusion/androidenhancedvideoplayer/test/EnhancedVideoPlayerTest.kt
Show resolved
Hide resolved
...rc/androidTest/java/com/profusion/androidenhancedvideoplayer/test/EnhancedVideoPlayerTest.kt
Show resolved
Hide resolved
3e3f82b
to
8846dd0
Compare
) { | ||
val isTapCountGreaterThanZero = tapCount > 0 | ||
Box( | ||
modifier = modifier |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transformSeekIncrementRatio = { transformSeekIncrementRatio(it) } | |
transformSeekIncrementRatio = transformSeekIncrementRatio |
@@ -113,6 +125,10 @@ fun EnhancedVideoPlayer( | |||
) | |||
} | |||
|
|||
fun setIsControlsVisible(value: Boolean) { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 }, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transformSeekIncrementRatio = { transformSeekIncrementRatio(it) } | |
transformSeekIncrementRatio = transformSeekIncrementRatio |
seekIcon = { controlsCustomization.rewindIconContent(it) } | ||
) | ||
Spacer(modifier = Modifier.weight(0.2f)) | ||
SeekClickableArea( |
There was a problem hiding this comment.
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
...c/main/java/com/profusion/androidenhancedvideoplayer/components/playerOverlay/PlayerIcons.kt
Outdated
Show resolved
Hide resolved
@@ -166,6 +177,15 @@ fun EnhancedVideoPlayer( | |||
} | |||
} | |||
) | |||
|
|||
SeekHandler( | |||
toggleIsControlsVisible = { isControlsVisible = !isControlsVisible }, |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...c/main/java/com/profusion/androidenhancedvideoplayer/components/playerOverlay/SeekHandler.kt
Outdated
Show resolved
Hide resolved
...c/main/java/com/profusion/androidenhancedvideoplayer/components/playerOverlay/SeekHandler.kt
Outdated
Show resolved
Hide resolved
...c/main/java/com/profusion/androidenhancedvideoplayer/components/playerOverlay/SeekHandler.kt
Outdated
Show resolved
Hide resolved
...hancedvideoplayer/src/main/java/com/profusion/androidenhancedvideoplayer/utils/JobsHolder.kt
Outdated
Show resolved
Hide resolved
...c/main/java/com/profusion/androidenhancedvideoplayer/components/playerOverlay/SeekHandler.kt
Outdated
Show resolved
Hide resolved
...c/main/java/com/profusion/androidenhancedvideoplayer/components/playerOverlay/SeekHandler.kt
Outdated
Show resolved
Hide resolved
8846dd0
to
6880cb2
Compare
...hancedvideoplayer/src/main/java/com/profusion/androidenhancedvideoplayer/utils/JobsHolder.kt
Outdated
Show resolved
Hide resolved
Closes #15
6880cb2
to
31b0c96
Compare
12c96fd
to
85b7bc7
Compare
onTap = if (isTapCountGreaterThanZero) { | ||
if (disableSeekClick) { | ||
null | ||
} else { { onSeekSingleTap() } } | ||
} else { | ||
{ checkIfCanToggleIsControlsVisible() } | ||
}, | ||
onDoubleTap = if (isTapCountGreaterThanZero) { null } else { | ||
if (disableSeekClick) { | ||
null | ||
} else { | ||
{ onSeekDoubleTap() } | ||
} | ||
} | ||
) |
There was a problem hiding this comment.
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 😅
There was a problem hiding this comment.
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 🤣
There was a problem hiding this comment.
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
* disable no-wildcard-imports rule * add insert_final_newline = true Closes #15
85b7bc7
to
6811890
Compare
Description
Related Issues
Progress
Pull request checklist
How to test it
Visual reference
Screenrecorder-2023-06-08-15-20-30-642.mp4