freddyfang / android-video-trimmer

Video trimmer widget
61 stars 25 forks source link

Blank Slider #1

Open simahero opened 4 years ago

simahero commented 4 years ago

Hello!

I am trying to implement your lib (which looks awesome!).

However whenever i run the app, the slider is black, and also i can not drag it.

freddyfang commented 4 years ago

Thank you for your endorsement, and sorry for replying late.

I tried to run the test app and it works well on two of my phones. Did you grant the permission and pick the video? Could you give me more specific details so that I could help you?

simahero commented 4 years ago

Hi!

Also sorry for the late response, my PC got broken.

Whenever I use your trimmert GUI, all im getting is a black screen, but the trimmer is visible (no thumbnails). I logge if i have schosen a valid video, and its not an URI problem.

Also im using Java, but that shouldnt be a problem, right?

`<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" tools:context=".Fragments.CREATE.CutFragment">

<Button
    android:id="@+id/button"
    android:layout_width="35dp"
    android:layout_height="35dp"
    android:layout_marginTop="16dp"
    android:layout_marginEnd="16dp"
    android:background="@drawable/ic_done_black_24dp"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<TextView
    android:id="@+id/durationView"
    android:layout_width="wrap_content"
    android:textSize="12sp"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintBottom_toTopOf="@+id/video_trimmer"
    android:layout_marginBottom="12dp"
    android:textColor="@android:color/white"
    android:layout_height="wrap_content"/>

<idv.luchafang.videotrimmer.VideoTrimmerView
    android:id="@+id/video_trimmer"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginBottom="11dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:vtv_window_bar_width="10dp"
    app:vtv_window_border_color="@android:color/white"
    app:vtv_window_border_width="2dp"
    app:vtv_window_left_bar="@drawable/trimmer_left_bar"
    app:vtv_window_right_bar="@drawable/trimmer_right_bar" >

</idv.luchafang.videotrimmer.VideoTrimmerView>

<VideoView
    android:id="@+id/videoView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="invisible"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>`

im setting the trimmer like this videoTrimmerView.setVideo(new File(model.getCutVid().getValue().getPath())) .setMinDuration(0) .setMaxDuration(10000) .setFrameCountInWindow(8) .setOnSelectedRangeChangedListener(this) .show();

freddyfang commented 4 years ago

It looks good to me. Can you paste the error log? Also, correct me if I am wrong, it's a local video file and the read permission has already been granted?

simahero commented 4 years ago

There are no errors. It is loaded, but not working corretly.

Yes it is a local file, and permission are granted.

Btw inlike your work! Looks awesome!

simahero commented 4 years ago

whoopps, there is an error!

E/RecycleView: No adapter attached; skipping layout

freddyfang commented 4 years ago

Okay I guess I found the reason. Min duration cannot be 0 cause we can't cut video with no frames. I should throw out a log to warn it.

simahero commented 4 years ago

I have tried to set minduration, but still nothing happens :(

freddyfang commented 4 years ago

Can you check if all of the following condition are matched?

minDuration > 0L maxDuration > 0L maxDuration >= minDuration videoLength >= minDuration

jaythummar95 commented 4 years ago

Same issue please provide a solution please

silvershort commented 4 years ago

I have the same problem. Has anyone solved it? The sample app works fine. But using the library creates a problem.

silvershort commented 4 years ago

I identified the problem.

It does not work if I use videoTrimmerView.show() directly from onCreate() after getting the filepath using Intent from another activity.

To use it directly in onCreate(), need to Handler().postDelayed about 100ms.

kartik1225 commented 4 years ago

I am not even able to see the slider all, I see is blank space nothing else. even after postDelayed in main looper

thorny84 commented 4 years ago

The problem seems to be that the presenter is instantiated in onAttachedToWindow. Do the show in a post and it should work. Waiting for a fix. :)

svenvdz commented 4 years ago

Running into the same issues, RecyclerView: No adapter attached; skipping layout, I am using the library in my java project shouldn't be a problem right? The demo seems to work when I build it

Sumanta9x9 commented 4 years ago

It is working ? I have added a 2.5s delay. But it still does not work.

handler = trimmerView .setVideo(new File(file)) .setMaxDuration(info.getDuration()) // millis .setMinDuration(1000) // millis .setFrameCountInWindow(10) .setExtraDragSpace(10) // pixels .setOnSelectedRangeChangedListener(this); new Handler().postDelayed(new Runnable() { @Override public void run() { handler.show(); } }, 2500);

image

Kasun-thilina commented 4 years ago

I identified the problem.

It does not work if I use videoTrimmerView.show() directly from onCreate() after getting the filepath using Intent from another activity.

To use it directly in onCreate(), need to Handler().postDelayed about 100ms.

thanks mate. this solved my issue ❤️

lazy-coder-10 commented 3 years ago

I solved this issue by removing code inside onAttachWindow to somewhere else.

Place below code inside initViews function private fun initViews() { videoFrameListView.layoutManager = LinearLayoutManager(context, HORIZONTAL, false) presenter = obtainVideoTrimmerPresenter() .apply { onViewAttached(this@VideoTrimmerView) } }

and one more change is add OnPresenterCreated inside the onShow() fun show() { presenter?.show() onPresenterCreated() } This is working for me.

easedroid commented 3 years ago

I have the same issue. The demo projects working because it implements older constraint layout api i.e.

implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

if I update this then it won't work in demo project also.

if anyone has solution please share. Thank you all.

lazy-coder-10 commented 3 years ago

@easedroid You can try the above solution https://github.com/freddyfang/android-video-trimmer/issues/1#issuecomment-722313725

and here is the output file

MicrosoftTeams-image (1)

easedroid commented 3 years ago

I solved this issue by removing code inside onAttachWindow to somewhere else.

Place below code inside initViews function private fun initViews() { videoFrameListView.layoutManager = LinearLayoutManager(context, HORIZONTAL, false) presenter = obtainVideoTrimmerPresenter() .apply { onViewAttached(this@VideoTrimmerView) } }

and one more change is add OnPresenterCreated inside the onShow() fun show() { presenter?.show() onPresenterCreated() } This is working for me.

I have tried and have changed only these two methods as you mentioned but no luck, are you using latest constraint layout api? if yes then can you share the complete block that you have changed.

lazy-coder-10 commented 3 years ago

yes i am using constraint layout 1.1.3

can you can share a sample project ?? so that we can fix this issue.

FuherProgramer commented 3 years ago

Hi guys this is my solution and its works wery well ..So you can update the last version of ConstraintLayout : 1- just change the ConstraintLayout to Relativelayout in layout_video_trimmer like this : <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="5dp" android:paddingBottom="5dp">

<androidx.recyclerview.widget.RecyclerView
        android:id="@+id/videoFrameListView"
        android:layout_width="wrap_content"
        android:layout_height="43dp"
        android:layout_gravity="center_vertical"
        android:layout_centerInParent="true"
        android:overScrollMode="never"
        android:paddingTop="2dp"
        android:paddingBottom="2dp"/>

<idv.luchafang.videotrimmer.slidingwindow.SlidingWindowView
        android:id="@+id/slidingWindowView"
        android:layout_width="wrap_content"
        android:layout_height="43dp"
        android:layout_marginStart="11dp"
        android:layout_marginTop="7dp"
        android:layout_marginEnd="11dp"
        android:layout_centerInParent="true" />

2- update the idv.luchafang.videotrimmer.VideoTrimmerView in main_layout like this : <idv.luchafang.videotrimmer.VideoTrimmerView android:id="@+id/videoTrimmerView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="70dp" app:layout_constraintBottom_toBottomOf="parent" app:vtv_window_bar_width="10dp" app:vtv_window_border_color="#FF0000" app:vtv_window_border_width="2dp" app:vtv_window_left_bar="@drawable/trimmer_left_bar" app:vtv_window_right_bar="@drawable/trimmer_right_bar" tools:layout_editor_absoluteX="0dp" />

hop that help you

chirag-sps commented 2 years ago

@FuherProgramer Your solution is correct, only need to change Constraint Layout to RelativeLayout and i also change ConstraintLayout implementation to RelativeLayout in class VideoTrimmerView, Now its working fine

Mohit-AppCrunk commented 1 year ago

Hello, the views are not showing when using com.google.android.material:material:1.6.1 dependency.i have tried many solution but nothing worked. Please tell waht could be possible solution for that

chirag-sps commented 1 year ago

Hello @Mohit-AppCrunk the above solution I posted is working fine, you can make changes in you file.

DonMarv00 commented 11 months ago

I forked it, updated the dependencies and gradle also fixed the blank VideoTrimmerView Error: https://github.com/MarvinStelter/android-video-trimmer