Skip to content

Commit

Permalink
Releases/v0.4.0 (#53)
Browse files Browse the repository at this point in the history
## 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 <edixon@mux.com>
  • Loading branch information
daytime-em committed Jun 7, 2023
1 parent 9bca4ad commit 73fd6dc
Show file tree
Hide file tree
Showing 11 changed files with 221 additions and 40 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ plugins {
id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.2' apply false
id 'org.jetbrains.kotlin.android' version '1.8.21' apply false
id 'com.mux.gradle.android.mux-android-distribution' version '1.0.3' apply false
}
id 'com.mux.gradle.android.mux-android-distribution' version '1.1.0' apply false
}
54 changes: 54 additions & 0 deletions library/Module.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Module Mux Upload SDK

The Mux Upload SDK processes and uploads video files to [Mux Video](https://www.mux.com/video) from
a user's local device. It is part of a full-stack flow described in our
guide, [Upload Files Directly](https://docs.mux.com/guides/video/upload-files-directly).

Once you have your direct upload URL, you can use it to upload a file using this SDK.

## Initializing the SDK

This SDK must be initialized once with a `Context` before it can be used

```kotlin
// from your custom Application class, Activity, etc. The context isn't saved
MuxUploadSdk.initialize(appContext = this)
```

## Starting a new upload

The `MuxUpload` class can be used to start a video upload and observe its progress.

```kotlin
// Start a new upload
val upload = MuxUpload.Builder(myUploadUrl, myInputFile).build()
upload.setResultListener { /*...*/ }
upload.setProgressListener { /*...*/ }
upload.start()
```

### Handling errors

The upload SDK handles transient errors according to a customizable retry policy. Fatal errors are
reported by `MuxUpload.setResultListener`.

```kotlin
upload.setResultListener { result ->
if (!result.isSuccess) {
notifyError()
} else {
/*...*/
}
}
```

## Resuming uploads after process death

Uploads managed by this SDK can be resumed after process death, or if network connectivity caused
them to fail at some time in the past.

```kotlin
MuxUploadManager.resumeAllCachedJobs()
val upload = MuxUploadManager.findUploadByFile(myVideoFile)
upload.setResultListener { /*...*/ }
```
8 changes: 6 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,22 @@ muxDistribution {
groupIds just("com.mux.video")
publicReleaseIf releaseOnTag()

packageJavadocs = releaseOnTag().call()
packageJavadocs = true
packageSources = true
publishIf { it.containsIgnoreCase("release") }
artifactoryConfig {
contextUrl = "https://muxinc.jfrog.io/artifactory/"
releaseRepoKey = 'default-maven-release-local'
devRepoKey = 'default-maven-local'
}
dokkaConfig {
moduleName = "Mux Upload SDK"
footer = "(c) " + new Date().format("yyyy") + " Mux, Inc. Have questions or need help?" +
" Contact support@mux.com"
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.9.0'

implementation "com.squareup.okhttp3:logging-interceptor:4.11.0"
Expand Down
5 changes: 5 additions & 0 deletions library/logo-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 13 additions & 5 deletions library/src/main/java/com/mux/video/upload/MuxUploadSdk.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.mux.video.upload

import android.content.Context
import android.util.Log
import com.mux.video.upload.MuxUploadSdk.initialize
import com.mux.video.upload.api.MuxUploadManager
import com.mux.video.upload.internal.UploadJobFactory
import com.mux.video.upload.internal.UploadMetrics
Expand All @@ -11,13 +12,13 @@ import okhttp3.logging.HttpLoggingInterceptor
import java.util.concurrent.TimeUnit

/**
* Uploads videos to Mux Video.
* This object allows you to get version info, enable logging, override the HTTP client, etc
*
* TODO: This would be a good place to put usage
* Before using the SDK, you must call [initialize].
*/
object MuxUploadSdk {
/**
* The current version of this SDK. Release builds of this SDK follow semver (https://semver.org)
* The current version of the SDK. Release builds of this SDK follow semver (https://semver.org)
*/
@Suppress("unused")
const val VERSION = BuildConfig.LIB_VERSION
Expand Down Expand Up @@ -56,12 +57,19 @@ object MuxUploadSdk {
.build()
}

@Suppress("unused") @JvmOverloads
/**
* Initializes the SDK with the given Context. The Context instance isn't saved.
*
* @param appContext A Context for your app. The passed instance isn't saved
* @param resumeStoppedUploads If true, uploads that failed due to errors or process death will be automatically resumed
*/
@Suppress("unused")
@JvmOverloads
fun initialize(appContext: Context, resumeStoppedUploads: Boolean = true) {
initializeUploadPersistence(appContext)
UploadMetrics.initialize(appContext)

if (resumeStoppedUploads) {
if (resumeStoppedUploads) {
val upl = MuxUploadManager.resumeAllCachedJobs()
}
}
Expand Down
Loading

0 comments on commit 73fd6dc

Please sign in to comment.