Browse Source

iOS playback: add activity indicator from the tvOS interface (refs #216)

(cherry picked from commit 19c863d2f8d39422eda2d9d2d3601cc6f37ab390)
Felix Paul Kühne 6 years ago
parent
commit
7ec0122935

+ 6 - 1
Resources/VLCMovieViewController~ipad.xib

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" colorMatched="YES">
     <device id="ipad9_7" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
@@ -11,6 +11,7 @@
     <objects>
         <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="VLCMovieViewController">
             <connections>
+                <outlet property="activityIndicator" destination="1Bq-rl-k4J" id="DeR-JB-gXq"/>
                 <outlet property="albumNameLabel" destination="305" id="308"/>
                 <outlet property="artistNameLabel" destination="303" id="306"/>
                 <outlet property="artworkImageView" destination="g3j-bZ-K3S" id="fPn-6f-Kez"/>
@@ -245,6 +246,10 @@
                     <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                     <nil key="highlightedColor"/>
                 </label>
+                <activityIndicatorView opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" misplaced="YES" style="whiteLarge" id="1Bq-rl-k4J">
+                    <rect key="frame" x="366" y="542" width="37" height="37"/>
+                    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
+                </activityIndicatorView>
                 <view contentMode="scaleToFill" id="141" userLabel="Video Effects Panel" customClass="VLCFrostedGlasView">
                     <rect key="frame" x="470" y="782" width="298" height="192"/>
                     <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>

+ 6 - 1
Resources/VLCMovieViewController~iphone.xib

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" colorMatched="YES">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
@@ -11,6 +11,7 @@
     <objects>
         <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="VLCMovieViewController">
             <connections>
+                <outlet property="activityIndicator" destination="vR5-i9-KEJ" id="mxp-ZT-rNk"/>
                 <outlet property="albumNameLabel" destination="280" id="285"/>
                 <outlet property="artistNameLabel" destination="279" id="283"/>
                 <outlet property="artworkImageView" destination="yK6-Ph-SVE" id="Cm9-7F-iYZ"/>
@@ -95,6 +96,10 @@
                     <nil key="highlightedColor"/>
                     <color key="shadowColor" red="1" green="1" blue="1" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
                 </label>
+                <activityIndicatorView opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" misplaced="YES" style="whiteLarge" id="vR5-i9-KEJ">
+                    <rect key="frame" x="169" y="373" width="37" height="37"/>
+                    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
+                </activityIndicatorView>
                 <view hidden="YES" userInteractionEnabled="NO" contentMode="scaleToFill" id="108" userLabel="Playing Externally View" customClass="VLCPlayingExternallyView" customModule="VLC_iOS" customModuleProvider="target">
                     <rect key="frame" x="28" y="178" width="320" height="257"/>
                     <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>

+ 1 - 0
Sources/VLCMovieViewController.h

@@ -74,6 +74,7 @@ typedef NS_ENUM(NSInteger, VLCMovieJumpState) {
 @property (nonatomic, strong) IBOutlet UILabel *trackNameLabel;
 @property (nonatomic, strong) IBOutlet UIImageView *artworkImageView;
 @property (nonatomic, strong) IBOutlet NSLayoutConstraint *widthConstraint;
+@property (nonatomic, strong) IBOutlet UIActivityIndicatorView *activityIndicator;
 
 @property (nonatomic, weak) id<VLCMovieViewControllerDelegate> delegate;
 

+ 23 - 0
Sources/VLCMovieViewController.m

@@ -814,6 +814,24 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
     [self setControlsHidden:!_controlsHidden animated:YES];
 }
 
+- (void)updateActivityIndicatorForState:(VLCMediaPlayerState)state {
+    UIActivityIndicatorView *indicator = self.activityIndicator;
+    switch (state) {
+        case VLCMediaPlayerStateBuffering:
+            if (!indicator.isAnimating) {
+                self.activityIndicator.alpha = 1.0;
+                [self.activityIndicator startAnimating];
+            }
+            break;
+        default:
+            if (indicator.isAnimating) {
+                [self.activityIndicator stopAnimating];
+                self.activityIndicator.alpha = 0.0;
+            }
+            break;
+    }
+}
+
 - (void)_resetIdleTimer
 {
     if (!_idleTimer)
@@ -1038,6 +1056,9 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
 
 - (void)playbackPositionUpdated:(VLCPlaybackController *)controller
 {
+    // FIXME: hard coded state since the state in mediaPlayer is incorrectly still buffering
+    [self updateActivityIndicatorForState:VLCMediaPlayerStatePlaying];
+
     if (!_isScrubbing) {
         self.timeNavigationTitleView.positionSlider.value = [controller playbackPosition];
     }
@@ -1079,6 +1100,8 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
         currentMediaHasChapters:(BOOL)currentMediaHasChapters
           forPlaybackController:(VLCPlaybackController *)controller
 {
+    [self updateActivityIndicatorForState:currentState];
+
     if (currentState == VLCMediaPlayerStateBuffering)
         _mediaDuration = controller.mediaDuration;