Skip to content

Instantly share code, notes, and snippets.

@mzorz
Created April 21, 2020 21:02
Show Gist options
  • Save mzorz/ffa5f1d05fab009dd3d06a6a53b3614b to your computer and use it in GitHub Desktop.
Save mzorz/ffa5f1d05fab009dd3d06a6a53b3614b to your computer and use it in GitHub Desktop.
diff --git a/app/src/main/java/com/automattic/portkey/compose/frame/FrameSaveManager.kt b/app/src/main/java/com/automattic/portkey/compose/frame/FrameSaveManager.kt
index ea8a255..5112808 100644
--- a/app/src/main/java/com/automattic/portkey/compose/frame/FrameSaveManager.kt
+++ b/app/src/main/java/com/automattic/portkey/compose/frame/FrameSaveManager.kt
@@ -116,9 +116,11 @@ class FrameSaveManager(private val photoEditor: PhotoEditor) : CoroutineScope {
try {
// create ghost PhotoEditorView to be used for saving off-screen
val ghostPhotoEditorView = createGhostPhotoEditor(context, photoEditor.composedCanvas)
- throw Exception("THIS IS A TEST")
+ if (TEST_FLAG <= 1) {
+ TEST_FLAG++
+ throw Exception("THIS IS A TEST")
+ }
frameFile = saveImageFrame(frame, ghostPhotoEditorView, frameIndex)
- throw Exception("THIS IS A TEST")
saveProgressListener?.onFrameSaveCompleted(frameIndex)
} catch (ex: Exception) {
saveProgressListener?.onFrameSaveFailed(frameIndex, ex.message)
@@ -288,6 +290,7 @@ class FrameSaveManager(private val photoEditor: PhotoEditor) : CoroutineScope {
private const val VIDEO_CONCURRENCY_LIMIT = 3
private const val IMAGE_CONCURRENCY_LIMIT = 10
private const val VIDEO_PROCESSING_READY_WAIT_TIME_MILLIS: Long = 500
+ private var TEST_FLAG = 0
fun releaseAddedViews(frame: StoryFrameItem) {
// don't forget to remove these views from ghost offscreen view before exiting
diff --git a/mp4compose/src/main/java/com/daasuu/mp4compose/composer/Mp4ComposerEngine.kt b/mp4compose/src/main/java/com/daasuu/mp4compose/composer/Mp4ComposerEngine.kt
index eaccc2b..0d080d7 100755
--- a/mp4compose/src/main/java/com/daasuu/mp4compose/composer/Mp4ComposerEngine.kt
+++ b/mp4compose/src/main/java/com/daasuu/mp4compose/composer/Mp4ComposerEngine.kt
@@ -281,6 +281,10 @@ internal class Mp4ComposerEngine {
)
val progress = (videoProgress + audioProgress) / 2.0
if (progressCallback != null) {
+ if (TEST_FLAG == 0 && progress > 0.8f) {
+ TEST_FLAG++
+ throw Exception("THIS IS A TEST")
+ }
progressCallback!!.onProgress(progress)
}
}
@@ -366,6 +370,7 @@ internal class Mp4ComposerEngine {
private val PROGRESS_UNKNOWN = -1.0
private val SLEEP_TO_WAIT_TRACK_TRANSCODERS: Long = 10
private val PROGRESS_INTERVAL_STEPS: Long = 10
+ private var TEST_FLAG = 0
private val BIT_RATE = 2000000
private val FRAME_RATE = 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment