Release Kaleido 0.7.0 with previous episode, timed auto-skip and cross-device refresh
All checks were successful
Validate and publish Kaleido / android (push) Successful in 2m36s
All checks were successful
Validate and publish Kaleido / android (push) Successful in 2m36s
- Player: Previous episode (also through a shuffle) and a redesigned bar, with times at the timeline ends and a centred transport cluster. - Settings > Playback: skip intros/credits automatically after 3-15 s or show the button only. A pending skip reads "Skipping intro" with a filling background; any remote press cancels it, OK skips now. - Continue Watching changes from other devices are picked up by the 15-second foreground poll (5%-step fingerprint) and within a second of returning to Kaleido. - Keep Continue Watching focus when a refresh replaces the restored card. - AGENTS.md: tiered testing so small changes don't run every device suite. - New scripts/verify_player_features.py device checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
bdc37db05d
commit
8533347b51
15 changed files with 373 additions and 54 deletions
17
AGENTS.md
17
AGENTS.md
|
|
@ -35,7 +35,17 @@ Install `app/build/outputs/apk/release/app-release.apk` instead for performance/
|
|||
|
||||
## Testing suite
|
||||
|
||||
Use `& $KaleidoPython` before the Python commands below. Run only checks relevant to the change; **never run competing device/UI tests in parallel**. Live playback tests change real Plex progress and can change playback preferences. Restore a useful final state, normally the release build on Home. After a functional debug batch, restore the signed release and its ART profile before returning the device to normal use; never judge performance from an unoptimized debug build.
|
||||
Use `& $KaleidoPython` before the Python commands below. **Never run competing device/UI tests in parallel.**
|
||||
|
||||
**Test in tiers; don't run every suite for every change.** Each device script cold-starts Kaleido, waits for playback and real timers, and dumps the UI per check, so a full pass takes 30+ minutes.
|
||||
|
||||
1. **Every change:** `.\Build.ps1 -Test` (compile, JVM unit tests, lint; about a minute). Put pure logic (ordering, parsing, fingerprints, countdown rules) in unit-testable functions with JVM tests instead of proving it on the TV.
|
||||
2. **UI or device behaviour changed:** run only the one or two scripts for the area touched (map below), plus a screenshot of the changed screen. One script is usually 1–4 minutes.
|
||||
3. **Before a release, or after broad navigation/playback/startup changes:** the full set: `verify_ui.py browse` and `player`, `repro_runtime.py controls episode postplay credits sections`, `verify_player_features.py`, `verify_settings.py`, then the release build with `repro_runtime.py browse` for frame pacing.
|
||||
|
||||
Area → checks: Home/Movies/TV rows, focus, details Back → `verify_ui.py browse` · player bar, menus, scrubbing → `verify_ui.py player` · previous/next episode, auto-skip, server picker, cross-device refresh → `verify_player_features.py <phase>` · post-play/autoplay/credits → `repro_runtime.py postplay` or `credits` · Settings rows/dialogs → `verify_settings.py` · details/cast → `verify_details_layout.py` / `verify_movie_details.py` · library A–Z/search → `verify_library_jump.py` · startup/tab loading → `repro_runtime.py sections` · scrolling smoothness → release + `repro_runtime.py browse`. Skip suites for untouched areas and say which were skipped.
|
||||
|
||||
Run only checks relevant to the change. Live playback tests change real Plex progress and can change playback preferences. Restore a useful final state, normally the release build on Home. After a functional debug batch, restore the signed release and its ART profile before returning the device to normal use; never judge performance from an unoptimized debug build.
|
||||
|
||||
| Command | Purpose / required build |
|
||||
| --- | --- |
|
||||
|
|
@ -58,6 +68,7 @@ Use `& $KaleidoPython` before the Python commands below. Run only checks relevan
|
|||
| `scripts/verify_movie_details.py` | Movie safe header, related movies and Back focus restoration; debug or release |
|
||||
| `scripts/verify_settings.py` | Category navigation, preference-dialog cancellation and live update check; expects Original quality / 80% test preferences |
|
||||
| `scripts/verify_library_jump.py` | Scoped Movie/TV categories, A–Z jumps beyond the first page, details/Back focus and exact Silo search |
|
||||
| `scripts/verify_player_features.py [phase…]` | Phases `previous_episode`, `auto_skip` (Skipping intro fill, Down/Back cancel), `server_picker` (Back/Cancel), `refresh` (resume and open-app Continue Watching sync; moves and restores Silo 1×1 progress); **debug**; restores skip preferences |
|
||||
| `scripts/verify_audio_preferences.py` | Theme persistence and actual playback audio; **debug**; restores prior audio preferences |
|
||||
|
||||
Live Android integration tests (currently six) cover secure persistence, library APIs, episodes, PIN, preview JPEGs/new seasons and supported HEVC remux negotiation:
|
||||
|
|
@ -75,7 +86,7 @@ These require the private test session. Playback test intents (`testTitleId`, `t
|
|||
## Important regression traps
|
||||
|
||||
- Keep initialization independent of cancellable tab requests and apply section results atomically. Cancelling initialization during a startup tab switch previously left Movies/TV blank.
|
||||
- Foreground library sync polls revisions every 15 seconds with a 60-second refresh fallback; pause it for playback/background and stage updates before applying them. Preserve stable hub/card focus IDs and current library filters/range. `LibrarySyncIntegrationTest` tests the real timer against an in-memory HTTP fixture without changing Plex or the encrypted session.
|
||||
- Foreground library sync polls revisions every 15 seconds with a 60-second refresh fallback, and checks within a second of returning to the foreground. The revision includes a Continue Watching fingerprint (membership, order, watch count, progress in 5% steps) so watching on another device shows up without refreshing Home on every poll; pause it for playback/background and stage updates before applying them. Preserve stable hub/card focus IDs and current library filters/range. `LibrarySyncIntegrationTest` tests the real timer against an in-memory HTTP fixture without changing Plex or the encrypted session.
|
||||
- Home, Movies and TV stay composed once shown; hidden ones are unplaced, have no semantics and must never request focus (gate effects on `active`). Catalog and rails prefetch through `FramePrefetch`/`CacheWindows`, which must remain a `CacheWindowLogic` or rows stop being kept around. With any accessibility service enabled, Compose walks every composed node after each layout change: keep offscreen rows and cards without semantics (`semanticsOnScreen`). See `docs/runtime-verification.md` (frame pacing).
|
||||
- Preserve explicit D-pad row/column targets and fixed card geometry. Avoid expensive beyond-bounds focus searches, per-focus catalog recomposition and full-screen gradient overdraw. Contrast is baked into cached backdrop bitmaps off the main thread.
|
||||
- Give every Media3 session a unique ID: next-episode creation can overlap the old controller's disposal. Plex HLS position is absolute; **do not add the requested resume offset again**.
|
||||
|
|
@ -83,7 +94,7 @@ These require the private test session. Playback test intents (`testTitleId`, `t
|
|||
- A text field keeps the D-pad: route Down/IME actions out of Search's field explicitly. Give every `focusRestorer()` a fallback, or it overrides explicit focus targets. Per-card modifiers on browse rows must be `Modifier.Node`s, not `composed {}`, and must not animate per card.
|
||||
- Playback has one quality preference (`StreamQuality`): **Original quality** (the default) tries the original file, then Plex HLS, then a 1080p conversion if needed; 4K/1080p/720p/480p ask Plex to convert. A nonempty audio-only track list for a declared video must trigger fallback. Earlier preferences migrate on first read. Debug `testMode` still forces a delivery mode. Augment Plex's existing HEVC target; competing targets previously forced unnecessary conversion. A server copy decision does not prove rendering. Preserve the selected Plex tracks and check actual delivered formats.
|
||||
- **ADB screenshots can omit HEVC video on this onn while the actual TV displays it. The user confirmed this.** Do not force transcoding based solely on a blank capture. `scripts/check_video.py` has a pixel assertion that can falsely fail for this reason; use playback logs/rendered-frame evidence and physical TV confirmation as appropriate. Never infer universal HDR/codec support from one test.
|
||||
- Preview thumbnails and intro/credit markers depend on server-generated data. Do not fabricate them.
|
||||
- Preview thumbnails and intro/credit markers depend on server-generated data. Do not fabricate them. Automatic skips (Settings › Playback, 0 = button only) show "Skipping intro/credits" with a filling background rather than a number, count down only while playing, and are cancelled by any remote press (OK on the button skips now; Back only cancels).
|
||||
- Theme tracks come from Plex metadata and inherit from the show for seasons/episodes. Stop music on video playback/background. Volume boost was removed because it degraded audio; keep passthrough and the normal audio path.
|
||||
- A server-stopped session (Plex dashboard Stop) arrives as `terminationCode`/`terminationText` on the timeline response. Leave the player with the reason and never fall back or reconnect afterwards; timelines keep reporting `buffering` while a stream stalls so the stop is still noticed.
|
||||
|
||||
|
|
|
|||
12
CHANGELOG.md
12
CHANGELOG.md
|
|
@ -1,5 +1,17 @@
|
|||
# Kaleido releases
|
||||
|
||||
## 0.7.0
|
||||
|
||||
- Add a Previous episode button to the player, and redesign its controls: elapsed and remaining time at the ends of the timeline, previous episode, back 10 seconds, play, forward 30 seconds and next episode grouped in the centre, and the finish time beside Exit. Previous episode also steps back through a shuffle.
|
||||
- Skip intros and credits automatically after a delay you choose in Settings › Playback (3, 5, 10 or 15 seconds, or show the button only). A pending skip reads "Skipping intro" with a filling background; pressing any button on the remote cancels it, and OK skips straight away. The earlier "Automatically" setting becomes a 5-second skip.
|
||||
- Show what you watch on other devices promptly: Kaleido checks Continue Watching every 15 seconds while open and as soon as you return to it.
|
||||
- Keep playback paused when you leave Kaleido while a stream is still starting, and only count down to the next episode while Kaleido is on screen.
|
||||
- Keep the resume point when leaving a title before its stream has started, and keep progress reports on the server the title came from.
|
||||
- Close Settings › Choose server with Back or the new Cancel button, and enter Home's rows from the Home tab when there is no featured title.
|
||||
- Cancel slow network requests when they are no longer needed, and connect to the best server address as soon as it answers.
|
||||
- Update a title's format badges when you pick another version, keep New Seasons when one show can't be loaded, and keep focus on Continue Watching when a card is replaced while a title page is open.
|
||||
- Remove Volume boost, which degraded audio, and leave the player with the server's reason when a stream is stopped from the Plex dashboard.
|
||||
|
||||
## 0.6.2
|
||||
|
||||
- New startup animation, the same as Kaleido Desktop's: a kaleidoscope of shards turns and gathers into the Kaleido mark, then the view flies through its centre into Home.
|
||||
|
|
|
|||
|
|
@ -184,6 +184,8 @@ private suspend fun LazyListState.animateBrowseTo(index:Int) {
|
|||
val scrolling=launch{list.animateBrowseTo(0)}
|
||||
focusHero();scrolling.join()
|
||||
}
|
||||
/** Whether focus is inside this screen; a card key in [KaleidoViewModel.focusId] alone doesn't mean it is. */
|
||||
val screenFocus=remember{booleanArrayOf(false)}
|
||||
LaunchedEffect(hubs) {
|
||||
val old=previousHubs
|
||||
if(old==hubs)return@LaunchedEffect
|
||||
|
|
@ -208,6 +210,19 @@ private suspend fun LazyListState.animateBrowseTo(index:Int) {
|
|||
previousHubs=hubs
|
||||
// A hidden screen moves no focus; it finds its card again when shown.
|
||||
if(!active())return@LaunchedEffect
|
||||
if(oldHub==null) {
|
||||
// The card being restored (e.g. after details) was already gone from the previous rows,
|
||||
// and this refresh cancelled that restoration. Finish it here instead of leaving focus
|
||||
// on the top bar: the card itself if it is back, else the first card of its row.
|
||||
val key=focus
|
||||
val row=hubs.firstOrNull{key.startsWith("${it.id}:")&&it.items.isNotEmpty()}
|
||||
if(row!=null&&!screenFocus[0]) {
|
||||
val item=row.items.firstOrNull{"${row.id}:${it.id}"==key} ?: row.items.first()
|
||||
columns[row.id]=item.id;pendingColumns[row.id]=item.id
|
||||
navigationJob[0]=scope.launch{withFrameNanos{};moveToRow(row.id,item.id)}
|
||||
}
|
||||
return@LaunchedEffect
|
||||
}
|
||||
|
||||
if(oldHub!=null&&oldTitle!=null) {
|
||||
val sameHub=hubs.firstOrNull{it.id==oldHub.id}
|
||||
|
|
@ -283,7 +298,6 @@ private suspend fun LazyListState.animateBrowseTo(index:Int) {
|
|||
}
|
||||
// Hidden, the screen keeps its state but gives up focus: an unplaced card must not take key
|
||||
// events. Shown again, it focuses what a freshly composed screen would.
|
||||
val screenFocus=remember{booleanArrayOf(false)}
|
||||
val focusManager=LocalFocusManager.current
|
||||
suspend fun reveal() {
|
||||
withFrameNanos{}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,10 @@ private fun categoryArtworkHint(section:Section,genre:String):String?=when {
|
|||
else->null
|
||||
}
|
||||
private const val SyncQuietMillis=2000L
|
||||
/** The countdown an earlier "Automatically" skip setting becomes. */
|
||||
internal const val AutoSkipDefaultSeconds=5
|
||||
/** Returning to Kaleido checks the server almost at once, so watching elsewhere shows up promptly. */
|
||||
private const val ResumeSyncDelayMillis=750L
|
||||
class KaleidoViewModel(app: Application): AndroidViewModel(app) {
|
||||
val application = app as KaleidoApplication
|
||||
val api = application.api
|
||||
|
|
@ -121,8 +125,9 @@ class KaleidoViewModel(app: Application): AndroidViewModel(app) {
|
|||
var remoteQuality by mutableStateOf(preferences.getString("remoteQuality",null)?.let{n->StreamQuality.entries.firstOrNull{it.name==n}} ?: StreamQuality.FullHD); private set
|
||||
/** Seconds before the next episode starts; 0 turns autoplay off. */
|
||||
var autoplaySeconds by mutableIntStateOf(preferences.getInt("autoplaySeconds",5)); private set
|
||||
var autoSkipIntro by mutableStateOf(preferences.getBoolean("autoSkipIntro",false)); private set
|
||||
var autoSkipCredits by mutableStateOf(preferences.getBoolean("autoSkipCredits",false)); private set
|
||||
/** Seconds the Skip intro/credits button counts down before skipping by itself; 0 only shows the button. */
|
||||
var autoSkipIntroSeconds by mutableIntStateOf(autoSkipSeconds("autoSkipIntro")); private set
|
||||
var autoSkipCreditsSeconds by mutableIntStateOf(autoSkipSeconds("autoSkipCredits")); private set
|
||||
var subtitleSize by mutableStateOf(preferences.getString("subtitleSize",null)?.let{n->SubtitleSize.entries.firstOrNull{it.name==n}} ?: SubtitleSize.Normal); private set
|
||||
var subtitleStyle by mutableStateOf(preferences.getString("subtitleStyle",null)?.let{n->SubtitleStyle.entries.firstOrNull{it.name==n}} ?: SubtitleStyle.Box); private set
|
||||
/** Debug test intents force a delivery mode (0 file, 1 direct stream, 2 convert); never set in release. */
|
||||
|
|
@ -237,20 +242,25 @@ class KaleidoViewModel(app: Application): AndroidViewModel(app) {
|
|||
librarySyncJob?.cancel();librarySyncJob=null
|
||||
if(!value)return
|
||||
librarySyncJob=viewModelScope.launch {
|
||||
var observedSession=session
|
||||
var sync=newLibrarySync()
|
||||
var interval=LibrarySync.POLL_MS
|
||||
// Kept across background spells: returning compares against what was last applied,
|
||||
// so Continue Watching changes made on another device show up within a second.
|
||||
var interval=ResumeSyncDelayMillis
|
||||
var backoff=LibrarySync.POLL_MS
|
||||
while(isActive) {
|
||||
delay(interval)
|
||||
if(session!=observedSession){observedSession=session;sync=newLibrarySync()}
|
||||
delay(interval);interval=backoff
|
||||
val sync=librarySync?.takeIf{librarySyncSession==session} ?: newLibrarySync().also{librarySync=it;librarySyncSession=session}
|
||||
if(session==null||playing!=null||busy||markingId!=null||initializeJob?.isActive==true)continue
|
||||
try{sync.check();interval=LibrarySync.POLL_MS}
|
||||
try{sync.check();backoff=LibrarySync.POLL_MS}
|
||||
catch(e:CancellationException){throw e}
|
||||
catch(_:Exception){interval=(interval*2).coerceAtMost(LibrarySync.FALLBACK_MS)}
|
||||
catch(_:Exception){backoff=(backoff*2).coerceAtMost(LibrarySync.FALLBACK_MS)}
|
||||
interval=backoff
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun newLibrarySync()=LibrarySync(api::libraryRevision,::syncLibrary,android.os.SystemClock::elapsedRealtime)
|
||||
private var librarySyncSession:Session?=null
|
||||
private var librarySync:LibrarySync?=null
|
||||
/** Library contents plus Continue Watching progress, which changes when anything is watched elsewhere. */
|
||||
private fun newLibrarySync()=LibrarySync({api.libraryRevision()+"#"+api.continueWatchingRevision()},::syncLibrary,android.os.SystemClock::elapsedRealtime)
|
||||
private suspend fun syncLibrary():Boolean {
|
||||
val expectedSession=session ?: return false
|
||||
val expectedPage=page;val generation=loadGeneration
|
||||
|
|
@ -282,6 +292,7 @@ class KaleidoViewModel(app: Application): AndroidViewModel(app) {
|
|||
section!=expectedSection||sort!=expectedSort||genre!=expectedGenre||unwatched!=expectedUnwatched||categories!=expectedCategories||allTitles!=expectedAllTitles||
|
||||
playing!=null||busy||markingId!=null)return false
|
||||
sections=freshSections;homeHubs=freshHome.hubs;homeFeatures=freshHome.features
|
||||
android.util.Log.i("KaleidoSync","APPLIED continue=${freshHome.hubs.firstOrNull{it.id=="continue"}?.items?.size ?: 0}")
|
||||
sectionCache.clear();characterOffsetCache.clear();detailsCache.clear();previews.clear()
|
||||
sectionStale=freshSection==null
|
||||
if(freshSection!=null){section=active;discoverHubs=freshSection.hubs;genres=freshSection.genres;library=freshSection.library.items;total=freshSection.library.total}
|
||||
|
|
@ -679,11 +690,38 @@ class KaleidoViewModel(app: Application): AndroidViewModel(app) {
|
|||
}
|
||||
}
|
||||
}
|
||||
/** The episode before [item]: the previous one in the show, or the previous shuffle pick. */
|
||||
fun precedingEpisode(item:Title):Title? {
|
||||
val shuffle=shuffleEpisodes
|
||||
if(shuffle!=null)return shuffle.preceding(item.id)
|
||||
val i=episodeQueue.indexOfFirst{it.id==item.id};return if(i>0)episodeQueue[i-1]else null
|
||||
}
|
||||
/** False only once the episode list has loaded and [item] is the show's first episode (or the shuffle's first pick). */
|
||||
fun mayHavePrecedingEpisode(item:Title):Boolean {
|
||||
val shuffle=shuffleEpisodes
|
||||
if(shuffle!=null)return shuffle.preceding(item.id)!=null
|
||||
val i=episodeQueue.indexOfFirst{it.id==item.id};return i!=0
|
||||
}
|
||||
fun followingEpisode(item:Title):Title? {
|
||||
val shuffle=shuffleEpisodes
|
||||
if(shuffle!=null)return shuffle.following(item.id)
|
||||
val i=episodeQueue.indexOfFirst{it.id==item.id};return if(i>=0)episodeQueue.getOrNull(i+1)else null
|
||||
}
|
||||
fun previousEpisode(item: Title) {
|
||||
if(episodeTransitionJob?.isActive==true)return
|
||||
episodeTransitionJob=viewModelScope.launch {
|
||||
transitioningEpisode=true
|
||||
try {
|
||||
val shuffle=shuffleEpisodes
|
||||
val previous=if(shuffle!=null)shuffle.preceding(item.id) else {
|
||||
val episodes=if(episodeQueue.any{it.id==item.id})episodeQueue else api.allEpisodes(item.grandparentId).sortedWith(compareBy<Title>{it.parentIndex}.thenBy{it.index})
|
||||
val i=episodes.indexOfFirst{it.id==item.id};if(i>0)episodes[i-1]else null
|
||||
} ?: return@launch
|
||||
val metadata=api.details(previous.id)
|
||||
if(playing?.id==item.id){if(shuffle!=null)shuffle.retreat(item.id,previous.id);startFromZero=true;playbackInstance++;playing=metadata}
|
||||
}catch(e:CancellationException){throw e}catch(e:Exception){fail(e.message ?: "The previous episode could not be loaded."){previousEpisode(item)}}finally{transitioningEpisode=false}
|
||||
}
|
||||
}
|
||||
fun nextEpisode(item: Title) {
|
||||
if(episodeTransitionJob?.isActive==true)return
|
||||
episodeTransitionJob=viewModelScope.launch {
|
||||
|
|
@ -719,6 +757,8 @@ class KaleidoViewModel(app: Application): AndroidViewModel(app) {
|
|||
}
|
||||
}
|
||||
}
|
||||
// Earlier versions stored an on/off switch that skipped at once; on becomes a short, cancellable countdown.
|
||||
private fun autoSkipSeconds(name:String)=preferences.getInt("${name}Seconds",if(preferences.getBoolean(name,false))AutoSkipDefaultSeconds else 0).coerceIn(0,60)
|
||||
// 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
|
||||
|
|
@ -727,8 +767,8 @@ class KaleidoViewModel(app: Application): AndroidViewModel(app) {
|
|||
/** The player's quality menu changes the preference for the connection in use. */
|
||||
fun chooseActiveQuality(value: StreamQuality)=if(localConnection)chooseStreamQuality(value)else chooseRemoteQuality(value)
|
||||
fun chooseAutoplaySeconds(value:Int){autoplaySeconds=value.coerceAtLeast(0);preferences.edit().putInt("autoplaySeconds",autoplaySeconds).apply()}
|
||||
fun chooseAutoSkipIntro(value:Boolean){autoSkipIntro=value;preferences.edit().putBoolean("autoSkipIntro",value).apply()}
|
||||
fun chooseAutoSkipCredits(value:Boolean){autoSkipCredits=value;preferences.edit().putBoolean("autoSkipCredits",value).apply()}
|
||||
fun chooseAutoSkipIntro(seconds:Int){autoSkipIntroSeconds=seconds.coerceIn(0,60);preferences.edit().putInt("autoSkipIntroSeconds",autoSkipIntroSeconds).remove("autoSkipIntro").apply()}
|
||||
fun chooseAutoSkipCredits(seconds:Int){autoSkipCreditsSeconds=seconds.coerceIn(0,60);preferences.edit().putInt("autoSkipCreditsSeconds",autoSkipCreditsSeconds).remove("autoSkipCredits").apply()}
|
||||
fun chooseSubtitleSize(value:SubtitleSize){subtitleSize=value;preferences.edit().putString("subtitleSize",value.name).apply()}
|
||||
fun chooseSubtitleStyle(value:SubtitleStyle){subtitleStyle=value;preferences.edit().putString("subtitleStyle",value.name).apply()}
|
||||
fun chooseWatchedPercent(value:Int){watchedPercent=value.coerceIn(50,100);preferences.edit().putInt("watchedPercent",watchedPercent).apply()}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ import androidx.compose.runtime.*
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.draw.drawBehind
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.focus.*
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
|
|
@ -100,12 +102,22 @@ import kotlinx.coroutines.delay
|
|||
if(marker.type=="credits"&&item.type=="episode"){controller.pause();android.util.Log.i("KaleidoPlayback","POSTPLAY item=${item.id} reason=skip-credits");postPlay=true}
|
||||
else controller.seekTo(marker.end)
|
||||
}
|
||||
// Each marker is skipped automatically once, so seeking back into it plays it.
|
||||
// Each marker counts down to an automatic skip once, so seeking back into it plays it.
|
||||
// The countdown runs only while playing; any remote press cancels it (OK on the button skips now).
|
||||
val autoSkipped=remember{mutableSetOf<Marker>()}
|
||||
LaunchedEffect(marker,controller.loading) {
|
||||
val m=marker ?: return@LaunchedEffect
|
||||
if(controller.loading||postPlay||m in autoSkipped)return@LaunchedEffect
|
||||
if(m.type=="intro"&&vm.autoSkipIntro||m.type=="credits"&&vm.autoSkipCredits){autoSkipped+=m;android.util.Log.i("KaleidoPlayback","AUTOSKIP ${m.type} item=${item.id}");skip(m)}
|
||||
var autoSkip by remember{mutableStateOf<Marker?>(null)}
|
||||
var autoSkipTotal by remember{mutableLongStateOf(0)}
|
||||
var autoSkipRemaining by remember{mutableLongStateOf(0)}
|
||||
fun cancelAutoSkip(){val m=autoSkip ?: return;autoSkipped+=m;autoSkip=null;android.util.Log.i("KaleidoPlayback","AUTOSKIP cancelled ${m.type} item=${item.id}")}
|
||||
LaunchedEffect(marker,controller.loading,postPlay) {
|
||||
val m=marker
|
||||
if(m==null||controller.loading||postPlay||m in autoSkipped){if(m==null||postPlay)autoSkip=null;return@LaunchedEffect}
|
||||
val seconds=when(m.type){"intro"->vm.autoSkipIntroSeconds;"credits"->vm.autoSkipCreditsSeconds;else->0}
|
||||
if(seconds<=0)return@LaunchedEffect
|
||||
if(autoSkip!=m){autoSkip=m;autoSkipTotal=seconds*1000L;autoSkipRemaining=autoSkipTotal;android.util.Log.i("KaleidoPlayback","AUTOSKIP countdown ${m.type} seconds=$seconds item=${item.id}")}
|
||||
while(autoSkipRemaining>0){delay(50);if(autoSkip!=m)return@LaunchedEffect;if(controller.isPlaying)autoSkipRemaining-=50}
|
||||
if(autoSkip!=m)return@LaunchedEffect
|
||||
autoSkipped+=m;autoSkip=null;android.util.Log.i("KaleidoPlayback","AUTOSKIP ${m.type} item=${item.id}");skip(m)
|
||||
}
|
||||
DisposableEffect(controller) {
|
||||
activity.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
|
|
@ -125,6 +137,13 @@ import kotlinx.coroutines.delay
|
|||
BackHandler(onBack=::goBack)
|
||||
val visible=controls&&!postPlay
|
||||
Box(Modifier.fillMaxSize().background(Color.Black).focusRequester(rootFocus).onPreviewKeyEvent{event->
|
||||
// A pending automatic skip yields to the remote. Back only cancels it; OK on a hidden
|
||||
// player still takes the Skip button, which skips now.
|
||||
val okHidden=!visible&&event.nativeKeyEvent.keyCode in listOf(android.view.KeyEvent.KEYCODE_DPAD_CENTER,android.view.KeyEvent.KEYCODE_ENTER)
|
||||
if(autoSkip!=null&&event.type==KeyEventType.KeyDown&&!okHidden&&!postPlay){
|
||||
cancelAutoSkip()
|
||||
if(event.key==Key.Back)return@onPreviewKeyEvent true
|
||||
}
|
||||
if(event.key==Key.Back){if(event.type==KeyEventType.KeyDown)goBack();true}
|
||||
else if(event.type!=KeyEventType.KeyDown||postPlay)false else {
|
||||
interacted()
|
||||
|
|
@ -135,7 +154,7 @@ 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}
|
||||
// With the controls hidden, OK takes a visible Skip intro/credits; otherwise it reveals them.
|
||||
android.view.KeyEvent.KEYCODE_DPAD_CENTER,android.view.KeyEvent.KEYCODE_ENTER->{if(!visible){marker?.let(::skip) ?: run{controls=true};true}else false}
|
||||
android.view.KeyEvent.KEYCODE_DPAD_CENTER,android.view.KeyEvent.KEYCODE_ENTER->{if(!visible){marker?.let{autoSkip=null;autoSkipped+=it;skip(it)} ?: run{controls=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 {
|
||||
|
|
@ -177,29 +196,42 @@ import kotlinx.coroutines.delay
|
|||
Spacer(Modifier.width(18.dp))
|
||||
Text(controller.qualityLabel,color=Color.White.copy(alpha=.6f),fontSize=10.sp,lineHeight=14.sp,maxLines=1,overflow=TextOverflow.Ellipsis,modifier=Modifier.widthIn(max=360.dp))
|
||||
}
|
||||
SeekTimeline(controller,item,Modifier.fillMaxWidth().focusRequester(timelineFocus).focusProperties{down=playFocus},::interacted)
|
||||
Box(Modifier.fillMaxWidth().height(40.dp)) {
|
||||
Row(Modifier.align(Alignment.CenterStart),verticalAlignment=Alignment.CenterVertically,horizontalArrangement=Arrangement.spacedBy(7.dp)) {
|
||||
IconControl(Icons.AutoMirrored.Outlined.ArrowBack,"Exit playback",size=30.dp,iconSize=18.dp,onFocused=::interacted){vm.stopPlayback()}
|
||||
Text(clockTime(controller.position),color=Color.White.copy(alpha=.78f),fontSize=10.sp,lineHeight=14.sp)
|
||||
// Elapsed and remaining time sit at the timeline's ends and follow a pending scrub.
|
||||
val shownPosition=controller.scrubPosition ?: controller.position
|
||||
Row(Modifier.fillMaxWidth(),verticalAlignment=Alignment.CenterVertically) {
|
||||
Text(clockTime(shownPosition),color=Color.White.copy(alpha=.82f),fontSize=10.sp,lineHeight=14.sp,maxLines=1,modifier=Modifier.width(58.dp))
|
||||
SeekTimeline(controller,item,Modifier.weight(1f).focusRequester(timelineFocus).focusProperties{down=playFocus},::interacted)
|
||||
Text("−"+clockTime(controller.duration-shownPosition),color=Color.White.copy(alpha=.62f),fontSize=10.sp,lineHeight=14.sp,maxLines=1,textAlign=TextAlign.End,modifier=Modifier.width(58.dp))
|
||||
}
|
||||
Box(Modifier.fillMaxWidth().padding(top=6.dp).height(48.dp)) {
|
||||
Row(Modifier.align(Alignment.CenterStart),verticalAlignment=Alignment.CenterVertically,horizontalArrangement=Arrangement.spacedBy(10.dp)) {
|
||||
IconControl(Icons.AutoMirrored.Outlined.ArrowBack,"Exit playback",size=32.dp,iconSize=19.dp,modifier=Modifier.focusProperties{up=timelineFocus},onFocused=::interacted){vm.stopPlayback()}
|
||||
Text("Ends "+endsAt(controller),color=Color.White.copy(alpha=.58f),fontSize=10.sp,lineHeight=14.sp,maxLines=1)
|
||||
}
|
||||
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&&!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()}
|
||||
// Transport: episodes step between neighbours around the seek and play controls.
|
||||
// An absent previous episode keeps its space, so Play stays centred.
|
||||
Row(Modifier.align(Alignment.Center),verticalAlignment=Alignment.CenterVertically,horizontalArrangement=Arrangement.spacedBy(14.dp)) {
|
||||
val up=Modifier.focusProperties{up=timelineFocus}
|
||||
if(item.type=="episode") {
|
||||
if(vm.mayHavePrecedingEpisode(item))IconControl(Icons.Outlined.SkipPrevious,"Previous episode",size=34.dp,iconSize=22.dp,modifier=up,onFocused=::interacted){vm.previousEpisode(item);interacted()}
|
||||
else Spacer(Modifier.size(34.dp))
|
||||
}
|
||||
IconControl(Icons.Outlined.Replay10,"Back 10 seconds",size=34.dp,iconSize=22.dp,modifier=up,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=46.dp,iconSize=30.dp,requester=playFocus,selected=true,initialFocus=controls&&!seekFocus&&!timelineReveal,modifier=up,onFocused=::interacted){controller.toggle();controls=true;interacted()}
|
||||
IconControl(Icons.Outlined.Forward30,"Forward 30 seconds",size=34.dp,iconSize=22.dp,modifier=up,onFocused=::interacted){controller.seekTo(controller.position+30000);interacted()}
|
||||
if(item.type=="episode")IconControl(Icons.Outlined.SkipNext,"Next episode",size=34.dp,iconSize=22.dp,modifier=up,onFocused=::interacted){vm.nextEpisode(item);interacted()}
|
||||
}
|
||||
Row(Modifier.align(Alignment.CenterEnd),verticalAlignment=Alignment.CenterVertically,horizontalArrangement=Arrangement.spacedBy(10.dp)) {
|
||||
Text("−"+clockTime(controller.duration-controller.position)+" · Ends "+endsAt(controller),color=Color.White.copy(alpha=.58f),fontSize=10.sp,lineHeight=14.sp,modifier=Modifier.padding(end=8.dp))
|
||||
if(item.type=="episode")IconControl(Icons.Outlined.SkipNext,"Next episode",size=30.dp,iconSize=21.dp,onFocused=::interacted){vm.nextEpisode(item)}
|
||||
IconControl(Icons.AutoMirrored.Outlined.VolumeUp,"Audio tracks",size=30.dp,iconSize=21.dp,requester=audioFocus,selected=trackMenu==1,modifier=Modifier.focusProperties{up=timelineFocus},onFocused=::interacted){trackMenu=1;interacted()}
|
||||
IconControl(Icons.Outlined.Subtitles,"Subtitles",size=30.dp,iconSize=21.dp,requester=subtitleFocus,selected=trackMenu==2,modifier=Modifier.focusProperties{up=timelineFocus},onFocused=::interacted){trackMenu=2;interacted()}
|
||||
IconControl(Icons.Outlined.Settings,"Playback options",size=30.dp,iconSize=21.dp,requester=optionsFocus,selected=trackMenu>=3,modifier=Modifier.focusProperties{up=timelineFocus},onFocused=::interacted){trackMenu=3;interacted()}
|
||||
IconControl(Icons.AutoMirrored.Outlined.VolumeUp,"Audio tracks",size=32.dp,iconSize=20.dp,requester=audioFocus,selected=trackMenu==1,modifier=Modifier.focusProperties{up=timelineFocus},onFocused=::interacted){trackMenu=1;interacted()}
|
||||
IconControl(Icons.Outlined.Subtitles,"Subtitles",size=32.dp,iconSize=20.dp,requester=subtitleFocus,selected=trackMenu==2,modifier=Modifier.focusProperties{up=timelineFocus},onFocused=::interacted){trackMenu=2;interacted()}
|
||||
IconControl(Icons.Outlined.Settings,"Playback options",size=32.dp,iconSize=20.dp,requester=optionsFocus,selected=trackMenu>=3,modifier=Modifier.focusProperties{up=timelineFocus},onFocused=::interacted){trackMenu=3;interacted()}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
marker?.let{marker->if(!postPlay)Box(Modifier.align(Alignment.BottomEnd).padding(end=Cinema.gutter,bottom=if(visible)130.dp else 45.dp)) {
|
||||
ActionButton(if(marker.type=="intro")"Skip intro"else "Skip credits",Icons.Outlined.ChevronRight,modifier=Modifier.background(Color.Black.copy(alpha=.9f),RoundedCornerShape(5.dp)).border(1.dp,Color.White.copy(alpha=.75f),RoundedCornerShape(5.dp))){skip(marker);interacted()}
|
||||
marker?.let{marker->if(!postPlay)Box(Modifier.align(Alignment.BottomEnd).padding(end=Cinema.gutter,bottom=if(visible)146.dp else 45.dp)) {
|
||||
val counting=autoSkip==marker&&autoSkipTotal>0
|
||||
SkipMarkerButton(marker.type=="intro",if(counting)1f-(autoSkipRemaining.toFloat()/autoSkipTotal).coerceIn(0f,1f)else null){autoSkip=null;autoSkipped+=marker;skip(marker);interacted()}
|
||||
}}
|
||||
if(postPlay)PostPlayScreen(vm,item,{postPlay=false;controls=true},{vm.nextEpisode(item)})
|
||||
controller.error?.let{ErrorDialog(it,{vm.stopPlayback()},{controller.retry()})}
|
||||
|
|
@ -220,6 +252,27 @@ import kotlinx.coroutines.delay
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip intro/credits. While an automatic skip is pending ([progress] non-null) it reads
|
||||
* "Skipping intro" and a lighter fill sweeps across it until the skip happens, without numbers.
|
||||
*/
|
||||
@Composable private fun SkipMarkerButton(intro:Boolean,progress:Float?,onClick:()->Unit) {
|
||||
var focused by remember{mutableStateOf(false)}
|
||||
val shape=RoundedCornerShape(6.dp)
|
||||
val label=if(progress!=null)(if(intro)"Skipping intro"else "Skipping credits")else if(intro)"Skip intro"else "Skip credits"
|
||||
val foreground=if(focused)Ink else Accent
|
||||
Row(Modifier.height(36.dp).navigationSound().onFocusChanged{focused=it.isFocused}.clip(shape)
|
||||
.drawBehind{
|
||||
drawRect(if(focused)Accent else Color(0xE6181818))
|
||||
if(progress!=null&&!focused)drawRect(Color.White.copy(alpha=.2f),size=androidx.compose.ui.geometry.Size(size.width*progress,size.height))
|
||||
}
|
||||
.border(1.dp,Color.White.copy(alpha=if(focused)0f else .55f),shape).semantics{contentDescription=label}
|
||||
.clickable(onClick=onClick).padding(horizontal=16.dp),verticalAlignment=Alignment.CenterVertically,horizontalArrangement=Arrangement.spacedBy(10.dp)) {
|
||||
Text(label,color=foreground,fontSize=12.sp,lineHeight=16.sp,fontWeight=FontWeight.SemiBold)
|
||||
Icon(Icons.Filled.SkipNext,null,tint=foreground,modifier=Modifier.size(17.dp))
|
||||
}
|
||||
}
|
||||
|
||||
/** The same track selector is reachable from the speaker and from Playback options. */
|
||||
@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
|
||||
@Composable internal fun AudioTrackPanel(controller:PlaybackController,dismiss:()->Unit,close:()->Unit) {
|
||||
|
|
|
|||
|
|
@ -87,6 +87,12 @@ class PlexApi(val clientId: String) {
|
|||
suspend fun hubs(section: String? = null): List<Hub> = withContext(Dispatchers.Default){container(if(section==null) "/hubs" else "/hubs/sections/$section", mapOf("count" to "18","includeExternalMetadata" to "1")).optJSONArray("Hub").objects().map { Hub(it.optString("hubIdentifier",it.optString("key",it.optString("title"))),it.optString("title"),it.optJSONArray("Metadata").objects().map(Title::parse),it.optString("key"),it.opt("more").let{v->v==true||v==1||v=="1"||v=="true"}) }.filter { it.items.isNotEmpty() && it.items.first().type in listOf("movie","show","episode","season","collection") }}
|
||||
/** A hub's complete list, for "View all". Plex keys may already carry query parameters. */
|
||||
suspend fun hubItems(key:String):List<Title> = withContext(Dispatchers.Default){container(key,mapOf("X-Plex-Container-Start" to "0","X-Plex-Container-Size" to "500","includeExternalMetadata" to "1")).optJSONArray("Metadata").objects().map(Title::parse)}
|
||||
/**
|
||||
* Continue Watching as a fingerprint. Watching on another device changes it without changing the
|
||||
* library revision above: new, finished or reordered titles at once, progress in 5% steps (so
|
||||
* a title playing elsewhere doesn't rebuild Home on every poll).
|
||||
*/
|
||||
suspend fun continueWatchingRevision():String = continueWatchingFingerprint(container("/library/onDeck",mapOf("X-Plex-Container-Size" to "30")).optJSONArray("Metadata").objects())
|
||||
suspend fun onDeck(): List<Title> = container("/library/onDeck",mapOf("X-Plex-Container-Size" to "30")).optJSONArray("Metadata").objects().map(Title::parse)
|
||||
suspend fun recentSeasons(section:String):List<Title> = withContext(Dispatchers.Default){
|
||||
// Fetch beyond the display limit so one large series import doesn't fill the row.
|
||||
|
|
@ -177,3 +183,8 @@ internal fun partFor(parts:List<Part>,time:Long):Int {
|
|||
return 0
|
||||
}
|
||||
internal fun partStart(parts:List<Part>,index:Int):Long = parts.take(index.coerceAtLeast(0)).sumOf{it.duration.coerceAtLeast(0)}
|
||||
internal fun continueWatchingFingerprint(items:List<JSONObject>):String = items.joinToString("|"){j->
|
||||
val duration=j.optLong("duration");val offset=j.optLong("viewOffset")
|
||||
val step=if(duration>0)(offset*20/duration).toString()else (offset/120_000).toString()
|
||||
"${j.optString("ratingKey")}:${j.optString("viewCount")}:$step"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ fun CohesiveSettingsScreen(vm: KaleidoViewModel, install: (File) -> Unit) {
|
|||
var watchedDialog by remember { mutableStateOf(false) }
|
||||
var remoteDialog by remember { mutableStateOf(false) }
|
||||
var autoplayDialog by remember { mutableStateOf(false) }
|
||||
var introDialog by remember { mutableStateOf(false) }
|
||||
var creditsDialog by remember { mutableStateOf(false) }
|
||||
var subtitleSizeDialog by remember { mutableStateOf(false) }
|
||||
var subtitleStyleDialog by remember { mutableStateOf(false) }
|
||||
var themeVolumeDialog by remember { mutableStateOf(false) }
|
||||
|
|
@ -72,7 +74,7 @@ fun CohesiveSettingsScreen(vm: KaleidoViewModel, install: (File) -> Unit) {
|
|||
delay(140)
|
||||
runCatching { entryFocus[selectedCategory].requestFocus() }
|
||||
}
|
||||
val anyDialogOpen = confirmSignOut || qualityDialog || watchedDialog || remoteDialog || autoplayDialog ||
|
||||
val anyDialogOpen = confirmSignOut || qualityDialog || watchedDialog || remoteDialog || autoplayDialog || introDialog || creditsDialog ||
|
||||
subtitleSizeDialog || subtitleStyleDialog || themeVolumeDialog
|
||||
LaunchedEffect(anyDialogOpen, dialogRestoreFocus) {
|
||||
if (!anyDialogOpen) {
|
||||
|
|
@ -242,19 +244,19 @@ fun CohesiveSettingsScreen(vm: KaleidoViewModel, install: (File) -> Unit) {
|
|||
)
|
||||
SettingsValueRow(
|
||||
title = "Skip intros",
|
||||
description = "Uses intro markers from your Plex server.",
|
||||
value = if (vm.autoSkipIntro) "Automatically" else "Show button",
|
||||
description = "Uses intro markers from your Plex server. Any remote press cancels an automatic skip.",
|
||||
value = autoSkipLabel(vm.autoSkipIntroSeconds),
|
||||
requester = introFocus,
|
||||
leftTarget = categoryFocus[1],
|
||||
onClick = { vm.chooseAutoSkipIntro(!vm.autoSkipIntro) }
|
||||
onClick = { dialogRestoreFocus = introFocus; introDialog = true }
|
||||
)
|
||||
SettingsValueRow(
|
||||
title = "Skip credits",
|
||||
description = "Episodes go straight to Up Next; movies skip past the credits.",
|
||||
value = if (vm.autoSkipCredits) "Automatically" else "Show button",
|
||||
description = "Episodes go straight to Up Next; movies skip past the credits. Any remote press cancels an automatic skip.",
|
||||
value = autoSkipLabel(vm.autoSkipCreditsSeconds),
|
||||
requester = creditsFocus,
|
||||
leftTarget = categoryFocus[1],
|
||||
onClick = { vm.chooseAutoSkipCredits(!vm.autoSkipCredits) }
|
||||
onClick = { dialogRestoreFocus = creditsFocus; creditsDialog = true }
|
||||
)
|
||||
Text(
|
||||
"Completed titles keep their Plex watched status.",
|
||||
|
|
@ -405,6 +407,18 @@ fun CohesiveSettingsScreen(vm: KaleidoViewModel, install: (File) -> Unit) {
|
|||
remoteDialog = false
|
||||
}
|
||||
}
|
||||
if (introDialog) {
|
||||
ChoiceDialog("Skip intros", AutoSkipChoices.map(::autoSkipLabel), AutoSkipChoices.indexOf(vm.autoSkipIntroSeconds).coerceAtLeast(0), { introDialog = false }) {
|
||||
vm.chooseAutoSkipIntro(AutoSkipChoices[it])
|
||||
introDialog = false
|
||||
}
|
||||
}
|
||||
if (creditsDialog) {
|
||||
ChoiceDialog("Skip credits", AutoSkipChoices.map(::autoSkipLabel), AutoSkipChoices.indexOf(vm.autoSkipCreditsSeconds).coerceAtLeast(0), { creditsDialog = false }) {
|
||||
vm.chooseAutoSkipCredits(AutoSkipChoices[it])
|
||||
creditsDialog = false
|
||||
}
|
||||
}
|
||||
if (autoplayDialog) {
|
||||
val choices = listOf(0, 5, 10, 15, 30)
|
||||
ChoiceDialog("Autoplay next episode", choices.map(::autoplayLabel), choices.indexOf(vm.autoplaySeconds), { autoplayDialog = false }) {
|
||||
|
|
@ -440,6 +454,9 @@ fun CohesiveSettingsScreen(vm: KaleidoViewModel, install: (File) -> Unit) {
|
|||
}
|
||||
|
||||
private fun autoplayLabel(seconds: Int) = if (seconds <= 0) "Off" else "After $seconds seconds"
|
||||
/** 0 only shows the Skip button; otherwise the button counts down this long before skipping. */
|
||||
private val AutoSkipChoices = listOf(0, 3, 5, 10, 15)
|
||||
private fun autoSkipLabel(seconds: Int) = if (seconds <= 0) "Show button" else "Automatically after $seconds s"
|
||||
|
||||
/** A sample line in the chosen subtitle look, rendered by the player's own subtitle view. */
|
||||
@androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,19 @@ internal class ShuffleEpisodes<T>(
|
|||
return nextCycle?.firstOrNull() ?: makeNextCycle(order[currentIndex]).also { nextCycle = it }.firstOrNull()
|
||||
}
|
||||
|
||||
/** The item played before [currentId] in this bag, or null at the bag's start. */
|
||||
fun preceding(currentId: String): T? {
|
||||
if (order.getOrNull(currentIndex)?.let(id) != currentId) return null
|
||||
return order.getOrNull(currentIndex - 1)
|
||||
}
|
||||
|
||||
/** Steps back only when [previousId] is the item returned by [preceding]. */
|
||||
fun retreat(currentId: String, previousId: String): Boolean {
|
||||
if (preceding(currentId)?.let(id) != previousId) return false
|
||||
currentIndex--
|
||||
return true
|
||||
}
|
||||
|
||||
/** Advances only when [nextId] is the next item returned by [following]. */
|
||||
fun advance(currentId: String, nextId: String): Boolean {
|
||||
if (following(currentId)?.let(id) != nextId) return false
|
||||
|
|
|
|||
|
|
@ -9,6 +9,19 @@ import org.junit.Test
|
|||
import kotlin.random.Random
|
||||
|
||||
class ShuffleEpisodesTest {
|
||||
@Test fun previousEpisodeReturnsToTheEarlierPickOnly() {
|
||||
val shuffle=ShuffleEpisodes(listOf("e1","e2","e3","e4"),{it},Random(7))
|
||||
val first=shuffle.first!!
|
||||
assertNull(shuffle.preceding(first))
|
||||
val second=shuffle.following(first)!!
|
||||
assertTrue(shuffle.advance(first,second))
|
||||
assertEquals(first,shuffle.preceding(second))
|
||||
assertTrue(!shuffle.retreat(second,"not-played"))
|
||||
assertTrue(shuffle.retreat(second,first))
|
||||
// Stepping back keeps the bag: the same episode follows again.
|
||||
assertEquals(second,shuffle.following(first))
|
||||
assertNull(shuffle.preceding(second))
|
||||
}
|
||||
@Test fun eachBagContainsEveryEpisodeOnceAndBoundaryDoesNotRepeat() {
|
||||
val episodes=listOf("e1","e2","e3","e4","e5")
|
||||
val shuffle=ShuffleEpisodes(episodes,{it},Random(42))
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
16ca9909181a434dad1f946a089c7cf719f328af101bd5b740ededc635ecc7b4 Kaleido.apk
|
||||
2d4fada001103d337515a05bec9a6edae01a33744fd4e36049a4fce149e11be6 Kaleido.apk
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"version": "0.6.2",
|
||||
"versionCode": 22,
|
||||
"url": "https://git.elijahkuntz.com/Elijah/Kaleido/raw/tag/v0.6.2/distribution/Kaleido.apk",
|
||||
"checksumUrl": "https://git.elijahkuntz.com/Elijah/Kaleido/raw/tag/v0.6.2/distribution/Kaleido.apk.sha256",
|
||||
"notes": "- New startup animation, the same as Kaleido Desktop's: a kaleidoscope of shards turns and gathers into the Kaleido mark, then the view flies through its centre into Home."
|
||||
"version": "0.7.0",
|
||||
"versionCode": 23,
|
||||
"url": "https://git.elijahkuntz.com/Elijah/Kaleido/raw/tag/v0.7.0/distribution/Kaleido.apk",
|
||||
"checksumUrl": "https://git.elijahkuntz.com/Elijah/Kaleido/raw/tag/v0.7.0/distribution/Kaleido.apk.sha256",
|
||||
"notes": "- Add a Previous episode button to the player, and redesign its controls: elapsed and remaining time at the ends of the timeline, previous episode, back 10 seconds, play, forward 30 seconds and next episode grouped in the centre, and the finish time beside Exit. Previous episode also steps back through a shuffle.\n- Skip intros and credits automatically after a delay you choose in Settings \u203a Playback (3, 5, 10 or 15 seconds, or show the button only). A pending skip reads \"Skipping intro\" with a filling background; pressing any button on the remote cancels it, and OK skips straight away. The earlier \"Automatically\" setting becomes a 5-second skip.\n- Show what you watch on other devices promptly: Kaleido checks Continue Watching every 15 seconds while open and as soon as you return to it.\n- Keep playback paused when you leave Kaleido while a stream is still starting, and only count down to the next episode while Kaleido is on screen.\n- Keep the resume point when leaving a title before its stream has started, and keep progress reports on the server the title came from.\n- Close Settings \u203a Choose server with Back or the new Cancel button, and enter Home's rows from the Home tab when there is no featured title.\n- Cancel slow network requests when they are no longer needed, and connect to the best server address as soon as it answers.\n- Update a title's format badges when you pick another version, keep New Seasons when one show can't be loaded, and keep focus on Continue Watching when a card is replaced while a title page is open.\n- Remove Volume boost, which degraded audio, and leave the player with the server's reason when a stream is stopped from the Plex dashboard."
|
||||
}
|
||||
|
|
|
|||
132
scripts/verify_player_features.py
Normal file
132
scripts/verify_player_features.py
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
"""Previous episode, timed auto-skip with remote cancellation, server-picker Back and resume refresh.
|
||||
|
||||
Requires the **debug** build (test intents and run-as). Playback runs as validation, so it reports no
|
||||
Plex progress. The refresh check moves one Continue Watching offset and restores it; the auto-skip
|
||||
preferences are restored as found.
|
||||
"""
|
||||
import json,pathlib,re,sys,time,urllib.request,urllib.parse
|
||||
sys.path.insert(0,str(pathlib.Path(__file__).resolve().parent))
|
||||
from device import adb,ROOT,screenshot
|
||||
from verify_ui import key,snapshot,focus,labels,wait,focused,text,launch
|
||||
from repro_runtime import await_ready
|
||||
|
||||
PREFS='shared_prefs/preferences.xml'
|
||||
INTRO_EPISODE=11621 # The Big Bang Theory 10x24: intro marker 117.4-146.7 s
|
||||
SILO_FIRST,SILO_SECOND=7599,8594
|
||||
|
||||
def logs(tag='KaleidoPlayback'):return adb('logcat','-d','-s',f'{tag}:I','AndroidRuntime:E','*:S').decode(errors='replace')
|
||||
def wait_log(needle,timeout=30,tag='KaleidoPlayback'):
|
||||
deadline=time.monotonic()+timeout
|
||||
while time.monotonic()<deadline:
|
||||
if needle in logs(tag):return
|
||||
time.sleep(.3)
|
||||
raise AssertionError(f'Log never showed {needle!r}')
|
||||
def start(item,offset):
|
||||
adb('shell','am','force-stop','tv.kaleido.app');adb('logcat','-c')
|
||||
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity','--es','testTitleId',str(item),'--el','testOffset',str(offset),'--ei','testMode','1','--ez','testValidation','true')
|
||||
await_ready(item)
|
||||
|
||||
def read_prefs():return adb('shell','run-as','tv.kaleido.app','cat',PREFS).decode()
|
||||
def write_prefs(xml):
|
||||
adb('shell','am','force-stop','tv.kaleido.app')
|
||||
adb('shell','run-as','tv.kaleido.app','sh','-c','"cat > '+PREFS+'"',data=xml.encode())
|
||||
def with_int(xml,name,value):
|
||||
entry=f'<int name="{name}" value="{value}" />'
|
||||
pattern=re.compile(r'<int name="'+name+r'" value="-?\d+" />')
|
||||
return pattern.sub(entry,xml) if pattern.search(xml) else xml.replace('</map>',f' {entry}\n</map>')
|
||||
|
||||
def auto_skip():
|
||||
start(INTRO_EPISODE,112000)
|
||||
wait_log('AUTOSKIP countdown intro seconds=5')
|
||||
root=wait(lambda r:'Skipping intro' in labels(r),'Pending skip reads "Skipping intro", without a number')
|
||||
assert not any(re.search(r'Skip(ping)? intro.*\d',l) for l in labels(root)),'Skip button shows a numeric countdown'
|
||||
screenshot('auto-skip-pending')
|
||||
wait_log(f'AUTOSKIP intro item={INTRO_EPISODE}',timeout=15)
|
||||
assert 'AUTOSKIP cancelled' not in logs()
|
||||
print('PASS intro skips itself after the countdown, shown as a fill rather than a number',flush=True)
|
||||
for code,name in ((20,'Down'),(4,'Back')):
|
||||
start(INTRO_EPISODE,112000)
|
||||
wait_log('AUTOSKIP countdown intro')
|
||||
key(code);wait_log('AUTOSKIP cancelled intro',timeout=5)
|
||||
time.sleep(7)
|
||||
assert f'AUTOSKIP intro item={INTRO_EPISODE}' not in logs(),f'{name} did not cancel the automatic skip'
|
||||
root=wait(lambda r:'Skip intro' in labels(r),'Manual Skip intro stays available after cancelling')
|
||||
assert adb('shell','pidof','tv.kaleido.app').strip(),'Player process exited'
|
||||
assert 'Skipping intro' not in labels(root)
|
||||
print(f'PASS {name} cancels the automatic skip and leaves the player open',flush=True)
|
||||
screenshot('auto-skip-cancelled')
|
||||
key(4);key(4)
|
||||
|
||||
def previous_episode():
|
||||
start(SILO_SECOND,90000)
|
||||
key(127);focused('Play');screenshot('player-bar-episode')
|
||||
key(21);focused('Back 10 seconds');key(21);focused('Previous episode');key(23)
|
||||
await_ready(SILO_FIRST)
|
||||
assert 'FATAL EXCEPTION' not in logs(),'Previous episode crashed'
|
||||
print('PASS Previous episode replaced the player with the earlier episode',flush=True)
|
||||
time.sleep(2);key(127);focused('Play')
|
||||
# The series' first episode has no previous one once its season list has loaded.
|
||||
wait(lambda r:'Next episode' in labels(r) and 'Previous episode' not in labels(r),'No Previous episode on the first episode')
|
||||
key(21);focused('Back 10 seconds');key(21)
|
||||
assert 'Back 10 seconds' in focus(snapshot()) or 'Exit playback' in focus(snapshot())
|
||||
print('PASS first episode offers Next but not Previous',flush=True)
|
||||
key(4);key(4)
|
||||
|
||||
def server_picker():
|
||||
launch();key(22,4);focused('Settings');key(23);focused('Switch account');key(22)
|
||||
if 'Choose server' not in focus(snapshot()):print('SKIP no account-linked server list (server-token session)');key(4);return
|
||||
key(23);text('Choose your Plex server');screenshot('server-picker')
|
||||
key(4)
|
||||
wait(lambda r:'Choose your Plex server' not in labels(r) and 'Choose server' in labels(r),'Back closes the server picker over Settings')
|
||||
assert adb('shell','pidof','tv.kaleido.app').strip()
|
||||
key(22) # Choose server again, now via the Cancel button
|
||||
if 'Choose server' not in focus(snapshot()):key(21)
|
||||
focused('Choose server');key(23);text('Choose your Plex server')
|
||||
for _ in range(12):
|
||||
if focus(snapshot())=='Cancel':break
|
||||
key(20)
|
||||
focused('Cancel');key(23)
|
||||
wait(lambda r:'Choose your Plex server' not in labels(r) and 'Choose server' in labels(r),'Cancel closes the server picker')
|
||||
print('PASS Back and Cancel close Settings > Choose server',flush=True)
|
||||
key(4)
|
||||
|
||||
def plex(path,params):
|
||||
env=dict(l.strip().split('=',1) for l in (ROOT/'.env').read_text().splitlines() if '=' in l and not l.startswith('#'))
|
||||
url=env['PLEX_SERVER_URL'].strip('"\'').rstrip('/')+path+'?'+urllib.parse.urlencode(params)
|
||||
req=urllib.request.Request(url,headers={'X-Plex-Token':env['PLEX_TOKEN'].strip('"\''),'Accept':'application/json','X-Plex-Client-Identifier':'kaleido-development','X-Plex-Product':'Kaleido'})
|
||||
with urllib.request.urlopen(req,timeout=20) as r:return r.read()
|
||||
def offset(item,field='viewOffset'):
|
||||
from inspect_server import get
|
||||
return int(get(f'/library/metadata/{item}')['Metadata'][0].get(field,0))
|
||||
def set_offset(item,ms):plex('/:/progress',{'key':str(item),'identifier':'com.plexapp.plugins.library','time':str(ms),'state':'stopped'})
|
||||
|
||||
def refresh():
|
||||
original=offset(SILO_FIRST)
|
||||
# Continue Watching progress is compared in 5% steps; move by more than one step each time.
|
||||
step=offset(SILO_FIRST,'duration')*6//100
|
||||
try:
|
||||
launch();time.sleep(4);adb('logcat','-c')
|
||||
# Watched elsewhere while Kaleido is in the background: shown promptly on return.
|
||||
key('KEYCODE_HOME');time.sleep(3)
|
||||
set_offset(SILO_FIRST,original+step)
|
||||
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity')
|
||||
began=time.monotonic();wait_log('APPLIED',timeout=10,tag='KaleidoSync')
|
||||
print(f'PASS returning to Kaleido applied Continue Watching changes in {time.monotonic()-began:.1f}s',flush=True)
|
||||
# Watched elsewhere while Kaleido stays open: the background poll picks it up.
|
||||
time.sleep(3);adb('logcat','-c');set_offset(SILO_FIRST,original+2*step);began=time.monotonic()
|
||||
wait_log('APPLIED',timeout=25,tag='KaleidoSync')
|
||||
print(f'PASS open Kaleido applied a progress change from another device in {time.monotonic()-began:.1f}s',flush=True)
|
||||
finally:
|
||||
set_offset(SILO_FIRST,original)
|
||||
assert offset(SILO_FIRST)==original,'Fixture progress was not restored'
|
||||
|
||||
if __name__=='__main__':
|
||||
phases=sys.argv[1:] or ['previous_episode','auto_skip','server_picker','refresh']
|
||||
original=read_prefs()
|
||||
try:
|
||||
if 'auto_skip' in phases:
|
||||
write_prefs(with_int(with_int(original,'autoSkipIntroSeconds',5),'autoSkipCreditsSeconds',0))
|
||||
for phase in phases:globals()[phase]()
|
||||
finally:
|
||||
write_prefs(original)
|
||||
adb('shell','am','start','-n','tv.kaleido.app/.MainActivity')
|
||||
|
|
@ -10,7 +10,10 @@ key(20);focused('Remote quality');key(23)
|
|||
wait(lambda r:any(q in focus(r) for q in ('Original quality','4K','1080p','720p','480p')),'Remote quality choices');key(4);focused('Remote quality')
|
||||
key(20);focused('Watched status');key(23);focused('80%');key(4);focused('Watched status')
|
||||
key(20);focused('Autoplay next episode');key(23);focused('After 5 seconds');key(4);focused('Autoplay next episode')
|
||||
key(20);focused('Skip intros');key(20);focused('Skip credits')
|
||||
key(20);focused('Skip intros');key(23)
|
||||
wait(lambda r:any(q in focus(r) for q in ('Show button','Automatically after')),'Skip intro delay choices');key(4);focused('Skip intros')
|
||||
key(20);focused('Skip credits');key(23)
|
||||
wait(lambda r:any(q in focus(r) for q in ('Show button','Automatically after')),'Skip credits delay choices');key(4);focused('Skip credits')
|
||||
print('PASS playback dialogs cancel back to their controls',flush=True)
|
||||
screenshot('settings-playback-current')
|
||||
key(21);focused('Playback');key(20);focused('Subtitles');key(22);focused('Size');key(23);focused('Normal');key(4);focused('Size')
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
versionName=0.6.2
|
||||
versionCode=22
|
||||
versionName=0.7.0
|
||||
versionCode=23
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue