Skip to content

Trying Auto Skip - #2618

Open
phisher98 wants to merge 25 commits into
recloudstream:masterfrom
phisher98:AutoSkip-Into/Outro
Open

phisher98 wants to merge 25 commits into
recloudstream:masterfrom
phisher98:AutoSkip-Into/Outro

Conversation

@phisher98

@phisher98 phisher98 commented Apr 5, 2026 •

Copy link
Copy Markdown
Contributor

Trying to implement auto-skip; used AI for guidance.

Added a setting to disable it as well.

@fire-light42

Copy link
Copy Markdown
Collaborator

Please check out the new API at 1d03b05

@Luna712

Luna712 commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Also, if this is done, I think it would make more sense for consistency with current behavior to be disabled by default. Just a suggestion though but not to adamant about it.

@phisher98
phisher98 marked this pull request as draft April 9, 2026 03:54
@phisher98
phisher98 marked this pull request as ready for review April 9, 2026 04:32
@phisher98

Copy link
Copy Markdown
Contributor Author

Auto Skip Disabled by Default

@fire-light42 fire-light42 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I have no doubt this works fine, the logic is hard to follow given the indirect recursion and global variables. I think it would be much cleaner if this was a simple for loop inside a suspended context. Then you only need a single "Job" variable that can be canceled.

@phisher98
phisher98 requested a review from fire-light42 April 13, 2026 10:04

@fire-light42 fire-light42 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good changes, but I think you can simplify this even more! ❤️

@phisher98
phisher98 requested a review from fire-light42 April 14, 2026 16:35
@phisher98

Copy link
Copy Markdown
Contributor Author

Done

@fire-light42 fire-light42 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good improvements, however while testing it I found that it is impossible to cancel it manually. Normally you either have a 5s countdown with a cancel button, or auto skip instantly. TV devices often cancel it immediately on any key-press.

So my question is: Is this the intended experience?

@phisher98

phisher98 commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Good improvements, however while testing it I found that it is impossible to cancel it manually. Normally you either have a 5s countdown with a cancel button, or auto skip instantly. TV devices often cancel it immediately on any key-press.

So my question is: Is this the intended experience?

Yes I guess do we need that ?

@phisher98
phisher98 requested a review from fire-light42 April 16, 2026 16:22
@fire-light42

Copy link
Copy Markdown
Collaborator

What I mean is that autoskip after 5s is a bit weird from a UX perspective. Here is an image of what I think autoskip should act like on TV, given my experience with the feature from other services.

Capture

Where as phone has a similar cancel when you press the screen. Otherwise what is the point of a 5s timer?

@fire-light42 fire-light42 added AI Assisted This pull request was AI assisted (or generated). Response needed Response from the author of the pull request needed labels Nov 1, 2026
# Conflicts:
#	app/src/main/res/values/strings.xml
- Any tap, swipe or key press now cancels the countdown, giving the
  user manual control (per review feedback)
- Cancel the countdown when playback is paused so the player never
  seeks away on its own while paused
- Restore the plain skip label whenever the countdown ends or is
  cancelled instead of leaving a stale '(3)' on the button
- Run the countdown in viewLifecycleOwner.lifecycleScope so it is
  cancelled with the view; removes the onDestroyView override and
  the redundant try/catch/finally
- Revert the ineffective skip button width change (the show/hide
  animator always sets its own width); keep the ellipsize fix
- Reword the setting title/description to match what it does
…p margin

- Show a 'Skipped <type> — Undo' snackbar after an automatic skip so
  inaccurate timestamps are recoverable; undo seeks back and suppresses
  auto-skipping that same timestamp again
- New 'Auto-skip countdown (Seconds)' setting (0-10, default 5);
  0 skips instantly, covering both behaviours requested in review
- New 'Auto-skip types' setting with a multi-select dialog so users can
  e.g. auto-skip openings but never endings; defaults to all types
- Both new preferences depend on the Auto skip switch and are disabled
  while it is off
- Seek 500ms past the timestamp end when skipping a chapter so the
  last frames of the skipped section are not shown
@phisher98
phisher98 marked this pull request as draft November 1, 2026 05:17
The player re-invokes the current timestamp on buffering transitions,
seeks and stamp loading, which reset the button label and restarted
the countdown from scratch each time. On streams that buffer at the
start of a video this meant the countdown never completed and the
button only ever showed the plain 'Skip Opening' label.

- Ignore re-invokes of a timestamp that is already showing
- Remember a timestamp the user declined by interacting or pausing,
  so a later re-show does not start a new countdown and skip anyway
