Revert r240434
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Feb 2019 20:34:55 +0000 (20:34 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Feb 2019 20:34:55 +0000 (20:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194600
<rdar://problem/48044566>

Reviewed by Brent Fulgham.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setVolume):
(WebCore::HTMLMediaElement::mediaPlayerVolumeChanged):
(WebCore::HTMLMediaElement::updateVolume):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::setVolume):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241450 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

index b5ddee8..ed4afe6 100644 (file)
@@ -1,3 +1,18 @@
+2019-02-13  Eric Carlson  <eric.carlson@apple.com>
+
+        Revert r240434
+        https://bugs.webkit.org/show_bug.cgi?id=194600
+        <rdar://problem/48044566>
+
+        Reviewed by Brent Fulgham.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::setVolume):
+        (WebCore::HTMLMediaElement::mediaPlayerVolumeChanged):
+        (WebCore::HTMLMediaElement::updateVolume):
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setVolume):
+
 2019-02-13  Alex Christensen  <achristensen@webkit.org>
 
         Stop using setDefersLoading from WebCore
index 1b6f798..3d1e343 100644 (file)
@@ -3722,11 +3722,7 @@ ExceptionOr<void> HTMLMediaElement::setVolume(double volume)
     if (!(volume >= 0 && volume <= 1))
         return Exception { IndexSizeError };
 
-#if PLATFORM(IOS_FAMILY)
-    if (!processingUserGestureForMedia())
-        return { };
-#endif
-
+#if !PLATFORM(IOS_FAMILY)
     if (m_volume == volume)
         return { };
 
@@ -3742,7 +3738,7 @@ ExceptionOr<void> HTMLMediaElement::setVolume(double volume)
         pauseInternal();
         setAutoplayEventPlaybackState(AutoplayEventPlaybackState::PreventedAutoplay);
     }
-
+#endif
     return { };
 }
 
@@ -4933,9 +4929,9 @@ void HTMLMediaElement::mediaPlayerVolumeChanged(MediaPlayer*)
 
     beginProcessingMediaPlayerCallback();
     if (m_player) {
-        double volume = m_player->volume();
-        if (volume != m_volume) {
-            m_volume = volume;
+        double vol = m_player->volume();
+        if (vol != m_volume) {
+            m_volume = vol;
             updateVolume();
             scheduleEvent(eventNames().volumechangeEvent);
         }
@@ -5348,7 +5344,14 @@ void HTMLMediaElement::updateVolume()
 {
     if (!m_player)
         return;
-
+#if PLATFORM(IOS_FAMILY)
+    // Only the user can change audio volume so update the cached volume and post the changed event.
+    float volume = m_player->volume();
+    if (m_volume != volume) {
+        m_volume = volume;
+        scheduleEvent(eventNames().volumechangeEvent);
+    }
+#else
     // Avoid recursion when the player reports volume changes.
     if (!processingMediaPlayerCallback()) {
         Page* page = document().page();
@@ -5377,6 +5380,7 @@ void HTMLMediaElement::updateVolume()
 
     if (hasMediaControls())
         mediaControls()->changedVolume();
+#endif
 }
 
 void HTMLMediaElement::scheduleUpdatePlayState()
index 770f637..5eff758 100644 (file)
@@ -1380,14 +1380,15 @@ void MediaPlayerPrivateAVFoundationObjC::seekToTime(const MediaTime& time, const
 void MediaPlayerPrivateAVFoundationObjC::setVolume(float volume)
 {
 #if PLATFORM(IOS_FAMILY)
-    if ([[PAL::getUIDeviceClass() currentDevice] userInterfaceIdiom] != UIUserInterfaceIdiomPad)
-        return;
-#endif
+    UNUSED_PARAM(volume);
+    return;
+#else
 
     if (!m_avPlayer)
         return;
 
     [m_avPlayer.get() setVolume:volume];
+#endif
 }
 
 void MediaPlayerPrivateAVFoundationObjC::setMuted(bool muted)