Explorar o código

add infrastructure for player info view
swipe down transition does currently not work, use up arrow tap instead

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

+ 49 - 3
VLC for Apple TV/VLCFullscreenMovieTVViewController.m

@@ -10,6 +10,11 @@
  *****************************************************************************/
 
 #import "VLCFullscreenMovieTVViewController.h"
+#import "VLCPlaybackInfoTVViewController.h"
+
+
+@interface VLCFullscreenMovieTVViewController (UIViewControllerTransitioningDelegate) <UIViewControllerTransitioningDelegate>
+@end
 
 @interface VLCFullscreenMovieTVViewController ()
 {
@@ -50,16 +55,31 @@
     self.dimmingView.alpha = 0.0;
     self.bottomOverlayView.hidden = YES;
 
-    UITapGestureRecognizer *playpauseGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(playPausePressed)];
-    playpauseGesture.allowedPressTypes = @[@(UIPressTypePlayPause)];
-    [self.view addGestureRecognizer:playpauseGesture];
+
+
+    // Panning and Swiping
+
+    // does not work with pan gesture
+//    UISwipeGestureRecognizer *swipeDownRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeDownRecognized:)];
+//    swipeDownRecognizer.direction = UISwipeGestureRecognizerDirectionDown;
+//    [self.view addGestureRecognizer:swipeDownRecognizer];
+
+    UITapGestureRecognizer *swipeDownRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(swipeDownRecognized:)];
+    swipeDownRecognizer.allowedPressTypes = @[@(UIPressTypeUpArrow)];
+    [self.view addGestureRecognizer:swipeDownRecognizer];
 
     UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGesture:)];
     [self.view addGestureRecognizer:panGestureRecognizer];
 
+    // Button presses
+    UITapGestureRecognizer *playpauseGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(playPausePressed)];
+    playpauseGesture.allowedPressTypes = @[@(UIPressTypePlayPause)];
+    [self.view addGestureRecognizer:playpauseGesture];
+
     UITapGestureRecognizer *selectTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectButtonPressed:)];
     selectTapGestureRecognizer.allowedPressTypes = @[@(UIPressTypeSelect)];
     [self.view addGestureRecognizer:selectTapGestureRecognizer];
+
     UITapGestureRecognizer *menuTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(menuButtonPressed:)];
     menuTapGestureRecognizer.allowedPressTypes = @[@(UIPressTypeMenu)];
     [self.view addGestureRecognizer:menuTapGestureRecognizer];
@@ -165,6 +185,19 @@
     }
 }
 
+- (void)swipeDownRecognized:(UITapGestureRecognizer *)recognizer
+{
+    if (self.transportBar.scrubbing) {
+        return;
+    }
+
+    VLCPlaybackInfoTVViewController *infoController = [[VLCPlaybackInfoTVViewController alloc] initWithNibName:nil bundle:nil];
+    infoController.transitioningDelegate = self;
+    infoController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
+    // TODO: configure with player info
+    [self presentViewController:infoController animated:YES completion:nil];
+}
+
 #pragma mark - 
 
 - (void)updateTimeLabelsForScrubbingFraction:(CGFloat)scrubbingFraction
@@ -276,3 +309,16 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
 }
 
 @end
