a914-gowtham / android-video-trimmer

Helps to trim local videos with compress option on Android applications using Exoplayer 2 and FFmpeg.
Other
380 stars 117 forks source link

I'm getting this issue when I import a video from the gallery #8

Closed MohamedFattah95 closed 4 years ago

MohamedFattah95 commented 4 years ago

W/System.err: java.lang.NullPointerException: uriString at android.net.Uri$StringUri.(Uri.java:496) at android.net.Uri$StringUri.(Uri.java:486) at android.net.Uri.parse(Uri.java:458) at com.gowtham.library.ui.ActVideoTrimmer.setDataInView(ActVideoTrimmer.java:173) at com.gowtham.library.ui.ActVideoTrimmer.onPostCreate(ActVideoTrimmer.java:143) at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1381) at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3322) at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221) at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2017) W/System.err: at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7403) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)

The video is not imported and I'm getting a blank player.

a914-gowtham commented 4 years ago

Make sure you have to give video uri as String and try Logging your videoUri before call the below code
TrimVideo.activity(String.valueOf(videoUri)) .start(this);

a914-gowtham commented 4 years ago

Refer this

MohamedFattah95 commented 4 years ago

This is my video path as String /storage/emulated/0/WhatsApp/Media/WhatsApp Video/VID-20200507-WA0074.mp4 However it still not loading the video. @a914-gowtham

a914-gowtham commented 4 years ago

Can u show me your builder code for opening the TrimmerActivity and OnActivityResult method

MohamedFattah95 commented 4 years ago

TrimVideo.activity(media.getPath()) .setAccurateCut(true) .setTrimType(TrimType.MIN_MAX_DURATION) .setMinToMax(1, 15) .start(this);

OnActivityResult: if (requestCode == TrimVideo.VIDEO_TRIMMER_REQ_CODE && resultCode == RESULT_OK && data != null) { Uri uri = Uri.parse(TrimVideo.getTrimmedVideoPath(data)); Log.d("Trim", "Trimmed path:: " + uri); }

a914-gowtham commented 4 years ago

Don't put media.getPath just use media TrimVideo.activity(media) .setAccurateCut(true) .setTrimType(TrimType.MIN_MAX_DURATION) .setMinToMax(1, 15) .start(this);

MohamedFattah95 commented 4 years ago

"media" is an object of an video picker, not a String. media.getPath() returns /storage/emulated/0/WhatsApp/Media/WhatsApp Video/VID-20200507-WA0074.mp4 as a String.

a914-gowtham commented 4 years ago

Please refer this https://github.com/a914-gowtham/Android-video-trimmer/blob/master/app/src/main/java/com/gowtham/videotrimmer/MainActivity.java