LA2L for developers

Sharing to LA2L Sender

An Android app can send sounds to Live without any network code: it shares the WAV files with LA2L Sender, the installed web app of LA2L, and puts a description of the sounds in the text of the share. The Android SDK, once published, does it in one call, La2lShare.intent(context, soundPackage); below is what it does. LA2L Sender shows them with loop or one-shot, BPM and role filled in, and the user taps Send.

The user installs LA2L Sender once from Chrome (any phone) or Samsung Internet (Samsung phones), at https://lloydstellar.nl/la2l/, opens it once and pairs it with Live. From then on it is in the share menu. Android only: not Firefox, not iOS.

The share

val manifest = org.json.JSONObject()
    .put("schema", "app2live/1")
    .put("title", "Treinbeat")
    .put("source", org.json.JSONObject().put("app", "Web808")) // the tracks: "Kick (Web808)"
    .put("tempo", org.json.JSONObject().put("bpm", 92))
    .put("items", org.json.JSONArray()
        .put(org.json.JSONObject().put("file", "kick.wav").put("name", "Kick").put("kind", "loop").put("role", "drums").put("length_beats", 16))
        .put(org.json.JSONObject().put("file", "robot.wav").put("name", "Robot hallo").put("kind", "oneshot").put("role", "vocal")))

val uris = arrayListOf(kickWav, robotWav).map {
    androidx.core.content.FileProvider.getUriForFile(context, "${context.packageName}.files", it)
}
val share = android.content.Intent(android.content.Intent.ACTION_SEND_MULTIPLE).apply {
    type = "audio/wav"
    putParcelableArrayListExtra(android.content.Intent.EXTRA_STREAM, ArrayList(uris))
    putExtra(android.content.Intent.EXTRA_TEXT, manifest.toString())
    putExtra(android.content.Intent.EXTRA_SUBJECT, "Treinbeat")
    addFlags(android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
context.startActivity(android.content.Intent.createChooser(share, "Send to Live"))

The files are shared through a FileProvider, declared once in AndroidManifest.xml:

<provider
    android:name="androidx.core.content.FileProvider"
    android:authorities="${applicationId}.files"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/shared_sounds" />
</provider>

with res/xml/shared_sounds.xml naming the folder the WAV files are in, for example <paths><cache-path name="sounds" path="sounds/" /></paths>.

The description in the text

What LA2L Sender takes

Any app that shares sound files works without a description too. Then the user sets loop or one-shot, BPM and role in LA2L Sender before sending.