Release 0.1.6 with one quality setting and silent skips
All checks were successful
Validate and publish Kaleido / android (push) Successful in 2m19s

Playback mode and transcode quality become one quality list: Original
quality (direct stream of the source video, the default), then 4K,
1080p, 720p and 480p conversions, with earlier preferences migrated.
Left/Right taps during playback skip 10 seconds without showing the
controls; holding still opens the timeline, which now keeps focus
instead of losing it to Play. Player checks wait for playback to be
ready and inspect the screen while paused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-10-24 14:48:55 -07:00
parent 6a53196748
commit 74afc7f3d4
16 changed files with 113 additions and 43 deletions

View file

@ -63,7 +63,9 @@ class KaleidoViewModel(app: Application): AndroidViewModel(app) {
var downloadProgress by mutableFloatStateOf(0f); private set
/** A verified APK for [update], kept so a cancelled installer can be reopened without downloading again. */
var readyApk by mutableStateOf<File?>(null); private set
var playbackMode by mutableStateOf(preferences.getInt("playbackModeV2",1)); private set
var streamQuality by mutableStateOf(savedStreamQuality()); private set
/** Debug test intents force a delivery mode (0 file, 1 direct stream, 2 convert); never set in release. */
var debugMode by mutableStateOf<Int?>(null); private set
var watchedPercent by mutableStateOf(preferences.getInt("watchedPercent",80).coerceIn(50,100)); private set
var navigationSounds by mutableStateOf(preferences.getBoolean("navigationSounds",true)); private set
var episodeQueue by mutableStateOf(emptyList<Title>());private set
@ -71,7 +73,6 @@ class KaleidoViewModel(app: Application): AndroidViewModel(app) {
var transitioningEpisode by mutableStateOf(false);private set
private var episodeContextJob:Job?=null
private var episodeTransitionJob:Job?=null
var quality by mutableStateOf(preferences.getInt("quality",20000)); private set
private var loadJob: Job? = null
private var initializeJob:Job?=null
private var loadGeneration=0
@ -263,10 +264,12 @@ class KaleidoViewModel(app: Application): AndroidViewModel(app) {
}
}
fun stopPlayback(){playing=null;sectionCache.clear();detailsCache.clear();previews.clear();cancelAnticipation();launchLoad {homeHubs=loadHome();detail?.let {if(it.type in listOf("movie","episode"))detail=api.details(it.id)}}}
fun choosePlaybackMode(value: Int){playbackMode=value;preferences.edit().putInt("playbackModeV2",value).apply()}
// Earlier versions stored a mode (Original/Direct stream/Transcode) and a separate transcode quality.
private fun savedStreamQuality()=preferences.getString("streamQuality",null)?.let{name->StreamQuality.entries.firstOrNull{it.name==name}}
?: if(preferences.getInt("playbackModeV2",1)==2)(if(preferences.getInt("quality",20000)>20000)StreamQuality.UltraHD else StreamQuality.FullHD)else StreamQuality.Original
fun chooseStreamQuality(value: StreamQuality){streamQuality=value;preferences.edit().putString("streamQuality",value.name).apply()}
fun chooseWatchedPercent(value:Int){watchedPercent=value.coerceIn(50,100);preferences.edit().putInt("watchedPercent",watchedPercent).apply()}
fun chooseNavigationSounds(value:Boolean){navigationSounds=value;preferences.edit().putBoolean("navigationSounds",value).apply()}
fun chooseQuality(value: Int){quality=value;preferences.edit().putInt("quality",value).apply()}
fun checkUpdate(manual: Boolean=true){viewModelScope.launch {
if(downloading||!manual&&System.currentTimeMillis()-preferences.getLong("lastUpdateCheck",0)<6*3600_000L)return@launch
updateStatus="Checking for updates…"
@ -287,5 +290,5 @@ class KaleidoViewModel(app: Application): AndroidViewModel(app) {
fun clearDownload(){downloadedApk=null}
/** Back from the system installer without updating: the verified APK can be installed again. */
fun installerReturned(){if(readyApk!=null&&!downloading)updateStatus="Update downloaded. Select Install ${update?.version.orEmpty()} to finish."}
fun debugPlay(id: String,offset: Long,mode: Int){if(!BuildConfig.DEBUG)return;launchLoad {playing=null;delay(150);playbackMode=mode;playing=api.details(id).copy(offset=offset);startFromZero=false}}
fun debugPlay(id: String,offset: Long,mode: Int){if(!BuildConfig.DEBUG)return;launchLoad {playing=null;delay(150);debugMode=mode;playing=api.details(id).copy(offset=offset);startFromZero=false}}
}

View file

@ -54,7 +54,10 @@ class PlaybackController(private val vm: KaleidoViewModel,val item: Title) {
setHandleAudioBecomingNoisy(true)
}
val mediaSession=MediaSession.Builder(app,player).setId("kaleido-${UUID.randomUUID()}").build()
var mode by mutableIntStateOf(vm.playbackMode);private set
// Original quality direct-streams the source video (remuxed, never re-encoded) and falls back
// to conversion if the TV can't play it; a resolution always asks Plex to convert.
var mode by mutableIntStateOf(vm.debugMode ?: if(vm.streamQuality==StreamQuality.Original)1 else 2);private set
val qualityLabel get()=if(mode<2)StreamQuality.Original.label else "Converting · "+vm.streamQuality.conversion.label
var loading by mutableStateOf(true);private set
var error by mutableStateOf<String?>(null);private set
var position by mutableLongStateOf(if(vm.startFromZero)0 else item.offset);private set
@ -115,7 +118,7 @@ class PlaybackController(private val vm: KaleidoViewModel,val item: Title) {
MediaItem.SubtitleConfiguration.Builder(android.net.Uri.parse(api.url(s.key))).setId(s.id).setLabel(s.title).setLanguage(s.language).setMimeType(when(s.codec){"srt"->MimeTypes.APPLICATION_SUBRIP;"ass","ssa"->MimeTypes.TEXT_SSA;else->MimeTypes.TEXT_VTT}).setSelectionFlags(if(s.id==activeSubtitle)C.SELECTION_FLAG_DEFAULT else 0).build()
})
} else {
val p=api.transcodeParams(item,streamSession,mode,offset,vm.quality)
val p=api.transcodeParams(item,streamSession,mode,offset,vm.streamQuality.conversion)
val decision=api.container("/video/:/transcode/universal/decision",p)
if(decision.optInt("generalDecisionCode")>=2000)throw PlexException(decision.optString("generalDecisionText","Server cannot convert this media."))
builder.setUri(api.url("/video/:/transcode/universal/start.m3u8",p)).setMimeType(MimeTypes.APPLICATION_M3U8)
@ -128,10 +131,10 @@ class PlaybackController(private val vm: KaleidoViewModel,val item: Title) {
fun seekTo(target:Long){val clamped=target.coerceIn(0,duration);if(mode>0&&clamped<streamStart){val resume=player.playWhenReady;scope.launch{prepare(mode,clamped,resume)}}else{player.seekTo(clamped);position=clamped;report(if(isPlaying)"playing"else "paused")}}
fun toggle(){if(player.isPlaying)player.pause()else{if(ended)seekTo(0);player.play()}}
fun retry(){scope.launch{prepare(mode,position)}}
fun changeMode(value:Int){val resume=player.playWhenReady;vm.choosePlaybackMode(value);scope.launch{prepare(value,position,resume)}}
fun changeQuality(value:Int){val resume=player.playWhenReady;vm.chooseQuality(value);if(mode>0)scope.launch{prepare(mode,position,resume)}}
fun changeQuality(value:StreamQuality){val resume=player.playWhenReady;vm.chooseStreamQuality(value);scope.launch{prepare(if(value==StreamQuality.Original)1 else 2,position,resume)}}
fun changeSpeed(value:Float){playbackRate=value;player.setPlaybackSpeed(value)}
fun scrubBy(delta:Long){scrubPosition=((scrubPosition ?: position)+delta).coerceIn(0,duration);seekJob?.cancel();seekJob=scope.launch{delay(650);commitScrub()}}
/** Moves the pending seek target; repeated presses accumulate into one seek after [settle] ms. */
fun scrubBy(delta:Long,settle:Long=650){scrubPosition=((scrubPosition ?: position)+delta).coerceIn(0,duration);seekJob?.cancel();seekJob=scope.launch{delay(settle);commitScrub()}}
fun commitScrub(){val target=scrubPosition ?: return;scrubPosition=null;seekTo(target)}
fun pause(){player.pause();position=currentPosition();report("paused")}
fun select(type:Int,groupIndex:Int,trackIndex:Int) {
@ -157,4 +160,14 @@ class PlaybackController(private val vm: KaleidoViewModel,val item: Title) {
}
fun close(){if(closed)return;position=currentPosition();closed=true;scope.cancel();report("stopped",true);reports.close();mediaSession.release();player.release()}
}
/** The single playback quality preference: the original stream, then conversions from highest to lowest resolution. */
enum class StreamQuality(val label:String,val width:Int,val height:Int,val kbps:Int) {
Original("Original quality",0,0,0),
UltraHD("4K · 80 Mbps",3840,2160,80000),
FullHD("1080p · 20 Mbps",1920,1080,20000),
HD("720p · 8 Mbps",1280,720,8000),
SD("480p · 3 Mbps",720,480,3000);
/** Target used when Plex must convert; Original falls back to 1080p if direct streaming fails. */
val conversion get()=if(this==Original)FullHD else this
}
fun clockTime(ms:Long):String {val s=(ms.coerceAtLeast(0)/1000);return if(s>=3600)"%d:%02d:%02d".format(s/3600,s/60%60,s%60)else "%d:%02d".format(s/60,s%60)}

View file

@ -22,14 +22,12 @@ import androidx.compose.ui.unit.sp
import kotlinx.coroutines.delay
@Composable internal fun PlaybackOptions(vm:KaleidoViewModel,controller:PlaybackController,item:Title,menu:Int,open:(Int)->Unit,close:()->Unit) {
val modes=listOf("Original file","Direct stream","Transcode")
val speeds=listOf(.5f,.75f,1f,1.25f,1.5f,2f)
val dismiss={if(menu==3)close()else open(3)}
when(menu) {
3->TrackPanel("Playback options",listOf("Mode · ${modes[controller.mode]}","Audio language","Subtitles","Speed · ${controller.playbackRate}×","Transcode quality", "Chapters"),0,dismiss){index->open(when(index){0->4;1->1;2->2;3->5;4->6;else->7})}
4->TrackPanel("Playback mode",modes,controller.mode,dismiss){controller.changeMode(it);close()}
3->TrackPanel("Playback options",listOf("Quality · ${vm.streamQuality.label}","Audio language","Subtitles","Speed · ${controller.playbackRate}×","Chapters"),0,dismiss){index->open(when(index){0->4;1->1;2->2;3->5;else->7})}
4->TrackPanel("Playback quality",StreamQuality.entries.map{it.label},vm.streamQuality.ordinal,dismiss){controller.changeQuality(StreamQuality.entries[it]);close()}
5->TrackPanel("Playback speed",speeds.map{"${it}×"},speeds.indexOf(controller.playbackRate),dismiss){controller.changeSpeed(speeds[it]);close()}
6->TrackPanel("Transcode quality",listOf("1080p · 20 Mbps","4K · 80 Mbps"),if(vm.quality>20000)1 else 0,dismiss){controller.changeQuality(if(it==0)20000 else 80000);close()}
7->TrackPanel("Chapters",item.chapters.map{"${it.title} · ${clockTime(it.start)}"},item.chapters.indexOfLast{it.start<=controller.position},dismiss){controller.seekTo(item.chapters[it].start);close()}
}
}

View file

@ -57,6 +57,8 @@ import kotlinx.coroutines.delay
var trackMenu by remember{mutableIntStateOf(0)}
var postPlay by remember{mutableStateOf(false)}
var seekFocus by remember{mutableStateOf(false)}
// Set once the timeline takes focus for this reveal, so Play's initial focus can't take it back.
var timelineReveal by remember{mutableStateOf(false)}
var restoreMenuFocus by remember{mutableIntStateOf(0)}
val rootFocus=remember{FocusRequester()}
val timelineFocus=remember{FocusRequester()}
@ -77,8 +79,8 @@ import kotlinx.coroutines.delay
LaunchedEffect(controls,interaction,controller.isPlaying,trackMenu) {
if(controls&&controller.isPlaying&&trackMenu==0){delay(5000);controls=false}
}
LaunchedEffect(controls) {if(!controls){delay(210);runCatching{rootFocus.requestFocus()}}}
LaunchedEffect(seekFocus,controls) {if(seekFocus&&controls){delay(220);runCatching{timelineFocus.requestFocus()};seekFocus=false}}
LaunchedEffect(controls) {if(!controls){timelineReveal=false;delay(210);runCatching{rootFocus.requestFocus()}}}
LaunchedEffect(seekFocus,controls) {if(seekFocus&&controls){delay(220);runCatching{timelineFocus.requestFocus()};timelineReveal=true;seekFocus=false}}
LaunchedEffect(restoreMenuFocus,trackMenu) {if(restoreMenuFocus!=0&&trackMenu==0){delay(16);runCatching{(when(restoreMenuFocus){1->audioFocus;2->subtitleFocus;else->optionsFocus}).requestFocus()};restoreMenuFocus=0}}
fun goBack(){if(postPlay)postPlay=false else if(trackMenu!=0)closeTracks()else if(controls)controls=false else vm.stopPlayback()}
BackHandler(onBack=::goBack)
@ -94,7 +96,16 @@ import kotlinx.coroutines.delay
android.view.KeyEvent.KEYCODE_MEDIA_FAST_FORWARD->{controller.seekTo(controller.position+30000);controls=true;seekFocus=true;true}
android.view.KeyEvent.KEYCODE_MEDIA_REWIND->{controller.seekTo(controller.position-10000);controls=true;seekFocus=true;true}
android.view.KeyEvent.KEYCODE_DPAD_CENTER,android.view.KeyEvent.KEYCODE_ENTER->{if(!visible){controls=true;true}else false}
android.view.KeyEvent.KEYCODE_DPAD_LEFT,android.view.KeyEvent.KEYCODE_DPAD_RIGHT->{if(!visible){controller.scrubBy(if(event.nativeKeyEvent.keyCode==android.view.KeyEvent.KEYCODE_DPAD_LEFT)-10000 else 10000);controls=true;seekFocus=true;true}else false}
android.view.KeyEvent.KEYCODE_DPAD_LEFT,android.view.KeyEvent.KEYCODE_DPAD_RIGHT->{
val delta=if(event.nativeKeyEvent.keyCode==android.view.KeyEvent.KEYCODE_DPAD_LEFT)-10000L else 10000L
when {
// A tap skips without revealing anything; quick taps add up into one seek.
!visible&&event.nativeKeyEvent.repeatCount==0->{controller.scrubBy(delta,settle=350);true}
// Holding reveals the timeline and keeps scrubbing until it takes focus.
!visible||seekFocus->{controller.scrubBy(delta);controls=true;seekFocus=true;true}
else->false
}
}
android.view.KeyEvent.KEYCODE_DPAD_UP,android.view.KeyEvent.KEYCODE_DPAD_DOWN->{if(!visible){controls=true;seekFocus=event.nativeKeyEvent.keyCode==android.view.KeyEvent.KEYCODE_DPAD_UP;true}else false}
else->false
}
@ -115,7 +126,7 @@ import kotlinx.coroutines.delay
Row(Modifier.fillMaxWidth().padding(bottom=7.dp),verticalAlignment=Alignment.Bottom) {
Text(item.displayTitle,color=Accent,fontSize=18.sp,lineHeight=23.sp,fontWeight=FontWeight.SemiBold,maxLines=1,overflow=TextOverflow.Ellipsis,modifier=Modifier.weight(1f))
Spacer(Modifier.width(18.dp))
Text(if(item.type=="episode")"S${item.parentIndex} · E${item.index} ${item.title}"else listOf("Original","Direct stream","Transcoding")[controller.mode],color=Color.White.copy(alpha=.62f),fontSize=10.sp,lineHeight=15.sp,maxLines=1,overflow=TextOverflow.Ellipsis,modifier=Modifier.widthIn(max=350.dp))
Text(if(item.type=="episode")"S${item.parentIndex} · E${item.index} ${item.title}"else controller.qualityLabel,color=Color.White.copy(alpha=.62f),fontSize=10.sp,lineHeight=15.sp,maxLines=1,overflow=TextOverflow.Ellipsis,modifier=Modifier.widthIn(max=350.dp))
}
SeekTimeline(controller,item,Modifier.fillMaxWidth().focusRequester(timelineFocus).focusProperties{down=playFocus},::interacted)
Box(Modifier.fillMaxWidth().height(40.dp)) {
@ -125,7 +136,7 @@ import kotlinx.coroutines.delay
}
Row(Modifier.align(Alignment.Center),verticalAlignment=Alignment.CenterVertically,horizontalArrangement=Arrangement.spacedBy(16.dp)) {
IconControl(Icons.Outlined.Replay10,"Back 10 seconds",size=32.dp,iconSize=22.dp,modifier=Modifier.focusProperties{up=timelineFocus},onFocused=::interacted){controller.seekTo(controller.position-10000);interacted()}
IconControl(if(controller.isPlaying)Icons.Filled.Pause else Icons.Filled.PlayArrow,if(controller.isPlaying)"Pause"else "Play",size=38.dp,iconSize=28.dp,requester=playFocus,initialFocus=controls&&!seekFocus,modifier=Modifier.focusProperties{up=timelineFocus},onFocused=::interacted){controller.toggle();controls=true;interacted()}
IconControl(if(controller.isPlaying)Icons.Filled.Pause else Icons.Filled.PlayArrow,if(controller.isPlaying)"Pause"else "Play",size=38.dp,iconSize=28.dp,requester=playFocus,initialFocus=controls&&!seekFocus&&!timelineReveal,modifier=Modifier.focusProperties{up=timelineFocus},onFocused=::interacted){controller.toggle();controls=true;interacted()}
IconControl(Icons.Outlined.Forward30,"Forward 30 seconds",size=32.dp,iconSize=22.dp,modifier=Modifier.focusProperties{up=timelineFocus},onFocused=::interacted){controller.seekTo(controller.position+30000);interacted()}
}
Row(Modifier.align(Alignment.CenterEnd),verticalAlignment=Alignment.CenterVertically,horizontalArrangement=Arrangement.spacedBy(10.dp)) {

View file

@ -96,12 +96,12 @@ class PlexApi(val clientId: String) {
request(url("/library/parts/${part.id}",buildMap { put("allParts","1");audio?.let {put("audioStreamID",it)};subtitle?.let {put("subtitleStreamID",it)} }),method="PUT")
}
fun image(path: String, width: Int = 600, height: Int = 900): String? = if(path.isBlank() || session==null) null else url("/photo/:/transcode",mapOf("url" to path,"width" to width.toString(),"height" to height.toString(),"minSize" to "1","upscale" to "0"))
fun transcodeParams(item: Title, sessionId: String, mode: Int, offset: Long, quality: Int): Map<String,String> = buildMap {
fun transcodeParams(item: Title, sessionId: String, mode: Int, offset: Long, quality: StreamQuality): Map<String,String> = buildMap {
put("path",item.key);put("mediaIndex","0");put("partIndex","0");put("protocol","hls");put("session",sessionId);put("offset",(offset/1000.0).toString())
put("directPlay","0");put("directStream",if(mode==1) "1" else "0");put("directStreamAudio","1");put("directStreamVideo",if(mode==1) "1" else "0")
val original=item.media.firstOrNull()
put("maxVideoBitrate",if(mode==1)maxOf(original?.bitrate ?: 0,100000).toString()else quality.toString())
put("videoResolution",if(mode==1&&original!=null&&original.width>0)"${original.width}x${original.height}"else if(quality>20000)"3840x2160"else "1920x1080")
put("maxVideoBitrate",if(mode==1)maxOf(original?.bitrate ?: 0,100000).toString()else quality.kbps.toString())
put("videoResolution",if(mode==1&&original!=null&&original.width>0)"${original.width}x${original.height}"else "${quality.width}x${quality.height}")
put("videoQuality","100");put("audioBoost","100");put("subtitleSize","100");put("location","lan");put("hasMDE","1");put("fastSeek","1")
put("X-Plex-Client-Identifier",clientId);put("X-Plex-Product","Kaleido");put("X-Plex-Platform","Android");put("X-Plex-Device","Android TV")
// Augment the existing target. Separate targets make Plex prefer H.264 conversion even for HEVC it could copy.

View file

@ -141,7 +141,7 @@ val sortLabels=listOf("titleSort:asc" to "Title: A–Z","titleSort:desc" to "Tit
Column(Modifier.fillMaxSize().padding(60.dp),verticalArrangement=Arrangement.spacedBy(18.dp)){Brand();Spacer(Modifier.height(20.dp));Text("Choose your Plex server",color=Color.White,fontSize=32.sp,fontWeight=FontWeight.Bold);vm.servers.forEachIndexed{i,s->TvButton(s.name,initialFocus=i==0,onClick={vm.chooseServer(s)})}}
}
@Composable fun SettingsScreen(vm: KaleidoViewModel,install: (File)->Unit) {
var confirmSignOut by remember{mutableStateOf(false)};var modeDialog by remember{mutableStateOf(false)};var qualityDialog by remember{mutableStateOf(false)};var watchedDialog by remember{mutableStateOf(false)}
var confirmSignOut by remember{mutableStateOf(false)};var qualityDialog by remember{mutableStateOf(false)};var watchedDialog by remember{mutableStateOf(false)}
LaunchedEffect(vm.downloadedApk){vm.downloadedApk?.let(install)}
// Returning from the package installer can leave nothing focused; the next D-pad press
// would then search from the top bar and open Home. Put focus back on the update actions.
@ -160,7 +160,10 @@ val sortLabels=listOf("titleSort:asc" to "Title: A–Z","titleSort:desc" to "Tit
LazyColumn(Modifier.onFocusChanged{settingsFocused=it.hasFocus},contentPadding=PaddingValues(horizontal=Cinema.gutter,vertical=17.dp),verticalArrangement=Arrangement.spacedBy(16.dp)) {
item {Text("Settings",color=Accent,fontSize=29.sp,lineHeight=34.sp,fontWeight=FontWeight.SemiBold,letterSpacing=(-.8).sp)}
item{SettingsPanel("Plex connection") {Text(vm.session?.serverName.orEmpty(),color=Color.White,fontSize=20.sp,fontWeight=FontWeight.Bold);Text(if(vm.accountToken.isBlank())"Server connection · Link your Plex account to discover your servers"else "Plex account linked · Session encrypted with Android Keystore",color=Muted,fontSize=12.sp);Spacer(Modifier.height(14.dp));Row(horizontalArrangement=Arrangement.spacedBy(10.dp)){TvButton("Sign in with Plex",initialFocus=true,onClick={vm.beginAccountLink()});if(vm.accountToken.isNotBlank())TvButton("Choose server",onClick={vm.switchServer()});TvButton("Sign out",onClick={confirmSignOut=true})}}}
item{SettingsPanel("Playback") {Row(horizontalArrangement=Arrangement.spacedBy(12.dp)){TvButton("Mode: "+listOf("Original","Direct stream","Transcode")[vm.playbackMode],onClick={modeDialog=true});TvButton("Transcode quality: "+if(vm.quality>20000)"4K · 80 Mbps"else "1080p · 20 Mbps",onClick={qualityDialog=true})};Text("Direct stream is the default. Playback mode, audio, subtitles, speed, and quality can also be changed in the player.",color=Muted,fontSize=12.sp,modifier=Modifier.padding(top=12.dp))}}
item{SettingsPanel("Playback") {
TvButton("Quality: "+vm.streamQuality.label,onClick={qualityDialog=true})
Text("Original quality plays the source video without conversion and is the default. A resolution asks Plex to convert, which helps on slower connections. Quality, audio, subtitles and speed can also be changed in the player.",color=Muted,fontSize=12.sp,lineHeight=18.sp,modifier=Modifier.padding(top=10.dp))
}}
item{SettingsPanel("Watched status") {
TvButton("Mark watched at ${vm.watchedPercent}%",onClick={watchedDialog=true})
Text("A resumed title gets its checkmark at this playback percentage. Completed titles keep their Plex watched status.",color=Muted,fontSize=12.sp,lineHeight=18.sp,modifier=Modifier.padding(top=10.dp))
@ -197,8 +200,7 @@ val sortLabels=listOf("titleSort:asc" to "Title: A–Z","titleSort:desc" to "Tit
val thresholds=listOf(50,60,70,75,80,85,90,95,100)
ChoiceDialog("Mark watched after",thresholds.map{"$it%"},thresholds.indexOf(vm.watchedPercent),{watchedDialog=false}){vm.chooseWatchedPercent(thresholds[it]);watchedDialog=false}
}
if(modeDialog)ChoiceDialog("Playback mode",listOf("Automatic · Original quality","Direct stream · Remux when possible","Transcode · Compatibility mode"),vm.playbackMode,{modeDialog=false}){vm.choosePlaybackMode(it);modeDialog=false}
if(qualityDialog)ChoiceDialog("Transcode quality",listOf("1080p · 20 Mbps","4K · 80 Mbps"),if(vm.quality>20000)1 else 0,{qualityDialog=false}){vm.chooseQuality(if(it==0)20000 else 80000);qualityDialog=false}
if(qualityDialog)ChoiceDialog("Playback quality",StreamQuality.entries.map{it.label},vm.streamQuality.ordinal,{qualityDialog=false}){vm.chooseStreamQuality(StreamQuality.entries[it]);qualityDialog=false}
}
/** Scroll only as far as needed to reveal the focused control, keeping [margin] px clear of the edges. */
private class MinimalScroll(private val margin:Float):BringIntoViewSpec {