Changeset 206490 in webkit
- Timestamp:
- Sep 27, 2016, 6:39:15 PM (9 years ago)
- Location:
- branches/safari-602.2.14.0-branch/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-602.2.14.0-branch/Source/WebCore/ChangeLog
r206489 r206490 1 2016-09-27 Babak Shafiei <bshafiei@apple.com> 2 3 Merge r206454. rdar://problem/28484193 4 5 2016-09-27 Wenson Hsieh <wenson_hsieh@apple.com> 6 7 Related videos on YouTube (and YouTube playlists) cause media controls to disappear 8 https://bugs.webkit.org/show_bug.cgi?id=162621 9 <rdar://problem/28484193> 10 11 Reviewed by Jer Noble. 12 13 Tweaks the main content media heuristic for better Now Playing behavior on YouTube by making the following 14 changes: 15 - Remove the strict requirement for audio to be actively playing for the session to be able to show 16 controls for the purpose of Now Playing, making it the same as our policy for the controls manager. 17 - Make playback requirement restrictions apply only for the controls manager. Videos that do not 18 autoplay will still have the correct behavior with respect to Now Playing, since we will bail in the 19 hasEverNotifiedAboutPlaying() check. 20 - Only consider the main content heuristic as preventing media controls from showing up for the purposes 21 of the controls manager. Now Playing should instead account for this by preferring elements large 22 enough for main content after collecting all of the candidate sessions. 23 24 * html/HTMLMediaElement.cpp: 25 (WebCore::mediaElementSessionInfoForSession): 26 (WebCore::preferMediaControlsForCandidateSessionOverOtherCandidateSession): 27 (WebCore::HTMLMediaElement::updatePlayState): 28 * html/MediaElementSession.cpp: 29 (WebCore::MediaElementSession::canShowControlsManager): 30 * platform/audio/mac/MediaSessionManagerMac.mm: 31 (WebCore::MediaSessionManagerMac::sessionWillBeginPlayback): 32 1 33 2016-09-27 Babak Shafiei <bshafiei@apple.com> 2 34 -
branches/safari-602.2.14.0-branch/Source/WebCore/html/HTMLMediaElement.cpp
r206487 r206490 351 351 struct MediaElementSessionInfo { 352 352 const MediaElementSession* session; 353 MediaElementSession::PlaybackControlsPurpose purpose; 353 354 354 355 double timeOfLastUserInteraction; … … 364 365 return { 365 366 &session, 367 purpose, 366 368 session.mostRecentUserInteractionTime(), 367 369 session.canShowControlsManager(purpose), … … 374 376 static bool preferMediaControlsForCandidateSessionOverOtherCandidateSession(const MediaElementSessionInfo& session, const MediaElementSessionInfo& otherSession) 375 377 { 376 // Prioritize visible media over offscreen media. 377 if (session.isVisibleInViewportOrFullscreen != otherSession.isVisibleInViewportOrFullscreen) 378 MediaElementSession::PlaybackControlsPurpose purpose = session.purpose; 379 ASSERT(purpose == otherSession.purpose); 380 381 // For the controls manager, prioritize visible media over offscreen media. 382 if (purpose == MediaElementSession::PlaybackControlsPurpose::ControlsManager && session.isVisibleInViewportOrFullscreen != otherSession.isVisibleInViewportOrFullscreen) 378 383 return session.isVisibleInViewportOrFullscreen; 384 385 // For Now Playing, prioritize elements that would normally satisfy main content. 386 if (purpose == MediaElementSession::PlaybackControlsPurpose::NowPlaying && session.isLargeEnoughForMainContent != otherSession.isLargeEnoughForMainContent) 387 return session.isLargeEnoughForMainContent; 379 388 380 389 // As a tiebreaker, prioritize elements that the user recently interacted with. … … 5086 5095 updateMediaController(); 5087 5096 updateRenderer(); 5097 5098 m_hasEverHadAudio |= hasAudio(); 5099 m_hasEverHadVideo |= hasVideo(); 5088 5100 } 5089 5101 -
branches/safari-602.2.14.0-branch/Source/WebCore/html/MediaElementSession.cpp
r206489 r206490 234 234 } 235 235 236 bool meetsAudioTrackRequirements = m_element.hasAudio() || (purpose == PlaybackControlsPurpose::ControlsManager && m_element.hasEverHadAudio()); 237 if (!meetsAudioTrackRequirements) { 236 if (!m_element.hasAudio() && !m_element.hasEverHadAudio()) { 238 237 LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No audio"); 239 238 return false; … … 260 259 } 261 260 262 if ( hasBehaviorRestriction(RequirePlaybackToControlControlsManager) && !m_element.isPlaying()) {261 if (purpose == PlaybackControlsPurpose::ControlsManager && hasBehaviorRestriction(RequirePlaybackToControlControlsManager) && !m_element.isPlaying()) { 263 262 LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: Needs to be playing"); 264 263 return false; … … 275 274 } 276 275 277 if (m_element.isVideo()) { 276 // Only allow the main content heuristic to forbid videos from showing up if our purpose is the controls manager. 277 if (purpose == PlaybackControlsPurpose::ControlsManager && m_element.isVideo()) { 278 278 if (!m_element.renderer()) { 279 279 LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No renderer"); … … 281 281 } 282 282 283 if ( purpose == PlaybackControlsPurpose::ControlsManager &&!m_element.hasVideo() && !m_element.hasEverHadVideo()) {283 if (!m_element.hasVideo() && !m_element.hasEverHadVideo()) { 284 284 LOG(Media, "MediaElementSession::canShowControlsManager - returning FALSE: No video"); 285 285 return false; … … 290 290 return true; 291 291 } 292 } 293 294 if (purpose == PlaybackControlsPurpose::NowPlaying) { 295 LOG(Media, "MediaElementSession::canShowControlsManager - returning TRUE: Potentially plays audio"); 296 return true; 292 297 } 293 298 -
branches/safari-602.2.14.0-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm
r206487 r206490 82 82 83 83 LOG(Media, "MediaSessionManagerMac::sessionWillBeginPlayback"); 84 updateNowPlayingInfo();84 scheduleUpdateNowPlayingInfo(); 85 85 return true; 86 86 }
Note:
See TracChangeset
for help on using the changeset viewer.