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

Play next/prev video after removing current video from the playlist #5158

Conversation

kommunarr
Copy link
Collaborator

@kommunarr kommunarr commented May 22, 2024

Play next/prev video after removing current video from the playlist

Pull Request Type

  • Feature Implementation

Related issue

closes #4918

Description

When you delete the video that is shown as being currently watched in watch-video-playlist, the video index will now visually appear to be the video prior to that one. if you delete that one, it carries on the video prior, and so forth. When the video autoplays or you click Play Next Video in this state, it plays the video that is shown as the one after the current video. When you click Play Previous Video in this state, it plays the video that is shown as the "current" video. (Edit 2024-05-31) If the current video cannot be found in the user playlist at all, e.g., removing it while watching it & reloading the page, the index becomes the 1st video in the playlist, preventing the glitchy "0/x videos" state from ever occurring. These are all existing behaviors of YT.

Note that if you were to navigate back to the previous route for a deleted playlist entry through the Back button, the current video index will be set to zero, as this feature is reset when you navigate to a new route. This pre-existing behavior is fine, and making this more "durable" is not worth the effort. Believe me, I've tried.

Screenshots

Screenshot_20240522_150833

Testing

  1. Test that removing the current video in the playlist will have the play icon in watch-video-playlist update to the prior video
    A. Test Play Previous Video plays the video with the same index as the video with the play icon
    B. Test Play Next Video and autoplay plays the video with index one higher than the video with the play icon
  2. Test that removing the current video in the playlist will have the play icon in watch-video-playlist update to the prior video, then delete that one. See that the play icon then goes the video prior to that.
    A. (Optional) Repeat validations 1A and 1B in this state.
  3. (Optional) Test 1 with Shuffle and/or Reverse enabled

Desktop

  • OS: OpenSUSE
  • OS Version: TW

Additional context

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) May 22, 2024 21:17
@github-actions github-actions bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label May 22, 2024
PikachuEXE
PikachuEXE previously approved these changes May 23, 2024
absidue
absidue previously approved these changes May 25, 2024
Copy link
Member

Choose a reason for hiding this comment

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

Something is going wrong here: When loop is enabled it will skip a video

VirtualBoxVM_QRsYYT01CW.mp4

@kommunarr kommunarr dismissed stale reviews from absidue and PikachuEXE via 7e398a8 May 30, 2024 00:36
@kommunarr
Copy link
Collaborator Author

Excellent catch John, we are very lucky to have someone with such great testing skills & discipline!

PikachuEXE
PikachuEXE previously approved these changes May 30, 2024
Copy link
Member

Choose a reason for hiding this comment

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

Found another one

VirtualBoxVM_XhUkrcovrp.mp4

@kommunarr
Copy link
Collaborator Author

@efb4f5ff-1298-471a-8973-3d47447115dc Could you share what you did before this? From the logs, it seems like somehow a null entry got into randomizedPlaylistItems.

@efb4f5ff-1298-471a-8973-3d47447115dc
Copy link
Member

efb4f5ff-1298-471a-8973-3d47447115dc commented May 31, 2024

This is all i did

VirtualBoxVM_pzRc1vEla3.mp4

@kommunarr
Copy link
Collaborator Author

kommunarr commented May 31, 2024

Thanks @efb4f5ff-1298-471a-8973-3d47447115dc, fixed now.

Here's one thing I added:

  • When no video is found in the user playlist (e.g., reloading the page after the current video has already been removed from the playlist), have the "current" default to the first video (instead of showing as a glitched 0 / x videos state)

Here's one thing I gave up on adding:

  • Having the video index "become" the current video if it's removed and then re-added. It's a somewhat marginal case, and I don't know if it's actually feasible/sensible in the case of duplicates existing.

@kommunarr kommunarr force-pushed the feat/play-next-or-prev-from-deleted branch from cd9d91b to 9d71186 Compare May 31, 2024 11:15
@efb4f5ff-1298-471a-8973-3d47447115dc
  1. Turn shuffle on
  2. Remove current playing video
  3. click on play next video button
  4. see that random video is selected which is expected because shuffle is turned on
  5. repeat 2
  6. click on play previous video button
  7. see that the actual previous video is being played which is unexpected

@kommunarr
Copy link
Collaborator Author

Thank you and great catches, I admittedly would never have caught these last two. I think it's all good now knock on wood

@efb4f5ff-1298-471a-8973-3d47447115dc

Removed video spawns back in?

VirtualBoxVM_U5A7sv2Y4J.mp4

@kommunarr
Copy link
Collaborator Author

kommunarr commented Jun 1, 2024

Still looking into this one. I think I'm going to be fixing bugs with this PR until I die

Edit: thankfully this was an obvious error from my part, now things seem good

@kommunarr kommunarr force-pushed the feat/play-next-or-prev-from-deleted branch from 379e62e to 4f37130 Compare June 1, 2024 14:01
Copy link
Collaborator

@PikachuEXE PikachuEXE left a comment

Choose a reason for hiding this comment

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

Non-blocking comments only so I only wish I spot them earlier next time

@@ -232,6 +216,23 @@ export default defineComponent({
}
},
methods: {
findIndexOfCurrentVideoInPlaylist: function (playlist) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: this should be videos / playlistItems
findIndexOfCurrentVideoInPlaylist is called with various source of video lists (with different sorting orders applied)

Comment on lines +490 to +491
const isCurrentVideoInParsedPlaylist = this.findIndexOfCurrentVideoInPlaylist(playlist.videos) !== -1
if (!isCurrentVideoInParsedPlaylist) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why use double negative here... (and below)

@FreeTubeBot FreeTubeBot merged commit 51666b5 into FreeTubeApp:development Jun 6, 2024
5 checks passed
@github-actions github-actions bot removed the PR: waiting for review For PRs that are complete, tested, and ready for review label Jun 6, 2024
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.

[Feature Request]: Play next/prev video after removing current video from the playlist
5 participants