<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>172051</bug_id>
          
          <creation_ts>2017-05-12 14:27:32 -0700</creation_ts>
          <short_desc>`webkitSetPresentationMode(&apos;picture-in-picture&apos;);` (PiP) not working on multiple video sources</short_desc>
          <delta_ts>2022-02-12 23:33:29 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Media</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>macOS 10.12</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Kurt Zenisek">KZeni1</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>eric.carlson</cc>
    
    <cc>jer.noble</cc>
    
    <cc>KZeni1</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1308062</commentid>
    <comment_count>0</comment_count>
    <who name="Kurt Zenisek">KZeni1</who>
    <bug_when>2017-05-12 14:27:32 -0700</bug_when>
    <thetext>Checking YouTube (which uses blob: for their videos now) shows that you can use `document.getElementsByTagName(&apos;video&apos;)[0];` in Safari&apos;s console on a video player page to obtain the correct video element without issue. However, using `document.getElementsByTagName(&apos;video&apos;)[0].webkitSetPresentationMode(&apos;picture-in-picture&apos;);` at that point returns &quot;undefined&quot; and the video is not turned into a Picture-in-Picture (PiP).

Meanwhile right-clicking the YouTube video player (to get the context menu for the video element to show) is able to turn the video into a Picture-in-Picture without issue. I&apos;m guessing there&apos;s a bug when it comes to the `webkitSetPresentationMode(&apos;picture-in-picture&apos;);` command being executed on video elements with a `blob:` url as it&apos;s source.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1308065</commentid>
    <comment_count>1</comment_count>
    <who name="Kurt Zenisek">KZeni1</who>
    <bug_when>2017-05-12 14:31:50 -0700</bug_when>
    <thetext>Also, it appears that using `document.getElementsByTagName(&apos;video&apos;)[0].webkitSetPresentationMode(&apos;inline&apos;);` _works_ on a YouTube video (if you were to make it a PiP via the video element&apos;s context menu) whereas `document.getElementsByTagName(&apos;video&apos;)[0].webkitSetPresentationMode(&apos;picture-in-picture&apos;);` does not work (even if you execute this immediately after the inline command worked.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1308072</commentid>
    <comment_count>2</comment_count>
    <who name="Kurt Zenisek">KZeni1</who>
    <bug_when>2017-05-12 14:49:22 -0700</bug_when>
    <thetext>Finally, it appears that the use of a `javascript:document.getElementsByTagName(&apos;video&apos;)[0].webkitSetPresentationMode(&apos;picture-in-picture&apos;);` bookmarklet does work while running `document.getElementsByTagName(&apos;video&apos;)[0].webkitSetPresentationMode(&apos;picture-in-picture&apos;);` directly from Safari&apos;s console does not.

Oddly enough, the use of `document.getElementsByTagName(&apos;video&apos;)[0].webkitSetPresentationMode(&apos;picture-in-picture&apos;);` directly in the console starts working after you have used the `javascript:document.getElementsByTagName(&apos;video&apos;)[0].webkitSetPresentationMode(&apos;picture-in-picture&apos;);` bookmarklet.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1308074</commentid>
    <comment_count>3</comment_count>
    <who name="Kurt Zenisek">KZeni1</who>
    <bug_when>2017-05-12 14:56:18 -0700</bug_when>
    <thetext>Triggering a PiP shouldn&apos;t require a bookmarklet or using the context menu of the video element while using the webkitSetPresentationMode(&apos;picture-in-picture&apos;); command directly via the browser&apos;s JavaScript (be it an extension or via the browser&apos;s console) does not work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1308086</commentid>
    <comment_count>4</comment_count>
    <who name="Kurt Zenisek">KZeni1</who>
    <bug_when>2017-05-12 15:06:05 -0700</bug_when>
    <thetext>I just tested a non-blob URL, and it appears this issue isn&apos;t just restricted to `blob:` video sources.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1309459</commentid>
    <comment_count>5</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2017-05-16 20:16:27 -0700</bug_when>
    <thetext>&lt;rdar://problem/32239548&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1840961</commentid>
    <comment_count>6</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2022-02-12 23:33:29 -0800</bug_when>
    <thetext>Fullscreen and Picture in picture require a user gesture. Commands run from the web inspector don’t simulate a user gesture while running.

The user-gesture requirement is removed after entering fullscreen on an element.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>