Open efstathiosntonas opened 2 hours ago
hi can you provide screen recording?
@maitrungduc1410 sure, give me a moment and I'll upload.
It seems to me that the mediaPlayer state is not ready thus it cannot seek. The moment I hit play the mediaPlayer is 'ready' thus the trimming handles movement do not throw the error.
https://github.com/user-attachments/assets/fbde2ac7-84ac-48e7-8897-c0ad5c4488ee
If you want to try out the same video like me: https://www.mediafire.com/file/1v93pmr45t6bro6/Pixel_40_second_video.MP4/file
It seems that it fails to load the first video frame, the only thing I can see is black. If I hit play then the video loads fine.
yes this is default behaviour of Android, it won't render first frame until you play
can I have your code?
yes this is default behaviour of Android, it won't render first frame until you play
yeah, thing is seeker can't work without at least mediaPlayer plays one frame.
useEffect(() => {
const eventEmitter = new NativeEventEmitter(NativeModules.VideoTrim);
const subscription = eventEmitter.addListener('VideoTrim', (event) => {
console.log(event);
switch (event.name) {
case 'onFinishTrimming': {
// @ts-ignore
setLocalVideo({ uri: event.outputPath });
setKey(Math.random());
break;
}
}
});
return () => {
subscription.remove();
};
}, []);
showEditor(assets[0].uri as string, {
maxDuration: 30,
fullScreenModalIOS: true,
cancelButtonText: _(
msg({
message: 'Cancel',
context: 'video.trim.cancel.button'
})
),
saveButtonText: _(
msg({
message: 'Save',
context: 'video.trim.save.button'
})
),
cancelDialogTitle: _(
msg({
message: 'Attention!',
context: 'video.trim.dialog.title'
})
),
cancelDialogMessage: _(
msg({
message: 'Are you sure you want to cancel?',
context: 'video.trim.cancel.dialog.message.button'
})
),
cancelDialogConfirmText: _(
msg({
message: 'Yes, go back',
context: 'video.trim.cancel.dialog.confirm.text'
})
),
enableSaveDialog: false,
trimmingText: _(
msg({
message: 'Trimming video...',
context: 'video.trim.trimming.text'
})
)
});
I believe these lines:
private void seekTo(long msec, boolean needUpdateProgress) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mediaPlayer.seekTo((int) msec, MediaPlayer.SEEK_CLOSEST);
} else {
mediaPlayer.seekTo((int) msec);
}
updateCurrentTime(needUpdateProgress);
}
should activate the mediaPlayer somehow or at least give it a play
state prior start seeking.
If I set autoplay: true
everything works fine
Hi,
device: Samsung S22 with Android 14
When opening a video and try to trim instantly without tapping play first I get this error in a form of Alert/Dialog:
Fail to load media. Possibly invalid file or no network connection
Remarks:
Save
then the trimmed video is returned fine but the error alert shows up for one last time.