2009-10-22 Eric Carlson <eric.carlson@apple.com>
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Oct 2009 18:10:41 +0000 (18:10 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Oct 2009 18:10:41 +0000 (18:10 +0000)
        Reviewed by Dan Bernstein & Simon Fraser.

        <rdar://problem/7297717>
        https://bugs.webkit.org/show_bug.cgi?id=30323
        Play/pause button in full-screen video controller does not reflect current state

        * WebView/WebVideoFullscreenController.mm:
        (-[WebVideoFullscreenController setMediaElement:WebCore::]): Register for QTMovieRateDidChangeNotification
        (-[WebVideoFullscreenController rateChanged:]): Call HUD controller when rate changes.

        * WebView/WebVideoFullscreenHUDWindowController.h:
        * WebView/WebVideoFullscreenHUDWindowController.mm:
        (-[WebVideoFullscreenHUDWindowController scheduleTimeUpdate]): Call updateRate so play button
        reflects playback state.
        (-[WebVideoFullscreenHUDWindowController updateRate]): New, set play button state according to
        movie state.
        (-[WebVideoFullscreenHUDWindowController playingChanged:]): Only call [self playing] once.

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

WebKit/mac/ChangeLog
WebKit/mac/WebView/WebVideoFullscreenController.mm
WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.h
WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm

index bf4c6f9677549dc3023d58c292fd3e861d538590..16fd3e40c3e5693251e57c18b20b464a7c908b49 100644 (file)
@@ -1,3 +1,23 @@
+2009-10-22  Eric Carlson  <eric.carlson@apple.com>
+
+        Reviewed by Dan Bernstein & Simon Fraser.
+
+        <rdar://problem/7297717>
+        https://bugs.webkit.org/show_bug.cgi?id=30323
+        Play/pause button in full-screen video controller does not reflect current state
+
+        * WebView/WebVideoFullscreenController.mm:
+        (-[WebVideoFullscreenController setMediaElement:WebCore::]): Register for QTMovieRateDidChangeNotification
+        (-[WebVideoFullscreenController rateChanged:]): Call HUD controller when rate changes.
+
+        * WebView/WebVideoFullscreenHUDWindowController.h:
+        * WebView/WebVideoFullscreenHUDWindowController.mm:
+        (-[WebVideoFullscreenHUDWindowController scheduleTimeUpdate]): Call updateRate so play button
+        reflects playback state.
+        (-[WebVideoFullscreenHUDWindowController updateRate]): New, set play button state according to
+        movie state.
+        (-[WebVideoFullscreenHUDWindowController playingChanged:]): Only call [self playing] once.
+
 2009-10-21  John Sullivan  <sullivan@apple.com>
 
         Rubber-stamped by Dan Bernstein.
index f54b177c30396889f6f181dd8fb308f720e549a8..39ec72a0b7ef70762fa8be291c447ee3a2756bf2 100644 (file)
 SOFT_LINK_FRAMEWORK(QTKit)
 SOFT_LINK_CLASS(QTKit, QTMovieView)
 
+SOFT_LINK_POINTER(QTKit, QTMovieRateDidChangeNotification, NSString *)
+
+#define QTMovieRateDidChangeNotification getQTMovieRateDidChangeNotification()
+
 @interface WebVideoFullscreenWindow : NSWindow
 #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_TIGER)
 <NSAnimationDelegate>
@@ -76,6 +80,7 @@ SOFT_LINK_CLASS(QTKit, QTMovieView)
 {
     ASSERT(!_backgroundFullscreenWindow);
     ASSERT(!_fadeAnimation);
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
     [super dealloc];
 }
 
@@ -109,7 +114,15 @@ SOFT_LINK_CLASS(QTKit, QTMovieView)
     _mediaElement = mediaElement;
     if ([self isWindowLoaded]) {
         QTMovieView *movieView = [[self fullscreenWindow] movieView];
-        [movieView setMovie:_mediaElement->platformMedia().qtMovie];
+        QTMovie *movie = _mediaElement->platformMedia().qtMovie;
+
+        ASSERT(movieView);
+        ASSERT(movie);
+        [movieView setMovie:movie];
+        [[NSNotificationCenter defaultCenter] addObserver:self
+                                                 selector:@selector(rateChanged:) 
+                                                     name:QTMovieRateDidChangeNotification 
+                                                   object:movie];
     }
 }
 
@@ -286,6 +299,16 @@ static NSWindow *createBackgroundFullscreenWindow(NSRect frame, int level)
 {
     [_hudController fadeWindowIn];
 }
+
+#pragma mark -
+#pragma mark QTMovie callbacks
+
+- (void)rateChanged:(NSNotification *)unusedNotification
+{
+    UNUSED_PARAM(unusedNotification);
+    [_hudController updateRate];
+}
+
 @end
 
 @implementation WebVideoFullscreenWindow
@@ -442,6 +465,7 @@ static NSWindow *createBackgroundFullscreenWindow(NSRect frame, int level)
     [super resignKeyWindow];
     [[self windowController] requestExitFullscreenWithAnimation:NO];
 }
+
 @end
 
 #endif /* ENABLE(VIDEO) */
index 8b06c1cda9d154885318ad82f31c1fc40990e1fe..abc809220a1862d436bf63c19959180addcf6e05 100644 (file)
@@ -50,6 +50,7 @@
 - (void)fadeWindowIn;
 - (void)fadeWindowOut;
 - (void)closeWindow;
+- (void)updateRate;
 
 @end
 
index 423629899743548cd77615648c0da16db21d5171..17729d38319330101816333f65de3c8c08595a77 100644 (file)
@@ -181,6 +181,7 @@ static const NSTimeInterval HUDWindowFadeOutDelay = 3;
 
     // First, update right away, then schedule future update
     [self updateTime];
+    [self updateRate];
 
     [_timelineUpdateTimer invalidate];
     [_timelineUpdateTimer release];
@@ -466,12 +467,18 @@ static NSTextField *createTimeTextField(NSRect frame)
     [_delegate mediaElement]->setVolume(volume / [self maxVolume], e);
 }
 
+- (void)updateRate
+{
+    [_playButton setIntValue:[self playing]];
+}
+
 - (void)playingChanged:(id)sender
 {
-    [self setPlaying:![self playing]];
-    
+    BOOL nowPlaying = [self playing];
+    [self setPlaying:!nowPlaying];
+
     // Keep HUD visible when paused
-    if (![self playing])
+    if (!nowPlaying)
         [self fadeWindowIn];
     else if (!_mouseIsInHUD) {
         [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(fadeWindowOut) object:nil];