Changeset 211687 in webkit


Ignore:
Timestamp:
Feb 5, 2017 12:55:21 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

[Modern Media Controls] PiP button is not visible with a live broadcast video
https://bugs.webkit.org/show_bug.cgi?id=167794
<rdar://problem/30348790>

Patch by Antoine Quint <Antoine Quint> on 2017-02-05
Reviewed by Dean Jackson.

Source/WebCore:

We were only listening to the "loadedmetadata", "error", "webkitpresentationmodechanged"
and "webkitcurrentplaybacktargetiswirelesschanged" events to invalidate the enabled state
for the PiP button. We also need to check availability of video tracks, which we already
did for fullscreen, which is quite similar.

So we now listen to "addtrack", "removetrack" and "change" events on the media.videoTracks
property, which correctly invalidates the PiP button when the first video track becomes
available or the last video track is removed.

Since a couple of other MediaControllerSupport subclasses (FullscreenSupport and TracksSupport)
would also listen to those events on various track types, we add a new "tracksToMonitor"
property on MediaControllerSupport which subclasses can override to provide a list of tracks
that should listen to those events. This removes the need for dedicated construction and
destruction time in MediaControllerSupport subclasses that need to listen to events on
tracks rather than the media itself.

Test: http/tests/media/modern-media-controls/pip-support/pip-support-live-broadcast.html

  • Modules/modern-media-controls/media/fullscreen-support.js:

(FullscreenSupport):
(FullscreenSupport.prototype.get tracksToMonitor):
(FullscreenSupport.prototype.destroy): Deleted.

  • Modules/modern-media-controls/media/media-controller-support.js:

(MediaControllerSupport):
(MediaControllerSupport.prototype.destroy):
(MediaControllerSupport.prototype.get tracksToMonitor):

  • Modules/modern-media-controls/media/pip-support.js:

(PiPSupport.prototype.get tracksToMonitor):

  • Modules/modern-media-controls/media/tracks-support.js:

(TracksSupport):
(TracksSupport.prototype.get tracksToMonitor):
(TracksSupport.prototype.destroy): Deleted.

LayoutTests:

Add a new test to check that a live broadcast video shows the picture-in-picture button.

  • http/tests/media/modern-media-controls/pip-support/pip-support-live-broadcast-expected.txt: Added.
  • http/tests/media/modern-media-controls/pip-support/pip-support-live-broadcast.html: Added.
  • platform/mac/TestExpectations:
