Skip to content

Commit

Permalink
add kotlin annotation to be compatible with java
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler committed Aug 14, 2020
1 parent 9ddbcb2 commit 2d209a3
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ enum class VideoQuality {

object VideoCompressor : CoroutineScope by MainScope() {

private var job: Job = Job()
private var job: Job? = null

private fun doVideoCompression(
srcPath: String, destPath: String, quality: VideoQuality,
isMinBitRateEnabled: Boolean, keepOriginalResolution: Boolean, listener: CompressionListener
srcPath: String,
destPath: String,
quality: VideoQuality,
isMinBitRateEnabled: Boolean,
keepOriginalResolution: Boolean,
listener: CompressionListener
) = launch {
isRunning = true
listener.onStart()
Expand All @@ -33,9 +37,10 @@ object VideoCompressor : CoroutineScope by MainScope() {
} else {
listener.onFailure(result.failureMessage ?: "An error has occurred!")
}

}

@JvmStatic
@JvmOverloads
fun start(
srcPath: String,
destPath: String,
Expand All @@ -54,8 +59,9 @@ object VideoCompressor : CoroutineScope by MainScope() {
)
}

@JvmStatic
fun cancel() {
job.cancel()
job?.cancel()
isRunning = false
}

Expand All @@ -64,7 +70,6 @@ object VideoCompressor : CoroutineScope by MainScope() {
srcPath: String, destPath: String, quality: VideoQuality, isMinBitRateEnabled: Boolean,
keepOriginalResolution: Boolean, listener: CompressionListener
): Result = withContext(Dispatchers.IO) {

return@withContext compressVideo(
srcPath,
destPath,
Expand All @@ -81,6 +86,4 @@ object VideoCompressor : CoroutineScope by MainScope() {
}
})
}


}

0 comments on commit 2d209a3

Please sign in to comment.