Skip to main content

Audio content

Overview

Audio content is a key part of making awesome video.

Video Editor SDK can play, trim, merge and add audio content to a video.

info
  1. Banuba does not deliver audio content for Video Editor SDK.
  2. Video Editor can apply audio file stored on the device. The SDK is not responsible for downloading audio content except Soundstripe, Mubert

There are 2 approaches of using audio content:

  1. AudioBrowser - specific module and a set of screens that includes built in support of browsing and applying audio content within video editor. The user does not leave the sdk while using audio.
  2. External API - the client implements specific API for managing audio content. The user leaves the SDK and is taken to an app screen when audio is requested.

Audio Browser

Audio Browser is a specific Android module that allows to browse, play and apply audio content within video editor.
It supports 3 sources for audio content:

  1. My Library - includes audio content available on the user's device

  2. Soundstripe - includes built in integration with Soundstripe API.

  3. Mubert - includes built in integration with Mubert API.

Add the dependency

implementation "com.banuba.sdk:ve-audio-browser-sdk:${version}"

to your gradle file and specify AudioBrowserKoinModule Koin module in VideoEditorModule

startKoin {
...
modules(
+ AudioBrowserKoinModule().module,
VideoEditorKoinModule().module
)
}

to integrate AudioBrowser.

Connect My Library

My Library is a default implementation in AudioBrowser . It allows the user to apply audio that is available on a device.

Use AudioBrowserMusicProvider implementation in VideoEditorModule to enable My Library.


single<ContentFeatureProvider<TrackData, Fragment>>(named("musicTrackProvider")) {
AudioBrowserMusicProvider()
}

Connect Soundstripe

Soundstripe is a service for providing the best audio tracks for creating video content. Your users will be able to add audio tracks while recording or editing video content.

info

The feature is not activated by default.
Please contact Banuba representatives to know more about using this feature.

Screenshot  Screenshot 

Use SoundstripeProvider implementation in VideoEditorModule

single<ContentFeatureProvider<TrackData, Fragment>>(named("musicTrackProvider")){
SoundstripeProvider()
}

Connect Mubert

Mubert is a service that delivers Generative AI Music. Your users will be able to add audio tracks while recording or editing video content.

info

Please contact Mubert representatives to request keys.

Screenshot 

Set Mubert license and token keys in VideoEditorModule.

single {
MubertApiConfig(
mubertLicence = "...",
mubertToken = "..."
)
}

single<ContentFeatureProvider<TrackData, Fragment>>(named("musicTrackProvider")) {
AudioBrowserMusicProvider()
}

Use MubertApiConfig to adjust Mubert settings.

PropertyAvailable valuesDescription
generatedTrackDurationSecNumber > 0duration that applied for generated tracks in seconds
generateTrackBitrateany of the following values: 32, 96, 128, 192, 256, 320sound quality measured in kbps
generatedTrackIntencityany of the following values: low, medium, highinstrumental saturation (number of stems) for generated tracks
generatedTrackFormatany of the following values: mp3, wav, flacformat of generated tracks
generatedTracksAmountNumber > 0amount of tracks to generate for selected category

Connect External API

Video Editor includes special API for integrating your custom audio content provider and applying this content in video editor.
The user will be taken to your app specific screen when audio is requested on video editor screen i.e. camera or editor. Next, once the user picks audio content on your app screen you need to follow API and return the user to video editor.
Any audio file should stored on the device before applying.

Below is a guide of using API to provide your audio to video editor.
First, create new Activity CustomAudioContentActivity that will handle API and create new method to start it from video editor. This Activity you can use to implement any API for downloading audio content and showing your beautiful UI to your users.

class CustomAudioContentActivity : AppCompatActivity() {
...

companion object {
fun buildPickMusicResourceIntent(
context: Context,
extras: Bundle
) =
Intent(context, AwesomeAudioContentActivity::class.java).apply {
putExtras(extras)
}
}
}

where extras includes a data that can be used in the Activity.

  1. ProvideTrackContract.EXTRA_LAST_PROVIDED_TRACK of TrackData. Can be null. null is used to dismiss audio.
  2. ProvideTrackContract.EXTRA_TRACK_TYPE of TrackType.

Next, create CustomActivityMusicProvider and implement ContentFeatureProvider<TrackData>.

