Skip to content

About

Kotlin library for embedding Mobilerun device streaming and events

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mobilerun

mobilerun-android

Kotlin library for embedding Mobilerun device streams in Android apps.
Live WebRTC video, remote input and task approvals, with optional Compose UI.

Building Mobilerun phones into your platform? Start with the Partner guide. It walks through the API key, one phone per user, stream keys and live viewing step by step.

Live device video with Android navigation controls In this package
  • DeviceStreamSession — connection, recovery and stream state.
  • StreamCredentials — target URL and per-connection token provider.
  • DeviceStreamView — interactive video for View hosts.
  • DeviceStream — Compose video and default navigation.
  • StreamTheme — colors, typography and white-label tokens.
  • TaskApprovalController — approval polling and decisions.
  • TaskApproval — Compose approval card.
Requirements
  • Android 7.0+ (API 24); Android SDK 36 to build.
  • JDK 17 and Kotlin 2.4.21.
  • A Mobilerun API key on your server.

Install

Configure Maven Central in settings.gradle.kts:

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
    }
}

Add the Compose SDK to your app module with group ai.mobilerun and version 0.1.0:

dependencies {
    implementation("ai.mobilerun:mobilerun-stream-compose:0.1.0")
}

For a View host, use ai.mobilerun:mobilerun-stream-android:0.1.0 instead. See package and artifacts for module details and headless JVM use.

Quick start

  1. Your server mints a short-lived stream key for one device with your API key using client.streamTokens.create. Follow the Partner guide.
  2. Your app's tokenProvider asks your server for a key before each connection.
  3. The SDK opens the stream with that key, one key per connection, and reconnects with a fresh one.

On your Node server, install @mobilerun/sdk@6.3.0 and keep MOBILERUN_API_KEY in the server environment. Return a fresh key to the authorized app for every connection:

import { MobilerunSDK } from '@mobilerun/sdk';

// Node server only. Authenticate the user and authorize this device before minting.
const client = new MobilerunSDK({
  apiKey: process.env.MOBILERUN_API_KEY,
  maxRetries: 0,
});
const allowedOrigins = ['https://app.example.com']; // optional browser origin policy
const { key, keyId, expiresAt } = await client.streamTokens.create({
  deviceId,
  ttlSeconds: 120,
  allowedOrigins,
});
res.writeHead(201, { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' });
res.end(JSON.stringify({ key, keyId, expiresAt }));

REST fallback: POST /v1/identity/stream-keys with bearer API-key authentication on the server.

In your app, backend below is your own client for that server:

val scope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
val session = DeviceStreamSession(context, credentials = {
    StreamCredentials(url = streamUrl, tokenProvider = { backend.mintStreamKey(deviceId) })
}, scope = scope)
session.start()
// Inside your composable:
StreamTheme { DeviceStream(session, Modifier.fillMaxSize()) }
// On screen disposal:
session.close(); scope.cancel()

To react to failures, collect session.errors: each failed attempt reports a reason (CredentialsUnavailable, TokenRejected, ConnectionRefused, Disconnected, …), its attempt and final once retries stop. See Stream keys. Every user-visible string comes from StreamLabels. The static StreamCredentials(url, token) form is legacy and deprecated: it reuses the same token on reconnect, so single-use keys need tokenProvider.

Never ship an API key in the app. Never cache keys or automatically retry mint requests. For the runnable sample, see TESTING.md.

Guides

Coding agents: use the Mobilerun device stream skill for Kotlin integration.

Guide Covers
Stream keys Token provider, deadlines, secure URLs and legacy credentials
Package Modules, supported API, configuration and Maven Central artifacts
Video and input View and Compose hosts, touch, keyboard, IME and navigation
Default UI Chrome, labels, themes and white-label slots
Task approvals Backend callbacks, polling, decisions and approval cards
Lifecycle Session ownership, visibility, network recovery and credentials
Statistics Stream stats, benchmark and hardening checks

Contributing

See CONTRIBUTING.md for builds, tests, conformance fixtures and release guidance. Report vulnerabilities privately as described in SECURITY.md.

License

Apache-2.0. App distributors must also retain applicable dependency licenses and notices; see third-party notices.

Microphone and camera

Supply per-device StreamConfig(publishCapabilities = …) from your backend to enable optional local microphone/camera injection. After host runtime permission and viewer connection, session.startPublish(PublishOptions(audio = true, video = true)) returns when active; session.stopPublish() releases capture without stopping viewing. Observe session.publishState and publish errors through session.errors (operation == "publish"). Reconnect never resumes capture. The default Compose UI includes a hideable, labelled microphone/camera pill. See Publishing for permissions, capabilities, errors and UI options.

About

Kotlin library for embedding Mobilerun device streaming and events

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages