Skip to content

Commit

Permalink
Optimisations.
Browse files Browse the repository at this point in the history
  • Loading branch information
tizisdeepan committed Aug 19, 2019
1 parent b25e237 commit 20b5c8a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.media.MediaMetadataRetriever
import android.net.Uri
import android.os.Environment
import android.util.AttributeSet
import android.util.Log
import android.view.LayoutInflater
import android.widget.FrameLayout
import android.widget.SeekBar
Expand Down Expand Up @@ -36,13 +35,11 @@ class VideoCropper @JvmOverloads constructor(context: Context, attrs: AttributeS
if (mFinalPath == null) {
val folder = Environment.getExternalStorageDirectory()
mFinalPath = folder.path + File.separator
Log.e(TAG, "Using default path " + mFinalPath!!)
}
return mFinalPath ?: ""
}
set(finalPath) {
mFinalPath = finalPath
Log.e(TAG, "Setting custom path " + mFinalPath!!)
}

init {
Expand Down Expand Up @@ -140,8 +137,6 @@ class VideoCropper @JvmOverloads constructor(context: Context, attrs: AttributeS
mediaMetadataRetriever.setDataSource(context, mSrc)
val duration = java.lang.Long.parseLong(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION))
val frameCount = duration / 1000 * frameRate
Log.e("FRAME RATE", frameRate.toString())
Log.e("FRAME COUNT", (duration / 1000 * frameRate).toString())
VideoOptions(context).cropVideo(width, height, x, y, file.path, outPutPath, outputFileUri, mOnCropVideoListener, frameCount.toInt())
}

Expand Down Expand Up @@ -191,11 +186,6 @@ class VideoCropper @JvmOverloads constructor(context: Context, attrs: AttributeS
Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e)
}
}
}
)
}

companion object {
private val TAG = VideoCropper::class.java.simpleName
})
}
}
16 changes: 6 additions & 10 deletions video-editor/src/main/java/com/video/trimmer/view/VideoTrimmer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ class VideoTrimmer @JvmOverloads constructor(context: Context, attrs: AttributeS
if (mFinalPath == null) {
val folder = Environment.getExternalStorageDirectory()
mFinalPath = folder.path + File.separator
Log.e(TAG, "Using default path " + mFinalPath!!)
}
return mFinalPath ?: ""
}
set(finalPath) {
mFinalPath = finalPath
Log.e(TAG, "Setting custom path " + mFinalPath!!)
}

init {
Expand All @@ -84,14 +82,12 @@ class VideoTrimmer @JvmOverloads constructor(context: Context, attrs: AttributeS
}
})

val gestureDetector = GestureDetector(context,
object : GestureDetector.SimpleOnGestureListener() {
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
onClickVideoPlayPause()
return true
}
}
)
val gestureDetector = GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() {
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
onClickVideoPlayPause()
return true
}
})

video_loader.setOnErrorListener { _, what, _ ->
mOnTrimVideoListener?.onError("Something went wrong reason : $what")
Expand Down

0 comments on commit 20b5c8a

Please sign in to comment.