⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 278850 in webkit


Ignore:
Timestamp:
Jun 14, 2021, 3:04:59 PM (5 years ago)
Author:
Devin Rousso
Message:

[macOS] TouchBar playback speed controls don't work
https://bugs.webkit.org/show_bug.cgi?id=226987
<rdar://problem/79216098>

Reviewed by Eric Carlson.

Override setRate: and setDefaultPlaybackRate: instead of just having an ivar so that
TouchBar playback speed controls actually affect the corresponding <video>.

  • platform/mac/WebPlaybackControlsManager.mm:

(-[WebPlaybackControlsManager defaultPlaybackRate]): Added.
(-[WebPlaybackControlsManager setDefaultPlaybackRate:]): Added.
(-[WebPlaybackControlsManager rate]): Added.
(-[WebPlaybackControlsManager setRate:]): Added.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r278849 r278850  
     12021-06-14  Devin Rousso  <drousso@apple.com>
     2
     3        [macOS] TouchBar playback speed controls don't work
     4        https://bugs.webkit.org/show_bug.cgi?id=226987
     5        <rdar://problem/79216098>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Override `setRate:` and `setDefaultPlaybackRate:` instead of just having an ivar so that
     10        TouchBar playback speed controls actually affect the corresponding `<video>`.
     11
     12        * platform/mac/WebPlaybackControlsManager.mm:
     13        (-[WebPlaybackControlsManager defaultPlaybackRate]): Added.
     14        (-[WebPlaybackControlsManager setDefaultPlaybackRate:]): Added.
     15        (-[WebPlaybackControlsManager rate]): Added.
     16        (-[WebPlaybackControlsManager setRate:]): Added.
     17
    1182021-06-14  Alex Christensen  <achristensen@webkit.org>
    219
  • trunk/Source/WebCore/platform/mac/WebPlaybackControlsManager.mm

    r275176 r278850  
    4949@synthesize hasEnabledAudio = _hasEnabledAudio;
    5050@synthesize hasEnabledVideo = _hasEnabledVideo;
    51 @synthesize defaultPlaybackRate = _defaultPlaybackRate;
    52 @synthesize rate = _rate;
    5351@synthesize canTogglePlayback = _canTogglePlayback;
    5452@synthesize allowsPictureInPicturePlayback;
     
    332330}
    333331
     332- (double)defaultPlaybackRate
     333{
     334    return _defaultPlaybackRate;
     335}
     336
     337- (void)setDefaultPlaybackRate:(double)defaultPlaybackRate
     338{
     339    if (defaultPlaybackRate == _defaultPlaybackRate)
     340        return;
     341
     342    _defaultPlaybackRate = defaultPlaybackRate;
     343
     344    if (_playbackSessionInterfaceMac) {
     345        if (auto* model = _playbackSessionInterfaceMac->playbackSessionModel(); model && model->defaultPlaybackRate() != _defaultPlaybackRate)
     346            model->setDefaultPlaybackRate(_defaultPlaybackRate);
     347    }
     348
     349    if ([self isPlaying])
     350        [self setRate:_defaultPlaybackRate];
     351}
     352
     353- (float)rate
     354{
     355    return _rate;
     356}
     357
     358- (void)setRate:(float)rate
     359{
     360    if (rate == _rate)
     361        return;
     362
     363    _rate = rate;
     364
     365    // AVKit doesn't have a separate variable for "paused", instead representing it by a `rate` of
     366    // `0`. Unfortunately, `HTMLMediaElement::play` doesn't call `HTMLMediaElement::setPlaybackRate`
     367    // so if we propagate a `rate` of `0` along to the `HTMLMediaElement` then any attempt to
     368    // `HTMLMediaElement::play` will effectively be a no-op since the `playbackRate` will be `0`.
     369    if (!_rate)
     370        return;
     371
     372    // In AVKit, the `defaultPlaybackRate` is used when playback starts, such as resuming after
     373    // pausing. In WebKit, however, `defaultPlaybackRate` is only used when first loading and after
     374    // ending scanning, with the `playbackRate` being used in all other cases, including when
     375    // resuming after pausing. As such, WebKit should return the `playbackRate` instead of the
     376    // `defaultPlaybackRate` in these cases when communicating with AVKit.
     377    [self setDefaultPlaybackRate:_rate];
     378
     379    if (_playbackSessionInterfaceMac) {
     380        if (auto* model = _playbackSessionInterfaceMac->playbackSessionModel(); model && model->playbackRate() != _rate)
     381            model->setPlaybackRate(_rate);
     382    }
     383}
     384
    334385- (void)togglePictureInPicture
    335386{
Note: See TracChangeset for help on using the changeset viewer.