+
+
+@implementation VLCFullscreenMovieTVViewController (UIViewControllerTransitioningDelegate)
+
+- (id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source
+{
+    return [[VLCPlaybackInfoTVTransitioningAnimator alloc] init];
+}
+- (id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed
+{
+    return [[VLCPlaybackInfoTVTransitioningAnimator alloc] init];
+}
+@end

+ 20 - 0
VLC for Apple TV/VLCPlaybackInfoTVViewController.h

@@ -0,0 +1,20 @@
+/*****************************************************************************
+ * VLC for iOS
+ *****************************************************************************
+ * Copyright (c) 2015 VideoLAN. All rights reserved.
+ * $Id$
+ *
+ * Authors: Tobias Conradi <videolan # tobias-conradi.de>
+ *
+ * Refer to the COPYING file of the official project for license.
+ *****************************************************************************/
+#import <UIKit/UIKit.h>
+
+@interface VLCPlaybackInfoTVTransitioningAnimator : NSObject <UIViewControllerAnimatedTransitioning>
+
+@end
+
+
+@interface VLCPlaybackInfoTVViewController : UIViewController
+
+@end

+ 116 - 0
VLC for Apple TV/VLCPlaybackInfoTVViewController.m

@@ -0,0 +1,116 @@
+/*****************************************************************************
+ * VLC for iOS
+ *****************************************************************************
+ * Copyright (c) 2015 VideoLAN. All rights reserved.
+ * $Id$
+ *
+ * Authors: Tobias Conradi <videolan # tobias-conradi.de>
+ *
+ * Refer to the COPYING file of the official project for license.
+ *****************************************************************************/
+
+#import "VLCPlaybackInfoTVViewController.h"
+
+@interface VLCPlaybackInfoTVViewController ()
+@property (nonatomic) IBOutlet UIView *containerView;
+@property (nonatomic) IBOutlet UIView *dimmingView;
+@property (nonatomic) IBOutlet NSLayoutConstraint *containerHeightConstraint;
+@property (nonatomic) IBOutlet UITabBarController *tabBarController;
+
+@end
+
+@implementation VLCPlaybackInfoTVViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+
+    UITabBarController *controller = [[UITabBarController alloc] init];
+
+
+    [self addChildViewController:controller];
+    controller.view.frame = self.containerView.bounds;
+    controller.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+    [self.containerView addSubview:controller.view];
+    [controller didMoveToParentViewController:self];
+
+    UISwipeGestureRecognizer *swipeUpRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeUpRecognized:)];
+    swipeUpRecognizer.direction = UISwipeGestureRecognizerDirectionUp;
+    [self.view addGestureRecognizer:swipeUpRecognizer];
+}
+
+- (BOOL)shouldAutomaticallyForwardAppearanceMethods {
+    return YES;
+}
+
+- (void)swipeUpRecognized:(UISwipeGestureRecognizer *)recognizer {
+
+    // TODO: check if it was a navigation gesture in child??
+
+    [self dismissViewControllerAnimated:YES completion:nil];
+}
+
+@end
+
+
+@implementation VLCPlaybackInfoTVTransitioningAnimator
+
+- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext {
+    return 0.5;
+}
+
+- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
+    UIViewController *source = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
+    UIViewController *target = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
+
+    UIView *container = [transitionContext containerView];
+    CGRect initialSourceFrame = [transitionContext initialFrameForViewController:source];
+    // TODO: calculate
+    CGFloat infoHeight = CGRectGetHeight(initialSourceFrame);
+
+    CGRect largeFrame = ({
+        CGRect frame = initialSourceFrame;
+        frame.origin.y -=infoHeight;
+        frame.size.height += infoHeight;
+        frame;
+    });
+    CGRect smallFrame = initialSourceFrame;
+
+    CGFloat targetAlpha = 1.0;
+    CGRect fromFrame = initialSourceFrame;
+    CGRect toFrame = initialSourceFrame;
+
+    VLCPlaybackInfoTVViewController *infoVC = nil;
+    if ([target isKindOfClass:[VLCPlaybackInfoTVViewController class]]) {
+        infoVC = (VLCPlaybackInfoTVViewController*) target;
+        infoVC.dimmingView.alpha = 0.0;
+        targetAlpha = 1.0;
+        toFrame = smallFrame;
+        fromFrame = largeFrame;
+        [container addSubview:target.view];
+    } else if ([source isKindOfClass:[VLCPlaybackInfoTVViewController class]]) {
+        infoVC = (VLCPlaybackInfoTVViewController*) source;
+        infoVC.dimmingView.alpha = 1.0;
+        targetAlpha = 0.0;
+        toFrame = largeFrame;
+        fromFrame = smallFrame;
+    }
+
+    infoVC.view.frame = fromFrame;
+
+    // fallback
+    if (!infoVC) {
+        target.view.frame = smallFrame;
+    }
+
+    [UIView animateWithDuration:[self transitionDuration:transitionContext]
+                     animations:^{
+                         infoVC.view.frame = toFrame;
+                         infoVC.dimmingView.alpha = targetAlpha;
+                     }
+                     completion:^(BOOL finished) {
+                         [transitionContext completeTransition:![transitionContext transitionWasCancelled]];
+                     }];
+
+}
+
+@end

+ 47 - 0
VLC for Apple TV/VLCPlaybackInfoTVViewController.xib

