-
Notifications
You must be signed in to change notification settings - Fork 144
Add video trimming to VideoEditScreen. #141
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
Conversation
Use a RangeSlider to allow user to specify a start point and end point for trimming a recently recorded video.
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.
Hello @donovanfm, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
This pull request adds video trimming functionality to the VideoEditScreen. It introduces a RangeSlider that allows users to specify the start and end points for trimming a recently recorded video. The changes involve modifications to the UI to incorporate the RangeSlider and update the VideoEditScreenViewModel to handle the trimming logic.
Highlights
- Video Trimming: Implements video trimming using a RangeSlider in the VideoEditScreen.
- UI Updates: Updates the UI to include the RangeSlider for specifying the start and end points of the video trim.
- ViewModel Changes: Modifies the VideoEditScreenViewModel to incorporate the video trimming parameters when processing the video.
Changelog
Click here to see the changelog
- app/src/main/java/com/google/android/samples/socialite/ui/Main.kt
- Adds
@file:OptIn(ExperimentalMaterial3Api::class)to enable experimental Material 3 APIs. - Adds
@OptIn(ExperimentalMaterial3Api::class)annotation to theMainNavigationcomposable function.
- Adds
- app/src/main/java/com/google/android/samples/socialite/ui/videoedit/VideoEditScreen.kt
- Imports
RangeSliderandRangeSliderStatefrom Material 3. - Adds
videoDuration,videoTrimStart, andvideoTrimEndstates to theVideoEditScreencomposable. - Adds a
RangeSliderto allow users to select the start and end points for video trimming. - Passes
videoTrimStartandvideoTrimEndto theVideoMessagePreviewcomposable. - Retrieves video duration using
MediaMetadataRetrieverand updates thevideoDurationandvideoTrimEndstates. - Modifies
VideoMessagePreviewto accept duration and trimEnd parameters. - Adds
@OptIn(ExperimentalMaterial3Api::class)annotation toVideoEditScreenandVideoEditScreenPreviewcomposables.
- Imports
- app/src/main/java/com/google/android/samples/socialite/ui/videoedit/VideoEditScreenViewModel.kt
- Adds
videoTrimStartandvideoTrimEndparameters to theeditVideofunction. - Uses
MediaItem.ClippingConfigurationto set the start and end positions for video trimming in theeditedMediaItem.
- Adds
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A slider's gentle sway,
A video finds its way,
Trimmed with care and grace,
A perfect, concise space,
For stories to convey.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
(Human note: these AI review comments have been addressed)
Code Review
The pull request introduces video trimming functionality to the VideoEditScreen using a RangeSlider. This allows users to specify start and end points for trimming recorded videos. The changes seem well-structured and integrate smoothly with the existing UI components. However, there are a few areas that could be improved for better clarity and efficiency.
Summary of Findings
- Inconsistent Unit Handling: The code mixes milliseconds and seconds when displaying and handling video trim values. Standardizing on one unit (preferably milliseconds internally for precision) would reduce potential confusion and errors.
- Potential for UI Jitter: Updating
videoTrimEnd.valuedirectly within theonValueChangelambda of theRangeSlidermight cause UI jitter, especially on slower devices. Consider debouncing or throttling the updates to improve performance. - Missing Error Handling: The code doesn't handle potential errors when extracting video metadata. Adding error handling would make the application more robust.
Merge Readiness
The pull request introduces a valuable feature, but there are a few issues that should be addressed before merging. Specifically, the inconsistent unit handling and potential UI jitter should be resolved to ensure a smooth user experience. The missing error handling should also be addressed to improve the robustness of the application. I am unable to approve this pull request, and recommend that others review and approve this code before merging.
app/src/main/java/com/google/android/samples/socialite/ui/videoedit/VideoEditScreen.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/google/android/samples/socialite/ui/videoedit/VideoEditScreen.kt
Outdated
Show resolved
Hide resolved
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.
(Human note: these AI review comments have been addressed)
Code Review
This pull request introduces a video trimming feature using a RangeSlider, which is a great addition. The UI for editing controls has been nicely refactored into a tabbed layout, improving organization. I've found a couple of critical resource leaks related to MediaMetadataRetriever not being released, which could cause crashes. I've also suggested improvements to simplify state management in VideoEditScreen and to correct the video duration handling in the VideoEditScreenViewModel for more robust processing. Please take a look at the detailed comments.
app/src/main/java/com/google/android/samples/socialite/ui/videoedit/FrameRangeSlider.kt
Show resolved
Hide resolved
app/src/main/java/com/google/android/samples/socialite/ui/videoedit/VideoEditScreen.kt
Outdated
Show resolved
Hide resolved
| val duration = rememberSaveable { mutableLongStateOf(0L) } | ||
|
|
||
| LaunchedEffect(uri) { | ||
| val mediaMetadataRetriever = MediaMetadataRetriever() |
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.
@amanc3765, this will be a good sample to update with the new Media3 APIs when you have a chance!
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.
Thanks for flagging this, Nevin!
Add video trimming to VideoEditScreen in SociaLite.
Given the growing number of edit options, this PR also splits out the editing controls into "Edit", "Overlay", and "Trim" tabs.