Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Autoplay muted videos stop playback of any streaming app in the backg…
…round https://bugs.webkit.org/show_bug.cgi?id=163993 <rdar://problem/29020431> Reviewed by Eric Carlson. Source/WebCore: Added test in TestWebKitAPI, WebKit1.AudioSessionCategoryIOS. Previously, we would set the audio session category to "playback" if there was a media- element-type media session, and if there was a session capable of playing audio. But because this was an "or" operation, we would incorrectly set the category to "playback" if there was a video element incapable of rendering audio (due to being muted, without an audio track, etc.), and also a session capable of producing audio, such as WebAudio. With this change, this turns into an "and" operation; there must be a media element capable of rendering audio in order to switch the audio session category to "playback". Additionally, we no longer cache the value of "canProduceAudio()"; it's queried directly whenever updateSessionState() is called. * Modules/webaudio/AudioContext.cpp: (WebCore::AudioContext::constructCommon): * Modules/webaudio/AudioContext.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::insertedInto): (WebCore::HTMLMediaElement::loadResource): (WebCore::HTMLMediaElement::setMuted): (WebCore::HTMLMediaElement::mediaPlayerCurrentPlaybackTargetIsWirelessChanged): (WebCore::HTMLMediaElement::mediaPlayerCharacteristicChanged): (WebCore::HTMLMediaElement::clearMediaPlayer): (WebCore::HTMLMediaElement::mediaPlayerCurrentPlaybackTargetIsWirelessChanged): (WebCore::HTMLMediaElement::presentationType): (WebCore::HTMLMediaElement::characteristics): (WebCore::HTMLMediaElement::canProduceAudio): * html/HTMLMediaElement.h: * platform/audio/PlatformMediaSession.cpp: (WebCore::PlatformMediaSession::activeAudioSessionRequired): (WebCore::PlatformMediaSession::canProduceAudio): (WebCore::PlatformMediaSession::canProduceAudioChanged): (WebCore::PlatformMediaSession::setCanProduceAudio): Deleted. * platform/audio/PlatformMediaSession.h: (WebCore::PlatformMediaSessionClient::canProduceAudio): (WebCore::PlatformMediaSession::canProduceAudio): Deleted. * platform/audio/cocoa/MediaSessionManagerCocoa.cpp: (PlatformMediaSessionManager::updateSessionState): Tools: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WebKit/ios/AudioSessionCategoryIOS.mm: (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WebKit/ios/video-with-muted-audio-and-webaudio.html: Added. Canonical link: https://commits.webkit.org/184516@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211240 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
12 changed files
with
150 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,31 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script> | ||
function go() { | ||
var audioContext = new webkitAudioContext(); | ||
audioContext.resume(); | ||
|
||
var video = document.getElementsByTagName('video')[0]; | ||
video.play().then(playing).catch(notPlaying); | ||
} | ||
|
||
function playing() { | ||
try { | ||
window.webkit.messageHandlers.testHandler.postMessage('playing'); | ||
} catch(e) { | ||
window.location = 'callback:playing'; | ||
} | ||
} | ||
|
||
function notPlaying() { | ||
try { | ||
window.webkit.messageHandlers.testHandler.postMessage('not playing'); | ||
} catch(e) { } | ||
} | ||
</script> | ||
</head> | ||
<body onload="go()"> | ||
<video src="video-with-audio.mp4" muted webkit-playsinline></video> | ||
</body> | ||
</html> |