@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder.AppleTV.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="AppleTV" propertyAccessControl="none" useAutolayout="YES">
+    <dependencies>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9059"/>
+    </dependencies>
+    <objects>
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="VLCPlaybackInfoTVViewController">
+            <connections>
+                <outlet property="containerHeightConstraint" destination="PQd-PR-z5I" id="40d-bO-xMR"/>
+                <outlet property="containerView" destination="U6y-cE-eGu" id="pdM-21-C2a"/>
+                <outlet property="dimmingView" destination="fkF-mr-3nG" id="NO9-Ww-dkm"/>
+                <outlet property="view" destination="iN0-l3-epB" id="aoh-6Y-hrX"/>
+            </connections>
+        </placeholder>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <view contentMode="scaleToFill" id="iN0-l3-epB">
+            <rect key="frame" x="0.0" y="0.0" width="1920" height="1080"/>
+            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+            <subviews>
+                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fkF-mr-3nG" userLabel="DimmingView">
+                    <rect key="frame" x="0.0" y="400" width="1920" height="680"/>
+                    <animations/>
+                    <color key="backgroundColor" white="0.0" alpha="0.29999999999999999" colorSpace="calibratedWhite"/>
+                </view>
+                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="U6y-cE-eGu" userLabel="Container">
+                    <rect key="frame" x="0.0" y="0.0" width="1920" height="400"/>
+                    <animations/>
+                    <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                    <constraints>
+                        <constraint firstAttribute="height" constant="400" id="PQd-PR-z5I"/>
+                    </constraints>
+                </view>
+            </subviews>
+            <animations/>
+            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
+            <constraints>
+                <constraint firstItem="fkF-mr-3nG" firstAttribute="top" secondItem="U6y-cE-eGu" secondAttribute="bottom" id="56R-lg-86y"/>
+                <constraint firstItem="fkF-mr-3nG" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="9tl-tu-ZJg"/>
+                <constraint firstItem="U6y-cE-eGu" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="C8C-JW-U5v"/>
+                <constraint firstAttribute="bottom" secondItem="fkF-mr-3nG" secondAttribute="bottom" id="X7X-Ek-8zE"/>
+                <constraint firstAttribute="trailing" secondItem="fkF-mr-3nG" secondAttribute="trailing" id="a5y-gG-ndP"/>
+                <constraint firstAttribute="trailing" secondItem="U6y-cE-eGu" secondAttribute="trailing" id="amL-DA-aLx"/>
+                <constraint firstItem="U6y-cE-eGu" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="wZW-k5-Ugc"/>
+            </constraints>
+        </view>
+    </objects>
+</document>

+ 1 - 1
VLC for Apple TV/VLCServerBrowsingTVCell.xib

@@ -12,7 +12,7 @@
             <rect key="frame" x="0.0" y="0.0" width="1920" height="150"/>
             <autoresizingMask key="autoresizingMask"/>
             <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Tcc-PQ-zMX" id="Ygk-DT-1Ta">
-                <rect key="frame" x="0.0" y="0.0" width="1920" height="150"/>
+                <rect key="frame" x="0.0" y="0.0" width="1904" height="150"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Diw-kq-1Zk" customClass="VLCNetworkImageView">

+ 10 - 0
VLC for iOS.xcodeproj/project.pbxproj

@@ -322,6 +322,8 @@
 		DD7BA2641B680C8E002D9F54 /* MediaLibraryKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DD7BA2601B680C1B002D9F54 /* MediaLibraryKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
 		DD8095D61BE3C3BA0065D8E1 /* VLCTransportBar.m in Sources */ = {isa = PBXBuildFile; fileRef = DD8095D51BE3C3BA0065D8E1 /* VLCTransportBar.m */; };
 		DD8095DB1BE3C42F0065D8E1 /* VLCBufferingBar.m in Sources */ = {isa = PBXBuildFile; fileRef = DD8095DA1BE3C42F0065D8E1 /* VLCBufferingBar.m */; };
+		DD8095E01BE3EFC20065D8E1 /* VLCPlaybackInfoTVViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DD8095DE1BE3EFC20065D8E1 /* VLCPlaybackInfoTVViewController.m */; };
+		DD8095E51BE3F4240065D8E1 /* VLCPlaybackInfoTVViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = DD8095E41BE3F4240065D8E1 /* VLCPlaybackInfoTVViewController.xib */; };
 		DD8F84311B00EB3B0009138A /* VLCPlaybackController+MediaLibrary.m in Sources */ = {isa = PBXBuildFile; fileRef = DD8F84301B00EB3B0009138A /* VLCPlaybackController+MediaLibrary.m */; };
 		DDAD5C2B1BB999CA006AFD3B /* VLCMovieViewControlPanel.xib in Resources */ = {isa = PBXBuildFile; fileRef = DDAD5C2A1BB999CA006AFD3B /* VLCMovieViewControlPanel.xib */; };
 		DDB7C6A41BAEB28200E6570E /* WKInterfaceController+VLCConnectionAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = DD9FBE761BAD6BB600FFE77A /* WKInterfaceController+VLCConnectionAlert.m */; };
