Picture-in-Picture Shortcut
-
A keyboard shortcut for Picture-in-Picture would be handsome imo. Or is there a workaround to achieve this?
As I hardly use the mouse it's a bit annoying to leave the keyboard only to activate PiP.
-
-
Thanks for your suggestion. I'm not using Windows and wouldn't consider this solution as it is not how it supposed to be done imo.
-
You could create a quick command and have it open a link in the current tab. The link to open would be a bookmarklet that activates PiP - like this one [there are plenty online, if that one doesn't work for you]
Then you can set a keyboard shortcut for that quick command.
Alternatively you can install an extension like this one. Then type in vivaldi://extensions, click the three lines, and click shortcuts. You would have to make sure the shortcut is a global shortcut because of a Vivaldi bug.
-
@legobuilder26
Thank you for your reply. Quick Commands also crossed my mind thinking about this. But I'm not sure how to set this up. How is it possible to save a link which opens PiP? An extra Extension is not an option for me. -
@rauldux Go to settings, click quick commands, scroll down and add a new command chain. This command chain will consist of only one command: open link in current tab. The link to open will be javascript code. You can find other code online, or use this:
javascript:(function()%7B%5Bdocument%2C...%5B...document.querySelectorAll(%22iframe%22)%5D.map(iframe%20%3D%3E%20iframe.contentDocument).filter(iframe%20%3D%3E%20!!iframe)%5D.some(d%20%3D%3E%5B...d.querySelectorAll(%22video%22)%5D.filter(video%20%3D%3E%20video.paused%20%3D%3D%20false%20%26%26%20video.ended%20%3D%3D%20false).some(video%20%3D%3E%20!!video.requestPictureInPicture().catch(err%20%3D%3E%20console.log(err))))%7D)()
Then you can go to keyboard settings and assign a keyboard shortcut [under command chains]
-
Works perfect. Thank you for the script and your detailed instruction. Would it be possible to toggle it back to the website once opend in PiP?
-
@rauldux If that script doesn't do it, than I would Alt-Tab to the PiP window and then use Alt-F4. There might be another script that can do that
Update - looks like the below script works on more sites and will close the PiP.
javascript:if(%22pictureInPictureEnabled%22in%20document&&%22querySelectorAll%22in%20document)%7B(async%20function()%7Bconst%20a=document.querySelectorAll(%22video%22);if(0===a.length)window.alert(%22Sorry,%20no%20videos%20on%20the%20page.%22);else%20if(0%3Ca.length)%7Bconst%20b=a%5B0%5D;try%7Bb===document.pictureInPictureElement?await%20document.exitPictureInPicture():await%20b.requestPictureInPicture()%7Dcatch(a)%7Bconsole.error(a)%7D%7D%7D)()%7Delse%22pictureInPictureEnabled%22in%20document?document.pictureInPictureEnabled%7C%7Cwindow.alert(%22Picture-in-Picture%20not%20available.%22):window.alert(%22Picture-in-Picture%20is%20disabled.%22);
Just go back to the Command Chain settings and change the script that it opens to this.
-
@legobuilder26 That works, thanks again.
-
Oh wow, thank you so much! I have 3 Windows PCs with Vivaldi installed and only one of them can trigger Picture-in-picture properly through a shortcut with a Google-made PiP extension. This script works great on youtube.