Open omegasome opened 9 months ago
TODO: Test if it works in chrome, edge, mobile, etc.
If for whatever reason @ubershmekel is opposed to this supporting the userscript I can take it out; it can still work for vanilla gfy embeds with the src blanking/restoring logic.
Also I'm completely new to open source contributions so if I'm committing any faux pas by opening multiple PRs or anything then... uh... sorry.
Simple enough change; adds an
eventListener
for avisibilitychange
. If the user just left the current tab, then (a) checks if auto-next is on, and if so, clears the timeout, and (b) pauses any current video playing. When the user returns to the tab, it (a) checks if auto-next is on, and if so, resets the timeout, and (b) resumes any current video playing.It can even pause/resume gfycat-style iframes; it accomplishes this two ways.
First, it checks if the custom userscript I made is present. If it is, it can just send an appropriate play or pause signal to the iframe and the userscript will obey.
If it isn't, then it "pauses" by blanking out the
src
attribute and "plays" by restoring it. This does mean that, in this case, state such as place in the video and whether audio is on is lost, but since gfycat-style vids tend to be pretty short, and enabling/disabling audio is already pretty finicky, I think that's a fair tradeoff.TODO: All this behavior is controlled by
rp.settings.pauseOnTabAway
, which is set totrue
by default. I have not yet added a way for the user to change it; looking for feedback from the community.