[webkit-changes] [WebKit/WebKit] 537043: Don't allow playback to start when in the backgrou...

Eric Carlson noreply at github.com
Sat Feb 10 20:39:18 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 537043c0738d31cf15247da8fe11c0e85838a1e5
      https://github.com/WebKit/WebKit/commit/537043c0738d31cf15247da8fe11c0e85838a1e5
  Author: Eric Carlson <eric.carlson at apple.com>
  Date:   2024-02-10 (Sat, 10 Feb 2024)

  Changed paths:
    A LayoutTests/media/video-playback-system-interruption-expected.txt
    A LayoutTests/media/video-playback-system-interruption.html
    M Source/WebCore/html/HTMLMediaElement.cpp
    M Source/WebCore/platform/audio/PlatformMediaSession.cpp
    M Source/WebCore/platform/audio/PlatformMediaSession.h
    M Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp
    M Source/WebCore/platform/audio/PlatformMediaSessionManager.h

  Log Message:
  -----------
  Don't allow playback to start when in the background and interrupted by the system
https://bugs.webkit.org/show_bug.cgi?id=269081
rdar://117928506

Reviewed by Jer Noble.

Don't allow playback to begin when WebKit is in the background and has also been interrupted
by the audio session. This can happen, for example, when playback is started from Control
Center on the lock screen and the user switches to the camera app and activates the video
camera. Allowing playback activates WebKit's AVAudioSession and prevents the camera app
from using the volume buttons to trigger start/stop recording.

* LayoutTests/media/video-playback-system-interruption-expected.txt: Added.
* LayoutTests/media/video-playback-system-interruption.html: Added.

* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::couldPlayIfEnoughData const): Return false if the element
needs an active audio session and it was paused by a system interruption.

* Source/WebCore/platform/audio/PlatformMediaSession.cpp: Keep a vector of interruption types
instead of an interruption count so we know the type of the most recent interruption.
(WebCore::PlatformMediaSession::interruptionType const): Return the type of the most recent
interruption, not the first.
(WebCore::PlatformMediaSession::beginInterruption): Update for interruption stack.
(WebCore::PlatformMediaSession::endInterruption): Ditto.
(WebCore::PlatformMediaSession::isPlayingToWirelessPlaybackTargetChanged): Can no longer
save and restore the interruption count, but the issue that caused the change appears to
have been fixed.
(WebCore::PlatformMediaSession::blockedBySystemInterruption const):
* Source/WebCore/platform/audio/PlatformMediaSession.h:
(WebCore::PlatformMediaSession::interruptionCount const):
(WebCore::PlatformMediaSession::interruptionType const): Deleted.

Canonical link: https://commits.webkit.org/274438@main




More information about the webkit-changes mailing list