haikuwebkit/LayoutTests/media/video-concurrent-playback-e...

22 lines
443 B
Plaintext
Raw Permalink Normal View History

Allow MediaSessionManager to restrict media playback https://bugs.webkit.org/show_bug.cgi?id=126780 Reviewed by Jer Noble. Source/WebCore: Test: media/video-concurrent-playback.html * WebCore.exp.in: Export functions needed by Internals. Add HTMLMediaSession. * WebCore.xcodeproj/project.pbxproj: * CMakeLists.txt: * GNUmakefile.list.am: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.vcxproj/WebCore.vcxproj.filters: * WebCore.xcodeproj/project.pbxproj: Add a media session object to manage HTMLMediaElement restrictions. * html/HTMLMediaSession.cpp: Added. * html/HTMLMediaSession.h: Added. Move media restriction management to a MediaSession. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): Use the media session to manage restrictions. (WebCore::HTMLMediaElement::parseAttribute): Ditto. (WebCore::HTMLMediaElement::insertedInto): Ditto. (WebCore::HTMLMediaElement::parseAttribute): Ditto. (WebCore::HTMLMediaElement::loadInternal): Ditto. (WebCore::HTMLMediaElement::loadResource): Ditto. (WebCore::HTMLMediaElement::setReadyState): Ditto. (WebCore::HTMLMediaElement::autoplay): Ditto. (WebCore::HTMLMediaElement::play): Ditto. (WebCore::HTMLMediaElement::pause): Ditto (WebCore::HTMLMediaElement::pauseInternal): Ditto (WebCore::HTMLMediaElement::suspend): Ditto (WebCore::HTMLMediaElement::resume): Ditto. (WebCore::HTMLMediaElement::updatePlayState): Tell media session playback is about to start. (WebCore::HTMLMediaElement::deliverNotification): Ditto. (WebCore::HTMLMediaElement::webkitShowPlaybackTargetPicker): Ditto. (WebCore::HTMLMediaElement::mediaPlayerIsFullscreenPermitted): Ditto. (WebCore::HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture): Ditto. (WebCore::HTMLMediaElement::pausePlayback): New, allows the media session to pause playback. * html/HTMLMediaElement.h: * html/HTMLVideoElement.cpp: (WebCore::HTMLVideoElement::webkitEnterFullscreen): Use the media session to manage restrictions. * platform/audio/MediaSession.cpp: (WebCore::MediaSession::beginInterruption): Add logging. (WebCore::MediaSession::endInterruption): Ditto. (WebCore::MediaSession::pauseSession): New, allows the session manager to pause playback. * platform/audio/MediaSession.h: Add per-media type restrictions. * platform/audio/MediaSessionManager.cpp: (WebCore::MediaSessionManager::MediaSessionManager): Initialize restrictions. (WebCore::MediaSessionManager::addRestriction): New. (WebCore::MediaSessionManager::removeRestriction): New. (WebCore::MediaSessionManager::restrictions): New. (WebCore::MediaSessionManager::sessionWillBeginPlayback): New. If only one session if the same type is allowed to play, pause all others. * platform/audio/MediaSessionManager.h: * platform/audio/ios/MediaSessionManagerIOS.h: Added. * platform/audio/ios/MediaSessionManagerIOS.mm: Added. (WebCore::MediaSessionManager::sharedManager): (WebCore::m_objcObserver): (-[WebAVAudioSessionHelper initWithCallback:]): (-[WebAVAudioSessionHelper dealloc]): (-[WebAVAudioSessionHelper interruption:]): * platform/audio/mac/AudioDestinationMac.h: Add pausePlayback. Allow tests to set media session restrictions. * testing/Internals.cpp: * testing/Internals.h: * testing/Internals.idl: LayoutTests: * media/video-concurrent-playback-expected.txt: Added. * media/video-concurrent-playback.html: Added. Canonical link: https://commits.webkit.org/144896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161899 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-01-13 19:42:27 +00:00
Test play() when concurrent playback not allowed.
Allow multiple playing videos on a page with 'autoplay' and 'playsinline' attributes https://bugs.webkit.org/show_bug.cgi?id=162366 <rdar://problem/28639600> Reviewed by Eric Carlson. Source/WebCore: Tests: media/video-concurrent-visible-playback.html media/video-multiple-concurrent-playback.html Separate out the concept of "video-only" from "video-with-audio" in PlatformMediaSession::MediaType, and only set the ConcurrentPlaybackNotPermitted restriction for "video-with-audio". This allows multiple silent video elements to play back simultaneously. However, the bug in question also shows bad behavior when both concurrent playback and invisible playback are not allowed. Namely, an invisible element will attempt to autoplay, interrupt visible elements, and then fail to play due to it's non-visibility. Add an extra check to canTransitionFromAutoplayToPlay() which asks the session if autoplay is allowed (which will return false if the element is not visible). * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::canTransitionFromAutoplayToPlay): (WebCore::HTMLMediaElement::mediaType): (WebCore::HTMLMediaElement::presentationType): (WebCore::HTMLMediaElement::updateShouldAutoplay): (WebCore::mediaElementIsAllowedToAutoplay): Deleted. * html/MediaElementSession.cpp: (WebCore::MediaElementSession::autoplayPermitted): * html/MediaElementSession.h: * platform/audio/PlatformMediaSession.h: * platform/audio/ios/MediaSessionManagerIOS.mm: (WebCore::MediaSessionManageriOS::resetRestrictions): * testing/Internals.cpp: (WebCore::Internals::setMediaSessionRestrictions): LayoutTests: * media/content/test-video-only.mp4: Added. * media/non-existent-video-playback-interrupted-expected.txt: * media/non-existent-video-playback-interrupted.html: * media/video-background-playback-expected.txt: * media/video-background-playback.html: * media/video-background-tab-playback-expected.txt: * media/video-background-tab-playback.html: * media/video-concurrent-playback-expected.txt: * media/video-concurrent-playback.html: * media/video-concurrent-visible-playback-expected.txt: Added. * media/video-concurrent-visible-playback.html: Added. * media/video-multiple-concurrent-playback-expected.txt: Added. * media/video-multiple-concurrent-playback.html: Added. * media/video-playback-interrupted-expected.txt: * media/video-playback-interrupted.html: * media/video-restricted-invisible-autoplay-not-allowed.html: Canonical link: https://commits.webkit.org/181931@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208149 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-31 16:36:00 +00:00
RUN(internals.setMediaSessionRestrictions('videoaudio', 'ConcurrentPlaybackNotPermitted'))
Allow MediaSessionManager to restrict media playback https://bugs.webkit.org/show_bug.cgi?id=126780 Reviewed by Jer Noble. Source/WebCore: Test: media/video-concurrent-playback.html * WebCore.exp.in: Export functions needed by Internals. Add HTMLMediaSession. * WebCore.xcodeproj/project.pbxproj: * CMakeLists.txt: * GNUmakefile.list.am: * WebCore.vcxproj/WebCore.vcxproj: * WebCore.vcxproj/WebCore.vcxproj.filters: * WebCore.xcodeproj/project.pbxproj: Add a media session object to manage HTMLMediaElement restrictions. * html/HTMLMediaSession.cpp: Added. * html/HTMLMediaSession.h: Added. Move media restriction management to a MediaSession. * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): Use the media session to manage restrictions. (WebCore::HTMLMediaElement::parseAttribute): Ditto. (WebCore::HTMLMediaElement::insertedInto): Ditto. (WebCore::HTMLMediaElement::parseAttribute): Ditto. (WebCore::HTMLMediaElement::loadInternal): Ditto. (WebCore::HTMLMediaElement::loadResource): Ditto. (WebCore::HTMLMediaElement::setReadyState): Ditto. (WebCore::HTMLMediaElement::autoplay): Ditto. (WebCore::HTMLMediaElement::play): Ditto. (WebCore::HTMLMediaElement::pause): Ditto (WebCore::HTMLMediaElement::pauseInternal): Ditto (WebCore::HTMLMediaElement::suspend): Ditto (WebCore::HTMLMediaElement::resume): Ditto. (WebCore::HTMLMediaElement::updatePlayState): Tell media session playback is about to start. (WebCore::HTMLMediaElement::deliverNotification): Ditto. (WebCore::HTMLMediaElement::webkitShowPlaybackTargetPicker): Ditto. (WebCore::HTMLMediaElement::mediaPlayerIsFullscreenPermitted): Ditto. (WebCore::HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture): Ditto. (WebCore::HTMLMediaElement::pausePlayback): New, allows the media session to pause playback. * html/HTMLMediaElement.h: * html/HTMLVideoElement.cpp: (WebCore::HTMLVideoElement::webkitEnterFullscreen): Use the media session to manage restrictions. * platform/audio/MediaSession.cpp: (WebCore::MediaSession::beginInterruption): Add logging. (WebCore::MediaSession::endInterruption): Ditto. (WebCore::MediaSession::pauseSession): New, allows the session manager to pause playback. * platform/audio/MediaSession.h: Add per-media type restrictions. * platform/audio/MediaSessionManager.cpp: (WebCore::MediaSessionManager::MediaSessionManager): Initialize restrictions. (WebCore::MediaSessionManager::addRestriction): New. (WebCore::MediaSessionManager::removeRestriction): New. (WebCore::MediaSessionManager::restrictions): New. (WebCore::MediaSessionManager::sessionWillBeginPlayback): New. If only one session if the same type is allowed to play, pause all others. * platform/audio/MediaSessionManager.h: * platform/audio/ios/MediaSessionManagerIOS.h: Added. * platform/audio/ios/MediaSessionManagerIOS.mm: Added. (WebCore::MediaSessionManager::sharedManager): (WebCore::m_objcObserver): (-[WebAVAudioSessionHelper initWithCallback:]): (-[WebAVAudioSessionHelper dealloc]): (-[WebAVAudioSessionHelper interruption:]): * platform/audio/mac/AudioDestinationMac.h: Add pausePlayback. Allow tests to set media session restrictions. * testing/Internals.cpp: * testing/Internals.h: * testing/Internals.idl: LayoutTests: * media/video-concurrent-playback-expected.txt: Added. * media/video-concurrent-playback.html: Added. Canonical link: https://commits.webkit.org/144896@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161899 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-01-13 19:42:27 +00:00
EVENT(canplaythrough)
EVENT(canplaythrough)
** Play first video...
RUN(videos[0].play())
EVENT(playing)
** Starting the second video, the first one should pause.
RUN(videos[1].play())
EVENT(playing)
EXPECTED (videos[0].paused == 'true') OK
EXPECTED (videos[1].paused == 'false') OK
END OF TEST