… undo snackbar

The legacy XML preferences screen (settings_player.xml) is no longer
reachable; the live Player settings are the Compose SettingsPlayerScreen,
so the auto-skip settings were invisible. Add them there instead:

- 'Auto skip' switch under 'Skip OP'
- 'Auto-skip countdown (Seconds)' slider (0-10), disabled while off
- 'Auto-skip types' multi-select, disabled while off, defaults to all

Also remove the 'Skipped ... Undo' snackbar per feedback; the countdown
can be cancelled by interacting with the player, and a wrong skip can
be undone by seeking back manually
@phisher98
phisher98 marked this pull request as ready for review November 1, 2026 05:38
@fire-light42 fire-light42 added Review needed The pull request contains no obvious blockers. It just needs a review before merging. and removed Response needed Response from the author of the pull request needed labels Nov 3, 2026

@fire-light42 fire-light42 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything generally looks good, except that the timer should also stop if the user pauses the video or performs other button interactions such as opening the sources menu. The countdown is stressful to the user if they cannot easily cancel it. This looks mergable after that fix 👍

I am not sure what the best solution to defaultAutoSkipTypes is, but I will think of something.

companion object {
/** Keep in sync with SkipType enum names */
private val defaultAutoSkipTypes = setOf(
"Opening", "Ending", "Recap", "MixedOpening", "MixedEnding", "Credits", "Intro", "Preview"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand you did this solution because SkipType is not in the shared module, and moving it would entail also moving the translations. Surely there must be a better solution 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best solution is probably just moving the enum class to an identical package in shared, while making an extension val:

// In shared package com.lagradost.cloudstream3.utils.videoskip
enum class SkipType {
    Opening,
    Ending,
    Recap,
    MixedOpening,
    MixedEnding,
    Credits,
    Intro,
    Preview,
}

// Where the SkipType was previously 
@get:StringRes
val SkipType.res: Int
    get() {
       return when (this) {
            SkipType.Opening -> R.string.skip_type_op
            SkipType.Ending -> R.string.skip_type_ed
            SkipType.Recap -> R.string.skip_type_recap
            SkipType.MixedOpening -> R.string.skip_type_mixed_op
            SkipType.MixedEnding -> R.string.skip_type_mixed_ed
            SkipType.Credits -> R.string.skip_type_credits
            SkipType.Intro -> R.string.skip_type_intro
            SkipType.Preview -> R.string.skip_type_preview
        }
    }

Then you can do:

val autoSkipTypes = preferences.getEnumSet<SkipType>("auto_skip_types_key", SkipType.entries.toSet())

This should retain backwards compatibility, since extension developers should not use SkipType.res even if they make their own SkipAPI.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

The auto-skip preference keys now live only as literals in
PlayerPreferences, the single source of truth, and the player reads
them through the type-safe AppSettings like the rest of the new
settings code. Drops the now-unused donottranslate keys and the
leftover switch in the unreachable legacy XML preferences screen.
…um set

Per review: SkipType now lives in the shared module under the same
package, so PlayerPreferences can use a type-safe
getEnumSet<SkipType> instead of a literal String set that had to be
kept in sync with the enum names. The @stringres mapping moves to a
SkipType.res extension in the app module, where the translations live.
getEnumSet persists the enum names, so previously stored values stay
readable
@phisher98
phisher98 requested a review from LagradOst November 20, 2026 05:33

@LagradOst LagradOst left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work!

This pr still has some bugs that I found while reading the code, and confirmed to exist in testing. Additionally, the code can somewhat be trimmed down as there is some redundant code.

@phisher98
phisher98 requested a review from LagradOst November 22, 2026 11:34

@LagradOst LagradOst left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When testing I still found it possible to get the skip button stuck forever without disappearing by seeking it a few times.

@phisher98

Copy link
Copy Markdown
Contributor Author

When testing I still found it possible to get the skip button stuck forever without disappearing by seeking it a few times.

I haven't observed it getting stuck in my testing

@LagradOst

Copy link
Copy Markdown
Contributor

When testing I still found it possible to get the skip button stuck forever without disappearing by seeking it a few times.

I haven't observed it getting stuck in my testing

idk what to say, I was able to get is stuck using 1a3ceb8 so there is some bug that causes some cancellation or similar. I did not read the code closely enough to find the exact path, but I recommend stress testing and re-reading the code to find the bug.

@phisher98
phisher98 requested a review from LagradOst November 24, 2026 17:42

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Assisted This pull request was AI assisted (or generated). Review needed The pull request contains no obvious blockers. It just needs a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants