Skip to content

Commit 73fd6dc

Browse files
authored
Releases/v0.4.0 (#53)
## Improvements * doc: Finish out the public KDoc (#49) * doc: Improve KDocs and add logo (#51) * nfc: Hide some internal classes from java. This should not affect anyone using the SDK ## Fixes * fix: pausing uploads shouldn't create errors (#55) Co-authored-by: Emily Dixon <[email protected]>
1 parent 9bca4ad commit 73fd6dc

File tree

11 files changed

+221
-40
lines changed

11 files changed

+221
-40
lines changed

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ plugins {
77
id 'com.android.application' version '7.4.2' apply false
88
id 'com.android.library' version '7.4.2' apply false
99
id 'org.jetbrains.kotlin.android' version '1.8.21' apply false
10-
id 'com.mux.gradle.android.mux-android-distribution' version '1.0.3' apply false
11-
}
10+
id 'com.mux.gradle.android.mux-android-distribution' version '1.1.0' apply false
11+
}

library/Module.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Module Mux Upload SDK
2+
3+
The Mux Upload SDK processes and uploads video files to [Mux Video](https://www.mux.com/video) from
4+
a user's local device. It is part of a full-stack flow described in our
5+
guide, [Upload Files Directly](https://docs.mux.com/guides/video/upload-files-directly).
6+
7+
Once you have your direct upload URL, you can use it to upload a file using this SDK.
8+
9+
## Initializing the SDK
10+
11+
This SDK must be initialized once with a `Context` before it can be used
12+
13+
```kotlin
14+
// from your custom Application class, Activity, etc. The context isn't saved
15+
MuxUploadSdk.initialize(appContext = this)
16+
```
17+
18+
## Starting a new upload
19+
20+
The `MuxUpload` class can be used to start a video upload and observe its progress.
21+
22+
```kotlin
23+
// Start a new upload
24+
val upload = MuxUpload.Builder(myUploadUrl, myInputFile).build()
25+
upload.setResultListener { /*...*/ }
26+
upload.setProgressListener { /*...*/ }
27+
upload.start()
28+
```
29+
30+
### Handling errors
31+
32+
The upload SDK handles transient errors according to a customizable retry policy. Fatal errors are
33+
reported by `MuxUpload.setResultListener`.
34+
35+
```kotlin
36+
upload.setResultListener { result ->
37+
if (!result.isSuccess) {
38+
notifyError()
39+
} else {
40+
/*...*/
41+
}
42+
}
43+
```
44+
45+
## Resuming uploads after process death
46+
47+
Uploads managed by this SDK can be resumed after process death, or if network connectivity caused
48+
them to fail at some time in the past.
49+
50+
```kotlin
51+
MuxUploadManager.resumeAllCachedJobs()
52+
val upload = MuxUploadManager.findUploadByFile(myVideoFile)
53+
upload.setResultListener { /*...*/ }
54+
```

library/build.gradle

+6-2
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,22 @@ muxDistribution {
3838
groupIds just("com.mux.video")
3939
publicReleaseIf releaseOnTag()
4040

41-
packageJavadocs = releaseOnTag().call()
41+
packageJavadocs = true
4242
packageSources = true
4343
publishIf { it.containsIgnoreCase("release") }
4444
artifactoryConfig {
4545
contextUrl = "https://muxinc.jfrog.io/artifactory/"
4646
releaseRepoKey = 'default-maven-release-local'
4747
devRepoKey = 'default-maven-local'
4848
}
49+
dokkaConfig {
50+
moduleName = "Mux Upload SDK"
51+
footer = "(c) " + new Date().format("yyyy") + " Mux, Inc. Have questions or need help?" +
52+
" Contact [email protected]"
53+
}
4954
}
5055

5156
dependencies {
52-
5357
implementation 'androidx.core:core-ktx:1.9.0'
5458

5559
implementation "com.squareup.okhttp3:logging-interceptor:4.11.0"

library/logo-icon.svg

+5
Loading

library/src/main/java/com/mux/video/upload/MuxUploadSdk.kt

+13-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.mux.video.upload
22

33
import android.content.Context
44
import android.util.Log
5+
import com.mux.video.upload.MuxUploadSdk.initialize
56
import com.mux.video.upload.api.MuxUploadManager
67
import com.mux.video.upload.internal.UploadJobFactory
78
import com.mux.video.upload.internal.UploadMetrics
@@ -11,13 +12,13 @@ import okhttp3.logging.HttpLoggingInterceptor
1112
import java.util.concurrent.TimeUnit
1213

1314
/**
14-
* Uploads videos to Mux Video.
15+
* This object allows you to get version info, enable logging, override the HTTP client, etc
1516
*
16-
* TODO: This would be a good place to put usage
17+
* Before using the SDK, you must call [initialize].
1718
*/
1819
object MuxUploadSdk {
1920
/**
20-
* The current version of this SDK. Release builds of this SDK follow semver (https://semver.org)
21+
* The current version of the SDK. Release builds of this SDK follow semver (https://semver.org)
2122
*/
2223
@Suppress("unused")
2324
const val VERSION = BuildConfig.LIB_VERSION
@@ -56,12 +57,19 @@ object MuxUploadSdk {
5657
.build()
5758
}
5859

59-
@Suppress("unused") @JvmOverloads
60+
/**
61+
* Initializes the SDK with the given Context. The Context instance isn't saved.
62+
*
63+
* @param appContext A Context for your app. The passed instance isn't saved
64+
* @param resumeStoppedUploads If true, uploads that failed due to errors or process death will be automatically resumed
65+
*/
66+
@Suppress("unused")
67+
@JvmOverloads
6068
fun initialize(appContext: Context, resumeStoppedUploads: Boolean = true) {
6169
initializeUploadPersistence(appContext)
6270
UploadMetrics.initialize(appContext)
6371

64-
if (resumeStoppedUploads) {
72+
if (resumeStoppedUploads) {
6573
val upl = MuxUploadManager.resumeAllCachedJobs()
6674
}
6775
}

0 commit comments

Comments
 (0)