Explorar o código

add activity indicator to playback view

Tobias Conradi %!s(int64=9) %!d(string=hai) anos
pai
achega
6574b39468

+ 1 - 0
VLC for Apple TV/VLCFullscreenMovieTVViewController.h

@@ -23,6 +23,7 @@
 @property (readwrite, nonatomic, weak) IBOutlet UILabel *remainingTimeLabel;
 @property (readwrite, nonatomic, weak) IBOutlet UILabel *titleLabel;
 @property (readwrite, nonatomic, weak) IBOutlet UILabel *bufferingLabel;
+@property (readwrite, nonatomic, weak) IBOutlet UIActivityIndicatorView *activityIndicator;
 
 + (instancetype) fullscreenMovieTVViewController;
 

+ 15 - 0
VLC for Apple TV/VLCFullscreenMovieTVViewController.m

@@ -47,6 +47,7 @@
     UITapGestureRecognizer *playpauseGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(playPausePressed)];
     playpauseGesture.allowedPressTypes = @[@(UIPressTypePlayPause)];
     [self.view addGestureRecognizer:playpauseGesture];
+
 }
 
 #pragma mark - view events
@@ -120,7 +121,21 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
         currentMediaHasChapters:(BOOL)currentMediaHasChapters
           forPlaybackController:(VLCPlaybackController *)controller
 {
+
+    switch (currentState) {
+        case VLCMediaPlayerStateBuffering:
+            [self.activityIndicator startAnimating];
+            self.activityIndicator.alpha = 1.0;
+            break;
+
+        default:
+            [self.activityIndicator stopAnimating];
+            self.activityIndicator.alpha = 0.0;
+            break;
+    }
+
     if (controller.isPlaying && !self.bufferingLabel.hidden) {
+        [self.activityIndicator stopAnimating];
         [UIView animateWithDuration:.3 animations:^{
             self.bufferingLabel.hidden = YES;
             self.bottomOverlayView.hidden = NO;

+ 8 - 0
VLC for Apple TV/VLCFullscreenMovieTVViewController.xib

@@ -24,6 +24,12 @@
             <subviews>
                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="SpU-aa-czI">
                     <rect key="frame" x="0.0" y="0.0" width="1920" height="1080"/>
+                    <subviews>
+                        <activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" animating="YES" style="whiteLarge" translatesAutoresizingMaskIntoConstraints="NO" id="UcH-Yc-Sd0">
+                            <rect key="frame" x="928" y="595" width="64" height="64"/>
+                            <animations/>
+                        </activityIndicatorView>
+                    </subviews>
                     <animations/>
                     <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
                 </view>
@@ -84,8 +90,10 @@
                 <constraint firstAttribute="trailing" secondItem="SzB-KN-vRr" secondAttribute="trailing" id="3Bb-JP-76x"/>
                 <constraint firstAttribute="bottom" secondItem="SzB-KN-vRr" secondAttribute="bottom" id="542-su-jDp"/>
                 <constraint firstItem="SzB-KN-vRr" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="DAq-5Q-AKJ"/>
+                <constraint firstItem="UcH-Yc-Sd0" firstAttribute="top" secondItem="yaX-qU-D4t" secondAttribute="bottom" constant="20" id="G3v-bW-rEA"/>
                 <constraint firstAttribute="bottom" secondItem="SpU-aa-czI" secondAttribute="bottom" id="J9T-OC-2Sd"/>
                 <constraint firstItem="yaX-qU-D4t" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="Qbe-FY-TR5"/>
+                <constraint firstItem="UcH-Yc-Sd0" firstAttribute="centerX" secondItem="yaX-qU-D4t" secondAttribute="centerX" id="SjI-w2-nOq"/>
                 <constraint firstItem="SpU-aa-czI" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="SnQ-Wu-aiI"/>
                 <constraint firstItem="SpU-aa-czI" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="XAU-E6-19A"/>
                 <constraint firstItem="yaX-qU-D4t" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="ecl-IU-ALU"/>