@@ -979,6 +981,9 @@
 		DD8095D51BE3C3BA0065D8E1 /* VLCTransportBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCTransportBar.m; sourceTree = "<group>"; };
 		DD8095D91BE3C42F0065D8E1 /* VLCBufferingBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCBufferingBar.h; sourceTree = "<group>"; };
 		DD8095DA1BE3C42F0065D8E1 /* VLCBufferingBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCBufferingBar.m; sourceTree = "<group>"; };
+		DD8095DD1BE3EFC20065D8E1 /* VLCPlaybackInfoTVViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCPlaybackInfoTVViewController.h; sourceTree = "<group>"; };
+		DD8095DE1BE3EFC20065D8E1 /* VLCPlaybackInfoTVViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCPlaybackInfoTVViewController.m; sourceTree = "<group>"; };
+		DD8095E41BE3F4240065D8E1 /* VLCPlaybackInfoTVViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = VLCPlaybackInfoTVViewController.xib; sourceTree = "<group>"; };
 		DD8C8F9F1B676C0900B3C4EE /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
 		DD8C8FA01B676C0F00B3C4EE /* fi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fi; path = fi.lproj/Localizable.strings; sourceTree = "<group>"; };
 		DD8C8FA11B676C1700B3C4EE /* el */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = el; path = el.lproj/Localizable.strings; sourceTree = "<group>"; };
@@ -1771,6 +1776,7 @@
 				DD3EAC121BE26166003668DA /* VLCServerBrowsingTVCell.xib */,
 				7D3E528A1BD7B5E100309D15 /* VLCCloudServicesTVViewController.xib */,
 				7DEC8BDD1BD67899006E1093 /* VLCFullscreenMovieTVViewController.xib */,
+				DD8095E41BE3F4240065D8E1 /* VLCPlaybackInfoTVViewController.xib */,
 				7D7EF3D91BD56B5900CD4CEE /* VLCOpenNetworkStreamTVViewController.xib */,
 				DDEAECF51BDFEAFA00756C83 /* VLCLocalNetworkServerTVCell.xib */,
 			);
@@ -1870,6 +1876,8 @@
 				DD8095D51BE3C3BA0065D8E1 /* VLCTransportBar.m */,
 				7DEC8BDB1BD67899006E1093 /* VLCFullscreenMovieTVViewController.h */,
 				7DEC8BDC1BD67899006E1093 /* VLCFullscreenMovieTVViewController.m */,
+				DD8095DD1BE3EFC20065D8E1 /* VLCPlaybackInfoTVViewController.h */,
+				DD8095DE1BE3EFC20065D8E1 /* VLCPlaybackInfoTVViewController.m */,
 			);
 			name = Playback;
 			sourceTree = "<group>";
@@ -2458,6 +2466,7 @@
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				DD8095E51BE3F4240065D8E1 /* VLCPlaybackInfoTVViewController.xib in Resources */,
 				7D6069721BD94AD600AB765C /* VLCCloudStorageTableViewCell.xib in Resources */,
 				7DEC8BDF1BD67899006E1093 /* VLCFullscreenMovieTVViewController.xib in Resources */,
 				7D4CAAFC1BDE548A00A08EF5 /* Localizable.strings in Resources */,
@@ -2657,6 +2666,7 @@
 				DD3EFF441BDEBCE500B68579 /* VLCSharedLibraryParser.m in Sources */,
 				DD3EFF5E1BDEBCE500B68579 /* VLCLocalServerDiscoveryController.m in Sources */,
 				7D0C35371BD97E870058CD19 /* VLCOneDriveTableViewController.m in Sources */,
+				DD8095E01BE3EFC20065D8E1 /* VLCPlaybackInfoTVViewController.m in Sources */,
 				7DEC8C1F1BD6A113006E1093 /* UIDevice+VLC.m in Sources */,
 				DDEAECFE1BDFFAEE00756C83 /* Reachability.m in Sources */,
 				DD3EFF561BDEBCE500B68579 /* VLCLocalNetworkServiceBrowserDSM.m in Sources */,