class CustomActivityMusicProvider : ContentFeatureProvider<TrackData, Fragment> {

private var activityResultLauncher: ActivityResultLauncher<Intent>? = null

private val activityResultCallback: (TrackData?) -> Unit = {
activityResultCallbackInternal(it)
}
private var activityResultCallbackInternal: (TrackData?) -> Unit = {}

override fun init(hostFragment: WeakReference<Fragment>) {
activityResultLauncher = hostFragment.get()?.registerForActivityResult(
ProvideTrackContract(),
activityResultCallback
)
}

override fun requestContent(
context: Context,
extras: Bundle
): ContentFeatureProvider.Result<TrackData> = ContentFeatureProvider.Result.RequestUi(
intent = CustomAudioContentActivity.buildPickMusicResourceIntent(
context,
extras
)
)

override fun handleResult(
hostFragment: WeakReference<Fragment>,
intent: Intent,
block: (TrackData?) -> Unit
) {
activityResultCallbackInternal = block
activityResultLauncher?.launch(intent)
}
}

And set CustomActivityMusicProvider to VideoEditorModule

    single<ContentFeatureProvider<TrackData>>(named("musicTrackProvider"), override = true) {
CustomActivityMusicProvider()
}

Please keep in mind that only one instance of musicTrackProvider can exist either your custom ofExternal API or Audio Browser.

Finally, pass audio content to apply audio in video editor. Instance of TrackData is used for passing in Intent to video editor. The audio should be stored on the device.

val trackData = TrackData(
UUID.randomUUID(),
"My awesome track",
audioTrackUri, // Uri of the audio track on local storage
// file:///data/user/0/<package>/files/<any folder>/awesome.wav
"Awesome Artist"
)

To pass TrackData to video editor your need to use setResult with Intent and finish current Activity.

val trackToApply: TrackData = ...

val resultIntent = Intent().apply {
putExtra(ProvideTrackContract.EXTRA_RESULT_TRACK_DATA,
trackToApply)
}
setResult(Activity.RESULT_OK, resultIntent)
finish()

To dismiss previously selected audio track you can pass null for TrackData.

Resources

The following string resources are used in AudioBrowser.

ResourceIdValue
apply_trackUse
remove_trackStop\nusing
track_loading_failedSorry, audio content is temporarily unavailable
track_search_cancelCancel
audio_browser_title_libraryMy library
audio_browser_title_categoryMusic
audio_browser_title_empty_categoryMusic
audio_browser_load_moreShow more
audio_browser_error_tracks_not_foundNo tracks found
audio_browser_error_categories_not_foundNo categories found
audio_browser_error_empty_libraryNo tracks yet
audio_browser_error_license_not_activeThe license is not active
audio_browser_error_license_expiredThe license expired
audio_browser_error_license_accessAccess denied, check license access type
audio_browser_error_license_api_versionAccess denied, check license API version
audio_browser_error_license_wrong_keyMubert key is missing. In order to get it contact Banuba rep.
audio_browser_hint_search_categoriesSearch by categories
audio_browser_hint_search_sub_categoriesSearch by groups
audio_browser_hint_search_tracksSearch by tracks
audio_browser_error_dialog_titleOops, something went wrong…
audio_browser_error_dialog_descriptionPlease, try again later.
audio_browser_error_dialog_retryRetry
audio_browser_error_dialog_closeClose
permission_library_description_messageAllow to access to your storage to select an audio tracks from your device.
audio_browser_connection_error_titleNo internet connection
audio_browser_connection_error_messagePlease, check your connection and try again.
audio_browser_connection_error_btnRetry
audio_browser_connection_error_toastNo internet connection
action_add_music_trackTracks
action_add_voice_recordingRecord
action_effectsEffects
action_editEdit
action_deleteDelete
edit_track_volume_titleVolume
edit_track_volume_percent%1$d%%
edit_track_audio_durationAudio duration
edit_track_duration_errorAudio should be longer than %1$.1f sec
error_voice_recording_startError on voice recording start
error_invalid_duration_voice_recordingMin voice recording duration - %1$.1f sec
error_invalid_duration_music_trackMin music track duration - %1$.1f sec
error_voice_recording_delete_fileInternal error when try to delete voice recording file
error_track_limitMax available tracks - %1$d
error_no_spaceNo space