Skip to content

Commit

Permalink
fix: disable dragging if video duration < minDuration
Browse files Browse the repository at this point in the history
  • Loading branch information
maitrungduc1410 committed Oct 27, 2024
1 parent c6469c0 commit 7fd3ff3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ private void onTrimmerContainerPanned(MotionEvent event) {

private void setHandleTouchListener(View handle, boolean isLeading) {
handle.setOnTouchListener((view, event) -> {
boolean draggingDisabled = mDuration < mMinDuration; // if the video is shorter than the minimum duration, disable dragging
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
currentSelectedhandle = handle;
Expand All @@ -650,6 +651,10 @@ private void setHandleTouchListener(View handle, boolean isLeading) {
playHapticFeedback(true);
break;
case MotionEvent.ACTION_MOVE:
if (draggingDisabled) {
return false;
}

boolean didClamp = false;
float newX = event.getRawX() - ((float) view.getWidth() / 2);
if (isLeading) {
Expand Down
7 changes: 4 additions & 3 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,16 @@ export default function App() {
isValidFile(url).then((res) => console.log('1isValidVideo:', res));
isValidFile(url1).then((res) => console.log('2isValidVideo:', res));
isValidFile(url2).then((res) => console.log('3isValidVideo:', res));
const url3 =
'https://file-examples.com/storage/fe825adda4669e5de9419e0/2017/11/file_example_MP3_5MG.mp3';
// const url3 =
// 'https://file-examples.com/storage/fe825adda4669e5de9419e0/2017/11/file_example_MP3_5MG.mp3';
showEditor(result.assets![0]?.uri || '', {
// showEditor(url3, {
// type: 'audio',
// outputExt: 'wav',
// maxDuration: 20,
// closeWhenFinish: false,
minDuration: 10,
minDuration: 5,
maxDuration: 15,
fullScreenModalIOS: true,
saveToPhoto: true,
removeAfterSavedToPhoto: true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-video-trim",
"version": "2.2.9",
"version": "2.2.10",
"description": "Video trimmer for your React Native app",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down

0 comments on commit 7fd3ff3

Please sign in to comment.