iOS 14: Picture in Picture Not Working in YouTube? Here's a Workaround

by

In iOS 14, Apple added a Picture in Picture mode on iPhone that lets you watch a video in a small screen on your device while you continue to do other things on the phone.

YouTube Picture in Picture
Picture in Picture mode doesn't work in the YouTube app, although it was possible to watch videos in Picture in Picture on YouTube's mobile website through Safari until YouTube intentionally nixed the workaround last week, presumably to push people to buy a Premium subscription. For a short while, you could still get Picture in Picture to work on YouTube.com in Safari if you request the desktop site, but YouTube has since blocked that as well.

But thanks to CodeEverywhere, there's now another neat workaround that uses a snippet of JavaScript and no external plugins to suppress the Picture in Picture block that YouTube has added to its mobile site.

As noted by CodeEverywhere, the same code can also be used in an iOS Shortcut that can then be selected from Safari's Activity view (formerly called the Share Sheet) whenever you want to watch a YouTube-hosted video in Picture in Picture.

Using CodeEverywhere's script, software engineer Jonas Reitmann has since created a Shortcut and made it available for download (Note: people are having trouble with the direct download shortcut working. Follow the directions below), but if you are uncomfortable downloading a shortcut blindly, you can recreate it with the steps below.

How to Create a Shortcut for YouTube Picture in Picture

  1. Launch the Shortcuts app on your ‌iPhone‌ and click the plus (+) icon in the top-right corner of the screen to create a new shortcut.
    shortcuts

  2. Tap Add Action.
    shortcuts

  3. Select Web.
    shortcuts

  4. Under "Safari," select Run JavaScript on Web Page.
    shortcuts

  5. Where it says "Run JavaScript on" tap the blue words Web Page, then select Shortcut Input in the pop-up menu.
    shortcuts

  6. Remove the existing JavaScript code in the shortcut window and paste in the following code:
    let v = document.querySelector('video');

    v.addEventListener('webkitpresentationmodechanged', (e)=>e.stopPropagation(), true);

    setTimeout(()=>v.webkitSetPresentationMode('picture-in-picture'), 3000);

    completion()
    shortcuts

  7. Tap the three dots icon in the top-right corner of the screen.
    shortcuts

  8. Give your shortcut a name, e.g. "YouTube PiP," then toggle the switch next to Show in Share Sheet to the green ON position.
    shortcuts

  9. Tap Share Sheet Types, then select Deselect All and tap Safari web pages.
    shortcuts

  10. Return to the Details screen, then tap Done.
    shortcuts

  11. Tap Done to finish.
    shortcuts

With that done, simply select the Shortcut in Safari via the Action icon whenever you want to use Picture in Picture on YouTube's mobile website, no premium subscription required.

safari

Related Roundups: iOS 14, iPadOS 14

Top Stories

lg wing

LG Considering Exit From Smartphone Business, Halts LCD Production for iPhone

Wednesday January 20, 2021 5:38 am PST by
LG is considering exiting the smartphone business entirely amid declining shipments and accrued losses of $4.5 billion over the past five years (via The Korea Herald). LG CEO Kwon Bong-Seok cautioned staff earlier today that the company is re-evaluating its presence in the smartphone industry: Since the competition in the global market for mobile devices is getting fiercer, it is about...
google maps detailed street level e1611052089473

Google Maps Gains Enhanced Street-Level Detail in Four Major Cities

Tuesday January 19, 2021 2:34 am PST by
Google Maps has quietly been updated to include significantly more detailed street-level information in a handful of key cities around the world. Upon zooming in, Google's maps for Central London, Tokyo, San Francisco, and New York now benefit from shapes and widths that match the scale of roads more accurately. Meanwhile, enhanced graphical representations of sidewalks, crosswalks,...
2019 mac pro side and front

Tim Cook Gifted Donald Trump 'First' 2019 Mac Pro

Wednesday January 20, 2021 5:45 pm PST by
Apple CEO Tim Cook gifted former United States President Donald Trump with the first 2019 Mac Pro that came off of the assembly line in Austin, Texas, according to a financial disclosure report that was released today (via The Verge). "Mac Pro Computer, the first created at the Flex Factory in Austin, Texas," reads the entry, which values the machine at $5,999, the base price for a Mac Pro....
airpods max sim ejector

AirPods Max Headband Removable With Just a SIM Ejector Tool, Hinting at Interchangeable Headbands

Tuesday January 19, 2021 8:25 am PST by
It is possible to remove the headband of AirPods Max with just a standard SIM card ejector tool, hinting at the possibility of interchanging headbands to achieve a different colorway. Image via Prelook In December, MacRumors revealed the large variety of AirPods Max ear cushion color combinations when it became clear that they were magnetically attatched and available for sale separately....
iphone 5s black slate

Images of Unreleased iPhone 5s in Black and Slate Shared Online

Sunday January 17, 2021 9:47 am PST by
Twitter user @DongleBookPro has today shared images of a prototype iPhone 5s in an unreleased Black and Slate color. The iPhone 5s was launched in September 2013. The device featured Touch ID, a 64-bit processor, and a True Tone LED flash for the first time. Other new features included a five-element lens with an f/2.2 aperture, a 15 percent larger camera sensor, Burst Mode, and Slo-Mo...
iphone 12 vs iphone 12 mini

Apple Shifting Some Production From iPhone 12 mini to iPhone 12 Pro to Meet Demand

Wednesday January 20, 2021 8:12 am PST by
Apple has reportedly cut production of the iPhone 12 mini by two million units to create more manufacturing capacity for the iPhone 12 Pro, according to a new Morgan Stanley investment note seen by PED30. Apple is believed to have made the switch for the first quarter of 2021 in an effort to combat continuing lead times for the more popular iPhone 12 Pro. iPhone 12 Pro lead times remain ...
Apple VR Feature

Bloomberg: Apple's First AR/VR Headset 'Pricey, Niche Precursor' to More Ambitious AR Glasses and Could Launch Next Year

Thursday January 21, 2021 3:27 am PST by
Apple's first virtual reality headset will be a "pricey, niche precursor" to a more ambitious augmented reality product, according to a new report from Bloomberg's Mark Gurman. As a mostly virtual reality device, it will display an all-encompassing 3-D digital environment for gaming, watching video and communicating. AR functionality, the ability to overlay images and information over a view...
shot on iphone 12 apple

Apple Highlights Photos Shot by iPhone 12 Users: Portraits, Cityscapes, and More

Tuesday January 19, 2021 6:05 am PST by
Apple today shared a gallery of photos shot by customers using the iPhone 12 mini, iPhone 12, iPhone 12 Pro, and iPhone 12 Pro Max, with scenes including cityscapes, landscapes, portraits of people, and more at day and night. Shot on iPhone 12 Pro Max by "NKCHU" in China (top) and shot on iPhone 12 Pro Max by Rohit Vohra in India (bottom) iPhone 12 mini and iPhone 12 models have a dual camera ...
Apple and Hyundai feature

Apple Car Production Again Linked to Kia Motor's US Plant in Georgia

Tuesday January 19, 2021 4:19 am PST by
Hyundai intends to transition the company's Apple Car involvement to its Kia brand as part of an internal arrangement that could see production move to the U.S., according to a new report today. On Sunday, Korea IT News reported that Apple and Hyundai are seeking a partnership agreement for the upcoming Apple Car by March, and that the electric vehicles could be made at a Georgia factory...
iPhone 13 Notch Feature

iPhone 13 Rumored to Feature Smaller Notch, Pro Model Cameras to Use Larger Image Sensor

Thursday January 21, 2021 1:38 am PST by
Apple's iPhone 13 series will feature a redesigned Face ID system that will allow for a smaller notch at the top of the screen, according to a new report today. The rumor comes via hit-and-miss Taiwanese industry publication DigiTimes, whose supply chain sources also claim that the ultra wide-angle lens in Apple's next-generation iPhones is due for an upgrade. The next-generation iPhones'...