Repository navigation
Conversation
The video URL was only kept in the activity's saved state, so it was lost when the process was killed, e.g. when Android Auto disconnects because the car is switched off. YouTube then always opened the home page. - Save the playing video's URL and position every 5 s and on pause. Use the player's video id, since search results and the feed play videos inline without changing the page URL. - On a fresh start, open the saved video at the saved position (t=) and unmute it once, because YouTube mutes videos that autoplay without a tap. - Clear the saved video when it ends. - New "Resume last video" setting, enabled by default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This sounds awesome. Would love this feature. Thanks for working on it. |
AndreyPavlenko
left a comment
There was a problem hiding this comment.
Review: resume last video. Request changes on the must-fix items below. Should-fix items can land in this PR.
Must fix
-
Autoplay previews overwrite and clear the saved session.
JS_VIDEO_ENDEDcallsclearLastVideo()unconditionally, so a finished feed or search preview deletes the user's unfinished video.timeupdateandpausealso save for any playing video, so the stored target becomes whatever played last. Suggested fix: skip progress saves while the video is muted, and onendedclear only when the ended video id matches the saved id (send the id with the event). -
The unmute flag can be consumed by the wrong video.
unmuteOnPlay()is armed inonViewCreatedbeforeloadUrl(DEFAULT_URL). If the home page autoplays a muted preview, the firstplayingevent consumes the flag: the preview is unmuted and the resumed video stays muted. Suggested fix: pass the resumed video id tounmuteOnPlay(id)and unmute inplaying()only whenfermataVideoUrl()contains that id. Note that fix 1 and this one interact: the resumed video starts muted, so the "skip while muted" check must exempt it.
Should fix
-
Progress is saved even when "Resume last video" is off.
saveLastVideowrites prefs every 5 s regardless ofYT_RESUME_LAST. Gate the save on the pref. -
lastSavedUrlonly drives logging. Remove the field and thechangedflag, or drop the log lines. -
getVideoUrl()fallback conflicts withisVideoUrl. Stream URLs usually lack/watch?and/shorts/, so the filter rejects them. Drop the branch or make the filter match what it returns. -
No automated check for the new logic.
getResumeUrl(query rewrite,treplacement,pos > 0) andsaveProgressparsing are plain Java and easy to unit test. Theendedpath is untested per the description.
Also consider: the p.unMute() plus v.muted = false pair is a workaround for platform muting; a comment saying so would help the next reader.
— Claude
…are URL helpers - Restore YT_PLAYER_CONTROLS, YT_PAUSE_ON_LEAVE and YT_REOPEN_VIDEO_MIN, which the merge dropped - Save the last video only when "Resume last video" is enabled - On ENDED, clear the saved video only if it is the one that ended - Move URL/progress parsing into YoutubeUrls (no android.net.Uri) - Fix YoutubeFragment.onViewCreated, which the merge left mangled Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…muted progress, share URL helpers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem
When the car is switched off, Android Auto disconnects and the Fermata process is usually killed. Next time Fermata is opened, YouTube always starts on the home page and the unfinished video is lost.
YoutubeFragmentonly keeps the page URL in the fragment's saved state (onSaveInstanceState), which doesn't survive the process being killed.YT_RESUME_POSis persisted, but it's only applied when the YouTube engine is already the active one, which is never the case after a fresh start.Change
movie_player.getVideoData().video_id) when the page isn't a/watchor/shorts/page. m.youtube.com plays search results and feed items inline without changinglocation.href, so the page URL alone isn't enough.t=<seconds>s.Restarts where the fragment's saved state survives are unchanged.
Testing
Tested on an Honor 400 Pro (Android 16) with a 2.0.2 auto build that includes this change:
Not tested: inside a real car (my own build isn't listed by Android Auto because it's not signed with your key, which is why I'm sending this upstream rather than running a fork), and the "video ended clears the session" path.
Only English strings are added; the other
values-*files fall back to them.🤖 Generated with Claude Code