Location:
trunk
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r211685 r211687  
     12017-02-05  Antoine Quint  <graouts@apple.com>
     2
     3        [Modern Media Controls] PiP button is not visible with a live broadcast video
     4        https://bugs.webkit.org/show_bug.cgi?id=167794
     5        <rdar://problem/30348790>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Add a new test to check that a live broadcast video shows the picture-in-picture button.
     10
     11        * http/tests/media/modern-media-controls/pip-support/pip-support-live-broadcast-expected.txt: Added.
     12        * http/tests/media/modern-media-controls/pip-support/pip-support-live-broadcast.html: Added.
     13        * platform/mac/TestExpectations:
     14
    1152017-02-05  Antoine Quint  <graouts@apple.com>
    216
  • trunk/LayoutTests/platform/mac/TestExpectations

    r211650 r211687  
    14581458# picture-in-picture is not supported prior to Sierra.
    14591459[ ElCapitan ] media/modern-media-controls/pip-support [ Skip ]
     1460[ ElCapitan ] http/tests/media/modern-media-controls/pip-support [ Skip ]
    14601461[ ElCapitan ] media/modern-media-controls/media-controller/media-controller-inline-to-fullscreen-to-pip-to-inline.html [ Skip ]
    14611462[ ElCapitan ] media/modern-media-controls/placard-support/placard-support-pip.html [ Skip ]
  • trunk/Source/WebCore/ChangeLog

    r211685 r211687  
     12017-02-05  Antoine Quint  <graouts@apple.com>
     2
     3        [Modern Media Controls] PiP button is not visible with a live broadcast video
     4        https://bugs.webkit.org/show_bug.cgi?id=167794
     5        <rdar://problem/30348790>
     6
     7        Reviewed by Dean Jackson.
     8
     9        We were only listening to the "loadedmetadata", "error", "webkitpresentationmodechanged"
     10        and "webkitcurrentplaybacktargetiswirelesschanged" events to invalidate the enabled state
     11        for the PiP button. We also need to check availability of video tracks, which we already
     12        did for fullscreen, which is quite similar.
     13       
     14        So we now listen to "addtrack", "removetrack" and "change" events on the media.videoTracks
     15        property, which correctly invalidates the PiP button when the first video track becomes
     16        available or the last video track is removed.
     17
     18        Since a couple of other MediaControllerSupport subclasses (FullscreenSupport and TracksSupport)
     19        would also listen to those events on various track types, we add a new "tracksToMonitor"
     20        property on MediaControllerSupport which subclasses can override to provide a list of tracks
     21        that should listen to those events. This removes the need for dedicated construction and
     22        destruction time in MediaControllerSupport subclasses that need to listen to events on
     23        tracks rather than the media itself.
     24
     25        Test: http/tests/media/modern-media-controls/pip-support/pip-support-live-broadcast.html
     26
     27        * Modules/modern-media-controls/media/fullscreen-support.js:
     28        (FullscreenSupport):
     29        (FullscreenSupport.prototype.get tracksToMonitor):
     30        (FullscreenSupport.prototype.destroy): Deleted.
     31        * Modules/modern-media-controls/media/media-controller-support.js:
     32        (MediaControllerSupport):
     33        (MediaControllerSupport.prototype.destroy):
     34        (MediaControllerSupport.prototype.get tracksToMonitor):
     35        * Modules/modern-media-controls/media/pip-support.js:
     36        (PiPSupport.prototype.get tracksToMonitor):
     37        * Modules/modern-media-controls/media/tracks-support.js:
     38        (TracksSupport):
     39        (TracksSupport.prototype.get tracksToMonitor):
     40        (TracksSupport.prototype.destroy): Deleted.
     41
    1422017-02-05  Antoine Quint  <graouts@apple.com>
    243
  • trunk/Source/WebCore/Modules/modern-media-controls/media/fullscreen-support.js

    r209451 r211687  
    3333        if (mediaController.controls instanceof IOSInlineMediaControls)
    3434            mediaController.controls.delegate = this;
    35 
    36         const videoTracks = mediaController.media.videoTracks;
    37         for (let eventType of ["change", "addtrack", "removetrack"])
    38             videoTracks.addEventListener(eventType, this);
    39     }
    40 
    41     // Public
    42 
    43     destroy()
    44     {
    45         super.destroy();
    46 
    47         const videoTracks = this.mediaController.media.videoTracks;
    48         for (let eventType of ["change", "addtrack", "removetrack"])
    49             videoTracks.removeEventListener(eventType, this);
    5035    }
    5136
     
    6045    {
    6146        return ["loadedmetadata", "error"];
     47    }
     48
     49    get tracksToMonitor()
     50    {
     51        return [this.mediaController.media.videoTracks];
    6252    }
    6353
  • trunk/Source/WebCore/Modules/modern-media-controls/media/media-controller-support.js

    r209451 r211687  
    3434            mediaController.media.addEventListener(eventType, this);
    3535
     36        for (let tracks of this.tracksToMonitor) {
     37            for (let eventType of ["change", "addtrack", "removetrack"])
     38                tracks.addEventListener(eventType, this);
     39        }
     40
    3641        if (!this.control)
    3742            return;
     
    5055            media.removeEventListener(eventType, this);
    5156
     57        for (let tracks of this.tracksToMonitor) {
     58            for (let eventType of ["change", "addtrack", "removetrack"])
     59                tracks.removeEventListener(eventType, this);
     60        }
     61
    5262        if (this.control)
    5363            this.control.uiDelegate = null;
     
    6272
    6373    get mediaEvents()
     74    {
     75        // Implemented by subclasses.
     76        return [];
     77    }
     78
     79    get tracksToMonitor()
    6480    {
    6581        // Implemented by subclasses.
  • trunk/Source/WebCore/Modules/modern-media-controls/media/pip-support.js

    r210959 r211687  
    4242    }
    4343
     44    get tracksToMonitor()
     45    {
     46        return [this.mediaController.media.videoTracks];
     47    }
     48
    4449    buttonWasPressed(control)
    4550    {
  • trunk/Source/WebCore/Modules/modern-media-controls/media/tracks-support.js

    r209451 r211687  
    3636        this.mediaController.controls.tracksPanel.dataSource = this;
    3737        this.mediaController.controls.tracksPanel.uiDelegate = this;
    38 
    39         const media = mediaController.media;
    40         for (let tracks of [media.audioTracks, media.textTracks]) {
    41             for (let eventType of ["addtrack", "change", "removetrack"])
    42                 tracks.addEventListener(eventType, this);
    43         }
    44     }
    45 
    46     // Public
    47 
    48     destroy()
    49     {
    50         super.destroy();
    51 
    52         const media = this.mediaController.media;
    53         for (let tracks of [media.audioTracks, media.textTracks]) {
    54             for (let eventType of ["addtrack", "change", "removetrack"])
    55                 tracks.removeEventListener(eventType, this);
    56         }
    5738    }
    5839
     
    6748    {
    6849        return ["loadedmetadata"];
     50    }
     51
     52    get tracksToMonitor()
     53    {
     54        return [this.mediaController.media.audioTracks, this.mediaController.media.textTracks];
    6955    }
    7056
Note: See TracChangeset for help on using the changeset viewer.