- Summary
I'm building a Pomodoro timer tool and need to play a short local sound (e.g. "focus session ended") from within the tool. I couldn't find an approved way to do this.
- What I tried
Placed .mp3 files in res/raw and used the standard Android approach:
val context = LocalContext.current
MediaPlayer.create(context, R.raw.finished_pomodoro)?.apply {
setOnCompletionListener { release() }
start()
}
This fails at build time due to the SDK's lint rules:
blocked import 'androidx.compose.ui.platform.LocalContext'
LocalContext.current is not allowed — use LightScreen APIs instead
-
What I found in the plugin source
Looking at LightSdkPlugin.kt, Context, getSystemService(), and similar APIs are intentionally blocked (makes sense for sandboxing). I couldn't find any alternative in LightScreen, LightViewModel, or LightServiceMethod for playing a short local sound.
The only audio-related method is SetRingtone, but that permanently changes the user's system ringtone — not suitable for a one-off notification sound.
Question
Is there a planned/approved API for tools to play a short local sound (timers, reminders, alerts)? Happy to provide more context if useful.
I'm building a Pomodoro timer tool and need to play a short local sound (e.g. "focus session ended") from within the tool. I couldn't find an approved way to do this.
Placed .mp3 files in res/raw and used the standard Android approach:
val context = LocalContext.current
MediaPlayer.create(context, R.raw.finished_pomodoro)?.apply {
setOnCompletionListener { release() }
start()
}
This fails at build time due to the SDK's lint rules:
blocked import 'androidx.compose.ui.platform.LocalContext'
LocalContext.current is not allowed — use LightScreen APIs instead
What I found in the plugin source
Looking at LightSdkPlugin.kt, Context, getSystemService(), and similar APIs are intentionally blocked (makes sense for sandboxing). I couldn't find any alternative in LightScreen, LightViewModel, or LightServiceMethod for playing a short local sound.
The only audio-related method is SetRingtone, but that permanently changes the user's system ringtone — not suitable for a one-off notification sound.
Question
Is there a planned/approved API for tools to play a short local sound (timers, reminders, alerts)? Happy to provide more context if useful.