@@ -51,7 +51,11 @@ import com.lb.video_trimmer_library.view.TimeLineView
5151import java.io.File
5252import java.lang.ref.WeakReference
5353
54- abstract class BaseVideoTrimmerView @JvmOverloads constructor(context : Context , attrs : AttributeSet , defStyleAttr : Int = 0 ) : FrameLayout(context, attrs, defStyleAttr) {
54+ abstract class BaseVideoTrimmerView @JvmOverloads constructor(
55+ context : Context ,
56+ attrs : AttributeSet ,
57+ defStyleAttr : Int = 0
58+ ) : FrameLayout(context, attrs, defStyleAttr) {
5559 private val rangeSeekBarView: RangeSeekBarView
5660 private val videoViewContainer: View
5761 private val timeInfoContainer: View
@@ -112,12 +116,12 @@ abstract class BaseVideoTrimmerView @JvmOverloads constructor(context: Context,
112116 }
113117 })
114118 val gestureDetector = GestureDetector (context,
115- object : GestureDetector .SimpleOnGestureListener () {
116- override fun onSingleTapConfirmed (e : MotionEvent ): Boolean {
117- onClickVideoPlayPause()
118- return true
119- }
119+ object : GestureDetector .SimpleOnGestureListener () {
120+ override fun onSingleTapConfirmed (e : MotionEvent ): Boolean {
121+ onClickVideoPlayPause()
122+ return true
120123 }
124+ }
121125 )
122126 videoView.setOnErrorListener { _, what, extra ->
123127 if (videoTrimmingListener != null )
@@ -154,7 +158,7 @@ abstract class BaseVideoTrimmerView @JvmOverloads constructor(context: Context,
154158 private fun setUpMargins () {
155159 val marge = rangeSeekBarView.thumbWidth
156160 val lp: MarginLayoutParams = timeLineView.layoutParams as MarginLayoutParams
157- lp.setMargins(marge, 0 , marge, 0 )
161+ lp.setMargins(marge, lp.topMargin , marge, lp.bottomMargin )
158162 timeLineView.layoutParams = lp
159163 }
160164
@@ -164,7 +168,8 @@ abstract class BaseVideoTrimmerView @JvmOverloads constructor(context: Context,
164168 pauseVideo()
165169 val mediaMetadataRetriever = MediaMetadataRetriever ()
166170 mediaMetadataRetriever.setDataSource(context, src)
167- val metadataKeyDuration = java.lang.Long .parseLong(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever .METADATA_KEY_DURATION ))
171+ val metadataKeyDuration =
172+ java.lang.Long .parseLong(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever .METADATA_KEY_DURATION ))
168173 if (timeVideo < MIN_TIME_FRAME ) {
169174 if (metadataKeyDuration - endPosition > MIN_TIME_FRAME - timeVideo) {
170175 endPosition + = MIN_TIME_FRAME - timeVideo
@@ -176,15 +181,23 @@ abstract class BaseVideoTrimmerView @JvmOverloads constructor(context: Context,
176181 if (videoTrimmingListener != null )
177182 videoTrimmingListener!! .onTrimStarted()
178183 BackgroundExecutor .execute(
179- object : BackgroundExecutor .Task (null , 0L , null ) {
180- override fun execute () {
181- try {
182- TrimVideoUtils .startTrim(context, src!! , dstFile!! , startPosition.toLong(), endPosition.toLong(), duration.toLong(), videoTrimmingListener!! )
183- } catch (e: Throwable ) {
184- Thread .getDefaultUncaughtExceptionHandler().uncaughtException(Thread .currentThread(), e)
185- }
184+ object : BackgroundExecutor .Task (null , 0L , null ) {
185+ override fun execute () {
186+ try {
187+ TrimVideoUtils .startTrim(
188+ context,
189+ src!! ,
190+ dstFile!! ,
191+ startPosition.toLong(),
192+ endPosition.toLong(),
193+ duration.toLong(),
194+ videoTrimmingListener!!
195+ )
196+ } catch (e: Throwable ) {
197+ Thread .getDefaultUncaughtExceptionHandler().uncaughtException(Thread .currentThread(), e)
186198 }
187199 }
200+ }
188201 )
189202 }
190203
0 commit comments