Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clearing watch positions doesn't works sometimes #5557

Conversation

manish99verma
Copy link
Contributor

No description provided.

@Bnyro
Copy link
Member

Bnyro commented Jan 26, 2024

This PR assumes that the timer task is still running in the background even though the player fragment already got killed?

I think it'd be easier to just release the timer in the onDestroy method to be sure and I don't see the need to create a new CustomTimer class to be honest, it doesn't really contain any additional functionality.

@manish99verma manish99verma changed the title fix: Clearing watch positions doesn't works sometimes fix2: Clearing watch positions doesn't works sometimes Jan 26, 2024
Copy link
Contributor Author

@manish99verma manish99verma left a comment

Choose a reason for hiding this comment

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

Removed Custom timer class. I thought it's easier to manage start and pause with custom timer class.

@@ -252,6 +251,9 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
}
}

// schedule task to save the watch position each second
private var watchPositionTimer = Timer()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
private var watchPositionTimer = Timer()
private var watchPositionTimer: Timer? = null

We don't need to initialize the timer here - it's going to be overwritten before the first usage anyways.

@@ -276,6 +278,18 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
100
)
}

//Start or pause watch position timer
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
//Start or pause watch position timer
// Start or pause watch position timer

@@ -907,7 +912,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {

val videoStream = streams.videoStreams.firstOrNull()
val isShort = PlayingQueue.getCurrent()?.isShort == true ||
(videoStream?.height ?: 0) > (videoStream?.width ?: 0)
(videoStream?.height ?: 0) > (videoStream?.width ?: 0)
Copy link
Member

Choose a reason for hiding this comment

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

Please undo that formatting change.

@@ -945,7 +950,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
if (binding.playerMotionLayout.progress != 1.0f) {
// show controllers when not in picture in picture mode
val inPipMode = PlayerHelper.pipEnabled &&
PictureInPictureCompat.isInPictureInPictureMode(requireActivity())
PictureInPictureCompat.isInPictureInPictureMode(requireActivity())
Copy link
Member

Choose a reason for hiding this comment

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

Please undo that formatting change.

@Bnyro
Copy link
Member

Bnyro commented Jan 26, 2024

Just some nitpick comments, the idea generally looks good to me 👍

Copy link
Member

@Bnyro Bnyro left a comment

Choose a reason for hiding this comment

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

Thank you!

@Bnyro Bnyro changed the title fix2: Clearing watch positions doesn't works sometimes fix: Clearing watch positions doesn't works sometimes Jan 26, 2024
@Bnyro Bnyro changed the title fix: Clearing watch positions doesn't works sometimes fix: clearing watch positions doesn't works sometimes Jan 26, 2024
@Bnyro Bnyro merged commit 9fc80a2 into libre-tube:master Jan 26, 2024
3 of 4 checks passed
Copy link
Contributor Author

@manish99verma manish99verma left a comment

Choose a reason for hiding this comment

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

Sorry for making those silly mistakes.
Your suggestions really helps me to improve my code style.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants