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

Picture-in-picture - Returning to normal player after changing tab #966

Closed
Jimmymax297 opened this issue Jan 21, 2021 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@Jimmymax297
Copy link

Behavior of the program
When User tries to come back to normal player with picture-in-picture player is opened after changing tab the player is in the background.

Expected behavior
Application should return to normal player even if User changed tabs with picture-in-picture player is opened.

Preconditions

  • User has videos in their Subscriptions tab

To Reproduce
Please add all steps to reproduce the behavior:

  1. User watches any video from their Subscriptions
  2. User clicks on the player bar to change to picture-in-picture player
  3. User changes the tab of the application, e.g. clicks on Subscriptions
  4. User clicks on the picture-in-picture player to return to the normal player
  5. See issue

Environment Information (please complete the following information):

  • OS: [Windows]
  • OS Version: [Windows 10]
  • FreeTube version: [0.11.1]
  • Primary API Used: [Local API]
@Jimmymax297 Jimmymax297 added the bug Something isn't working label Jan 21, 2021
@PrestonN
Copy link
Member

This is working as intended and was recently talked about in our Matrix channel. FreeTube is not able to differentiate between the user clicking on the "Close" button and the "Back to video player" button if you are on a different page. Because of this, we have no way of identifying the user's intention when PiP is closed. If we forced FreeTube to always navigate back to that video, then it would more than likely not be the user's intention. It's always possible the user simply wanted to stop watching the video. Because of this, closing the video is the better option and will not be changed.

@Jimmymax297
Copy link
Author

@PrestonN I understand your reasoning here, but you are expecting user to remember that if they changed the tab while having PiP opened when they they can only close it. The main issue here is that the player is somewhere in the background and still playing, only closing the app can close this player or waiting for it to end playback.

@PrestonN
Copy link
Member

The issue you're mentioning is something that I believe should be fixed in the latest nightly builds. There is logic that prevents the PiP video from playing in the background and there was a bug where this logic wouldn't run if your history is disabled. If you do keep history enabled and you're still experiencing this bug on the latest nightly builds, then please provide step by step instructions to reproduce and I will look into it.

@SebTota
Copy link
Contributor

SebTota commented May 8, 2021

I'm sorry for creating a PR before continuing this issue here.

I propose, and already created a PR for, a solution that will check if the video is currently paused or playing to determine if the PiP window should close or return to the regular video window.

This works because the underlying difference between the "Close" and "Back to video player" mode is that the "Close" button pauses the video before sending the "leavepictureinpicture" event. Therefore, we can just check if the video player is paused or not when the "leavepictureinpicture" event is triggered to determine if we should close the PiP window or close the PiP window and navigate back to the original video screen.

If the video is paused: Close PiP window
If the video is not paused: Close PiP window and re-navigate to the regular video window

The one down side to this is that if the video in the PiP window is paused and the user clicks the "Back to video player" button, the window close and not return to the original videos window. It will be closed as if the "Close" button is pressed, for the same reason as described above.

One other thing I added is to make sure the current video progress time of the PiP video is saved before closing the PiP window to make sure you resume in the regular video window where the PiP window left off. I think this is something that should be looked into further though because it seems that the progress of watching a video in PiP mode after navigating away from the video page is not tracked.

Let me know if this works or not and I can close the PR if this is not an implementation you want to add. Again, I apologize for not re-opening this issue before creating a PR.

To make sure all credit is given where it's due, the idea came from this stack-overflow post:
https://stackoverflow.com/questions/55991590/how-to-determine-type-of-leaving-picture-in-picture-mode

@GilgusMaximus
Copy link
Contributor

Wow, thanks for checking this out and finding a way to do this. Further discussion should be moved to the PR #1262
We'll probably all take a look at this in the next days, as there is quite some stuff going on for each of the teammebers atm. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants