Commit b025b73d authored by Carola Nitz's avatar Carola Nitz

Refactored the controlspanel and movievc for clearer interfaces and more...

Refactored the controlspanel and movievc for clearer interfaces and more decoupling Moved logic for layout completely into code to have it one place and fix the disappearing controls
parent d781d85e
Pipeline #80 failed with stage
in 0 seconds
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="VLCMovieViewControlPanelViewController">
<connections>
<outlet property="bwdButton" destination="JDB-xi-tPg" id="PWa-6a-7nP"/>
<outlet property="fwdButton" destination="ebr-CU-0C0" id="6xF-al-DU2"/>
<outlet property="moreActionsButton" destination="JfQ-q3-fZH" id="47z-eO-7zE"/>
<outlet property="playPauseButton" destination="sWz-p2-OOq" id="uWM-TM-PRK"/>
<outlet property="playbackControls" destination="2cP-rW-fzM" id="wpr-p8-6Or"/>
<outlet property="playbackSpeedButton" destination="ihG-fo-m2Q" id="5y8-Eo-2xy"/>
<outlet property="trackSwitcherButton" destination="Ev9-Aj-Ysl" id="wpy-cc-ir4"/>
<outlet property="videoFilterButton" destination="wn4-Cf-Bor" id="gAq-me-PdK"/>
<outlet property="view" destination="xGq-of-vsu" id="fd9-4M-xqD"/>
<outlet property="volumeView" destination="0j8-jT-SDG" id="Nsm-zK-V0I"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view hidden="YES" opaque="NO" contentMode="scaleToFill" id="xGq-of-vsu" customClass="VLCFrostedGlasView">
<rect key="frame" x="0.0" y="0.0" width="320" height="95"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ihG-fo-m2Q" userLabel="Playback Speed Button">
<rect key="frame" x="8" y="8" width="35" height="40"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="Een-T9-l4Q"/>
<constraint firstAttribute="width" constant="35" id="VY6-bJ-OtU"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<inset key="contentEdgeInsets" minX="0.0" minY="4" maxX="0.0" maxY="4"/>
<state key="normal" image="speedIcon">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<variation key="widthClass=compact" fixedFrame="YES">
<rect key="frame" x="11" y="6" width="19" height="27"/>
</variation>
<connections>
<action selector="showPlaybackSpeedView" destination="-2" eventType="touchUpInside" id="0g6-YN-jtk"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ev9-Aj-Ysl" userLabel="track switcher button">
<rect key="frame" x="51" y="8" width="35" height="40"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="9OZ-EG-hPx"/>
<constraint firstAttribute="width" constant="35" id="jBS-11-dzh"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<inset key="contentEdgeInsets" minX="0.0" minY="4" maxX="0.0" maxY="4"/>
<state key="normal" image="audioTrackIcon">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<variation key="widthClass=compact" fixedFrame="YES">
<rect key="frame" x="56" y="15" width="32" height="40"/>
</variation>
<connections>
<action selector="switchTrack:" destination="-2" eventType="touchUpInside" id="DMb-OM-S3d"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wn4-Cf-Bor" userLabel="Video Filter Button">
<rect key="frame" x="234" y="8" width="35" height="40"/>
<constraints>
<constraint firstAttribute="width" constant="35" id="2g4-uD-jL2"/>
<constraint firstAttribute="height" constant="40" id="qAx-hr-fm1"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<inset key="contentEdgeInsets" minX="0.0" minY="4" maxX="0.0" maxY="4"/>
<state key="normal" image="videoEffectsIcon">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="videoFilterToggle:" destination="-2" eventType="touchUpInside" id="DMM-9Y-Eff"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="JfQ-q3-fZH" userLabel="more actions button">
<rect key="frame" x="277" y="8" width="35" height="40"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="Nay-FZ-Ucn"/>
<constraint firstAttribute="width" constant="35" id="jMy-Wa-krc"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<inset key="contentEdgeInsets" minX="0.0" minY="4" maxX="0.0" maxY="4"/>
<state key="normal" image="More">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<variation key="widthClass=compact" fixedFrame="YES">
<rect key="frame" x="280" y="15" width="32" height="40"/>
</variation>
<connections>
<action selector="moreActions:" destination="-2" eventType="touchUpInside" id="uKo-wq-2SU"/>
</connections>
</button>
<view opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" placeholderIntrinsicWidth="infinite" placeholderIntrinsicHeight="30" translatesAutoresizingMaskIntoConstraints="NO" id="0j8-jT-SDG" customClass="VLCVolumeView">
<rect key="frame" x="10" y="57" width="300" height="30"/>
<constraints>
<constraint firstAttribute="width" priority="250" constant="300" id="85a-bl-A1M"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="150" id="UzA-DV-IRM"/>
<constraint firstAttribute="width" relation="lessThanOrEqual" priority="900" constant="300" id="rkl-fF-S16"/>
</constraints>
</view>
<view contentMode="scaleToFill" semanticContentAttribute="playback" translatesAutoresizingMaskIntoConstraints="NO" id="2cP-rW-fzM" userLabel="Playback controls">
<rect key="frame" x="94" y="8" width="132" height="40"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" semanticContentAttribute="playback" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="JDB-xi-tPg" userLabel="bwd button">
<rect key="frame" x="0.0" y="0.0" width="40" height="40"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="40" id="GWR-Ar-Rkq"/>
<constraint firstAttribute="height" constant="40" id="Sm5-yS-Mhp"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<inset key="contentEdgeInsets" minX="0.0" minY="4" maxX="0.0" maxY="4"/>
<state key="normal" image="backIcon">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="backward:" destination="-2" eventType="touchUpInside" id="Jci-SY-Oyo"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" semanticContentAttribute="playback" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="sWz-p2-OOq" userLabel="play pause button">
<rect key="frame" x="46" y="0.0" width="40" height="40"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="AvI-sg-Cfg"/>
<constraint firstAttribute="width" constant="40" id="dgQ-ny-i0B"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<inset key="contentEdgeInsets" minX="0.0" minY="4" maxX="0.0" maxY="4"/>
<state key="normal" image="playIcon">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="playPause" destination="-2" eventType="touchUpInside" id="EOM-4b-iUz"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" semanticContentAttribute="playback" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ebr-CU-0C0" userLabel="fwd button">
<rect key="frame" x="92" y="0.0" width="40" height="40"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="40" id="3R8-m2-NES"/>
<constraint firstAttribute="height" constant="40" id="cce-E1-xjV"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<inset key="contentEdgeInsets" minX="0.0" minY="4" maxX="0.0" maxY="4"/>
<state key="normal" image="forwardIcon">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="forward:" destination="-2" eventType="touchUpInside" id="PEb-DG-gsL"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="sWz-p2-OOq" firstAttribute="top" secondItem="2cP-rW-fzM" secondAttribute="top" id="1GA-3R-rNJ"/>
<constraint firstItem="ebr-CU-0C0" firstAttribute="top" secondItem="2cP-rW-fzM" secondAttribute="top" id="4rg-xz-1ZA"/>
<constraint firstItem="sWz-p2-OOq" firstAttribute="centerX" secondItem="2cP-rW-fzM" secondAttribute="centerX" id="AZ1-5b-Su4"/>
<constraint firstItem="sWz-p2-OOq" firstAttribute="left" secondItem="JDB-xi-tPg" secondAttribute="right" priority="750" constant="15" id="Aau-p6-v2m"/>
<constraint firstItem="JDB-xi-tPg" firstAttribute="top" secondItem="2cP-rW-fzM" secondAttribute="top" id="Bb5-bY-0Mo"/>
<constraint firstAttribute="bottom" secondItem="sWz-p2-OOq" secondAttribute="bottom" id="DoC-Pm-7fV"/>
<constraint firstAttribute="bottom" secondItem="ebr-CU-0C0" secondAttribute="bottom" id="a11-IG-9Hf"/>
<constraint firstItem="JDB-xi-tPg" firstAttribute="left" secondItem="2cP-rW-fzM" secondAttribute="left" id="aMc-E9-yjF"/>
<constraint firstAttribute="bottom" secondItem="JDB-xi-tPg" secondAttribute="bottom" id="c0j-dl-pOQ"/>
<constraint firstItem="ebr-CU-0C0" firstAttribute="left" secondItem="sWz-p2-OOq" secondAttribute="right" priority="750" constant="15" id="cfF-Ax-geb"/>
<constraint firstAttribute="right" secondItem="ebr-CU-0C0" secondAttribute="right" id="dyi-Jl-CkU"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstItem="JfQ-q3-fZH" firstAttribute="leading" secondItem="wn4-Cf-Bor" secondAttribute="trailing" constant="8" id="BFe-d9-v0M"/>
<constraint firstItem="ihG-fo-m2Q" firstAttribute="leading" secondItem="xGq-of-vsu" secondAttribute="leading" constant="8" id="MoD-Bo-PaT"/>
<constraint firstAttribute="trailing" secondItem="JfQ-q3-fZH" secondAttribute="trailing" constant="8" id="O20-57-Kf4"/>
<constraint firstItem="2cP-rW-fzM" firstAttribute="leading" secondItem="Ev9-Aj-Ysl" secondAttribute="trailing" constant="8" id="Pe8-qK-NGa"/>
<constraint firstItem="2cP-rW-fzM" firstAttribute="centerX" secondItem="xGq-of-vsu" secondAttribute="centerX" id="Wb1-Bh-HRN"/>
<constraint firstItem="wn4-Cf-Bor" firstAttribute="leading" secondItem="2cP-rW-fzM" secondAttribute="trailing" constant="8" id="WhX-MM-w9S"/>
<constraint firstAttribute="bottom" secondItem="0j8-jT-SDG" secondAttribute="bottom" constant="8" id="bgI-Df-ZPx"/>
<constraint firstItem="0j8-jT-SDG" firstAttribute="centerX" secondItem="xGq-of-vsu" secondAttribute="centerX" id="eKd-It-BJV"/>
<constraint firstItem="wn4-Cf-Bor" firstAttribute="centerY" secondItem="ihG-fo-m2Q" secondAttribute="centerY" id="eSw-0a-0Ae"/>
<constraint firstItem="JfQ-q3-fZH" firstAttribute="centerY" secondItem="ihG-fo-m2Q" secondAttribute="centerY" id="eoS-6H-tER"/>
<constraint firstItem="2cP-rW-fzM" firstAttribute="top" secondItem="xGq-of-vsu" secondAttribute="top" constant="8" id="hcI-5g-0LY"/>
<constraint firstItem="2cP-rW-fzM" firstAttribute="centerY" secondItem="ihG-fo-m2Q" secondAttribute="centerY" id="hnD-44-2fm"/>
<constraint firstItem="Ev9-Aj-Ysl" firstAttribute="centerY" secondItem="ihG-fo-m2Q" secondAttribute="centerY" id="pDl-On-k6L"/>
<constraint firstItem="Ev9-Aj-Ysl" firstAttribute="leading" secondItem="ihG-fo-m2Q" secondAttribute="trailing" constant="8" id="vj7-1I-YOd"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<nil key="simulatedTopBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="333" y="681.5"/>
</view>
</objects>
<resources>
<image name="More" width="20" height="6"/>
<image name="audioTrackIcon" width="19" height="19"/>
<image name="backIcon" width="32" height="16"/>
<image name="forwardIcon" width="32" height="16"/>
<image name="playIcon" width="19" height="17"/>
<image name="speedIcon" width="19" height="19"/>
<image name="videoEffectsIcon" width="21" height="21"/>
</resources>
</document>
/*****************************************************************************
* VLCMovieViewControlPanelViewController.h
* VLCMovieViewControlPanelView.h
* VLC for iOS
*****************************************************************************
* Copyright (c) 2015 VideoLAN. All rights reserved.
......@@ -12,26 +12,22 @@
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
#import "VLCPlaybackController.h"
#import "VLCVolumeView.h"
#import "VLCFrostedGlasView.h"
@interface VLCMovieViewControlPanelViewController : UIViewController
@interface VLCMovieViewControlPanelView : VLCFrostedGlasView
@property (nonatomic, strong) IBOutlet UIButton *playbackSpeedButton;
@property (nonatomic, strong) IBOutlet UIButton *trackSwitcherButton;
@property (nonatomic, strong) UIButton *playbackSpeedButton;
@property (nonatomic, strong) UIButton *trackSwitcherButton;
@property (nonatomic, strong) IBOutlet UIButton *bwdButton;
@property (nonatomic, strong) IBOutlet UIButton *playPauseButton;
@property (nonatomic, strong) IBOutlet UIButton *fwdButton;
@property (nonatomic, strong) UIButton *bwdButton;
@property (nonatomic, strong) UIButton *playPauseButton;
@property (nonatomic, strong) UIButton *fwdButton;
@property (nonatomic, strong) IBOutlet UIButton *videoFilterButton;
@property (nonatomic, strong) IBOutlet UIButton *moreActionsButton;
@property (nonatomic, strong) IBOutlet MPVolumeView *volumeView;
@property (nonatomic, weak) VLCPlaybackController *playbackController;
@property (nonatomic, strong) UIButton *videoFilterButton;
@property (nonatomic, strong) UIButton *moreActionsButton;
@property (nonatomic, strong) VLCVolumeView *volumeView;
- (void)updateButtons;
......
/*****************************************************************************
* VLCMovieViewControlPanelViewController.m
* VLCMovieViewControlPanelView.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Tobias Conradi <videolan@tobias-conradi.de>
* Carola Nitz <nitz.carola@googlemail.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCMovieViewControlPanelView.h"
#import "VLCPlaybackController.h"
#import "VLCMovieViewControlPanelViewController.h"
@interface VLCMovieViewControlPanelView ()
@interface VLCMovieViewControlPanelViewController ()
@property (nonatomic, weak) IBOutlet UIView *playbackControls;
@property (nonatomic, strong) UIView *playbackControls;
@property (nonatomic, strong) NSMutableArray *constraints;
@property (nonatomic, assign) BOOL compactMode;
@property (nonatomic, strong) VLCPlaybackController *playbackController;
@end
@implementation VLCMovieViewControlPanelViewController
@implementation VLCMovieViewControlPanelView
static const CGFloat maxCompactWidth = 420.0;
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self setupSubviews];
[self setupConstraints];
_compactMode = YES;
[self setupConstraints:_compactMode];
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
- (void)setupSubviews
{
_playbackSpeedButton = [[UIButton alloc] initWithFrame:CGRectZero];
[_playbackSpeedButton setImage:[UIImage imageNamed:@"speedIcon"] forState:UIControlStateNormal];
_playbackSpeedButton.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:_playbackSpeedButton];
_trackSwitcherButton = [[UIButton alloc] initWithFrame:CGRectZero];
[_trackSwitcherButton setImage:[UIImage imageNamed:@"audioTrackIcon"] forState:UIControlStateNormal];
_trackSwitcherButton.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:_trackSwitcherButton];
_playbackControls = [[UIView alloc] initWithFrame:CGRectZero];
_playbackControls.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:_playbackControls];
_bwdButton = [[UIButton alloc] initWithFrame:CGRectZero];
[_bwdButton setImage:[UIImage imageNamed:@"backIcon"] forState:UIControlStateNormal];
_bwdButton.translatesAutoresizingMaskIntoConstraints = NO;
[_playbackControls addSubview:_bwdButton];
_playPauseButton = [[UIButton alloc] initWithFrame:CGRectZero];
[_playPauseButton setImage:[UIImage imageNamed:@"playIcon"] forState:UIControlStateNormal];
_playPauseButton.translatesAutoresizingMaskIntoConstraints = NO;
[_playbackControls addSubview:_playPauseButton];
_fwdButton = [[UIButton alloc] initWithFrame:CGRectZero];
[_fwdButton setImage:[UIImage imageNamed:@"forwardIcon"] forState:UIControlStateNormal];
_fwdButton.translatesAutoresizingMaskIntoConstraints = NO;
[_playbackControls addSubview:_fwdButton];
_videoFilterButton = [[UIButton alloc] initWithFrame:CGRectZero];
[_videoFilterButton setImage:[UIImage imageNamed:@"videoEffectsIcon"] forState:UIControlStateNormal];
_videoFilterButton.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:_videoFilterButton];
_moreActionsButton = [[UIButton alloc] initWithFrame:CGRectZero];
[_moreActionsButton setImage:[UIImage imageNamed:@"More"] forState:UIControlStateNormal];
_moreActionsButton.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:_moreActionsButton];
_volumeView = [[VLCVolumeView alloc] initWithFrame:CGRectZero];
_volumeView.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:_volumeView];
_playbackSpeedButton.accessibilityLabel = NSLocalizedString(@"PLAYBACK_SPEED", nil);
_playbackSpeedButton.isAccessibilityElement = YES;
_trackSwitcherButton.accessibilityLabel = NSLocalizedString(@"OPEN_TRACK_PANEL", nil);
_trackSwitcherButton.isAccessibilityElement = YES;
_bwdButton.accessibilityLabel = NSLocalizedString(@"BWD_BUTTON", nil);
_bwdButton.isAccessibilityElement = YES;
UILongPressGestureRecognizer *longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(playPauseLongPress:)];
[_playPauseButton addGestureRecognizer:longPressRecognizer];
_playPauseButton.accessibilityLabel = NSLocalizedString(@"PLAY_PAUSE_BUTTON", nil);
_playPauseButton.accessibilityHint = NSLocalizedString(@"LONGPRESS_TO_STOP", nil);
_playPauseButton.isAccessibilityElement = YES;
_fwdButton.accessibilityLabel = NSLocalizedString(@"FWD_BUTTON", nil);
_fwdButton.isAccessibilityElement = YES;
_videoFilterButton.accessibilityLabel = NSLocalizedString(@"VIDEO_FILTER", nil);
_videoFilterButton.isAccessibilityElement = YES;
UILongPressGestureRecognizer *longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(playPauseLongPress:)];
[_playPauseButton addGestureRecognizer:longPressRecognizer];
// HACK: get the slider from volume view
UISlider *volumeSlider = nil;
for (id aView in self.volumeView.subviews){
if ([aView isKindOfClass:[UISlider class]]){
volumeSlider = (UISlider *)aView;
break;
}
}
[volumeSlider addTarget:nil action:@selector(volumeSliderAction:) forControlEvents:UIControlEventValueChanged];
[self.volumeView setVolumeThumbImage:[UIImage imageNamed:@"sliderKnob"] forState:UIControlStateNormal];
_compactMode = YES;
[self setupConstraints:YES];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.volumeView.hidden = NO;
}
- (void)viewDidDisappear:(BOOL)animated
- (void)setupConstraints
{
[super viewDidDisappear:animated];
self.volumeView.hidden = YES;
}
- (void) viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
[self.view setNeedsUpdateConstraints];
NSDictionary *viewsDict = @{
@"forward" : self.fwdButton,
@"backward" : self.bwdButton,
@"playpause" : self.playPauseButton,
@"speed" : self.playbackSpeedButton,
@"track" : self.trackSwitcherButton,
@"more" : self.moreActionsButton,
@"filter" : self.videoFilterButton,
@"volume" : self.volumeView,
};
NSMutableArray *staticConstraints = [NSMutableArray new];
[staticConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[backward(40)]-(margin@750)-[playpause(40)]-(margin@750)-[forward(40)]|"
options:NSLayoutFormatAlignAllCenterY
metrics:@{@"margin": @15.0}
views:viewsDict]];
[staticConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[backward(40)]|"
options:NSLayoutFormatAlignAllCenterX
metrics:nil
views:viewsDict]];
for (NSString *object in viewsDict) {
NSString *format = [NSString stringWithFormat:@"V:[%@(40)]", object];
[staticConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:format
options:NSLayoutFormatAlignAllCenterX
metrics:nil
views:viewsDict]];
}
[NSLayoutConstraint activateConstraints:staticConstraints];
}
- (void) updateViewConstraints {
BOOL compactMode = CGRectGetWidth(self.view.frame) <= maxCompactWidth;
- (void)updateViewConstraints
{
BOOL compactMode = CGRectGetWidth(self.frame) <= maxCompactWidth;
if (self.compactMode != compactMode) {
self.compactMode = compactMode;
[self setupConstraints:compactMode];
}
[super updateViewConstraints];
}
- (void) setupConstraints:(BOOL)compactMode {
UIView *superview = self.view.superview;
NSArray *oldConstraints = [self.view.constraints filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSLayoutConstraint * evaluatedObject, NSDictionary<NSString *,id> * _Nullable bindings) {
if (!superview) {
return YES;
}
return evaluatedObject.firstItem != superview && evaluatedObject.secondItem != superview;
}]];
[self.view removeConstraints:oldConstraints];
- (void)setupConstraints:(BOOL)compactMode
{
[self removeConstraints:_constraints];
NSDictionary *viewsDict = @{@"speed" : self.playbackSpeedButton,
@"track" : self.trackSwitcherButton,
@"playback" : self.playbackControls,
......@@ -111,66 +151,51 @@ static const CGFloat maxCompactWidth = 420.0;
@"volume" : self.volumeView,
};
NSMutableArray *constraints = [NSMutableArray array];
_constraints = [NSMutableArray array];
if (compactMode) {
[constraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[speed]-8-[track]-(>=8)-[playback]-(>=8)-[filter]-8-[actions]-|"
[_constraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[speed(35)]-[track(35)]-(>=8)-[playback]-(>=8)-[filter(35)]-[actions(35)]-|"
options:NSLayoutFormatAlignAllCenterY
metrics:nil
views:viewsDict]];
[constraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(>=10)-[volume]-(>=10)-|"
[_constraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(>=10)-[volume(==300)]-(>=10)-|"
options:0
metrics:nil
views:viewsDict]];
[constraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[playback]-[volume(==40)]-|"
[_constraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[playback]-[volume]-|"
options:NSLayoutFormatAlignAllCenterX
metrics:nil
views:viewsDict]];
} else {
[constraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[volume]-(>=8)-[playback]-(>=8)-[speed]-8-[track]-8-[filter]-8-[actions]-|"
[_constraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[volume(>=150)]-(>=8)-[playback]-(>=8)-[speed(35)]-[track(35)]-[filter(35)]-[actions(35)]-|"
options:NSLayoutFormatAlignAllCenterY
metrics:nil
views:viewsDict]];
[constraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[playback]-|"
[_constraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[playback]-|"
options:0
metrics:nil
views:viewsDict]];
[constraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[volume(==40)]"
options:0
metrics:nil
views:viewsDict]];
}
[constraints addObject:[NSLayoutConstraint constraintWithItem:self.playbackControls
[_constraints addObject:[NSLayoutConstraint constraintWithItem:self.playbackControls
attribute:NSLayoutAttributeCenterX
relatedBy:NSLayoutRelationEqual
toItem:self.view
toItem:self
attribute:NSLayoutAttributeCenterX
multiplier:1.0
constant:0]];
[self.view addConstraints:constraints];
[self addConstraints:_constraints];
}
// needed for < iOS 8
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
[self.view setNeedsUpdateConstraints];
}
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
[self.view setNeedsUpdateConstraints];
} completion:nil];
- (void)layoutSubviews
{
[super layoutSubviews];
[self updateViewConstraints];
}
- (VLCPlaybackController *)playbackController
{
if (!_playbackController) {
......@@ -199,7 +224,8 @@ static const CGFloat maxCompactWidth = 420.0;
}
}
- (void)updateButtons {
- (void)updateButtons
{
[self updatePlayPauseButton];
self.trackSwitcherButton.hidden = !self.playbackController.currentMediaHasTrackToChooseFrom;
......
......@@ -2,7 +2,7 @@
* VLCMovieViewController.h
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013-2015 VideoLAN. All rights reserved.
* Copyright (c) 2013-2017 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
......@@ -20,7 +20,7 @@
@class VLCHorizontalSwipeGestureRecognizer;
@class VLCVerticalSwipeGestureRecognizer;
@class VLCTimeNavigationTitleView;
@class VLCMovieViewControlPanelViewController;
@class VLCMovieViewControlPanelView;
typedef NS_ENUM(NSInteger, VLCMovieJumpState) {
VLCMovieJumpStateDefault,
......@@ -35,7 +35,7 @@ typedef NS_ENUM(NSInteger, VLCMovieJumpState) {
@property (nonatomic, strong) IBOutlet VLCTimeNavigationTitleView *timeNavigationTitleView;
@property (nonatomic, strong) IBOutlet UIButton *sleepTimerButton;
@property (nonatomic, strong) IBOutlet UINavigationBar *toolbar;
@property (nonatomic, strong) IBOutlet UIView *controllerPanel;
@property (nonatomic, strong) IBOutlet VLCMovieViewControlPanelView *controllerPanel;
@property (nonatomic, strong) IBOutlet VLCStatusLabel *statusLabel;
@property (nonatomic, strong) IBOutlet UIView *playingExternallyView;
......@@ -75,8 +75,6 @@ typedef NS_ENUM(NSInteger, VLCMovieJumpState) {
@property (nonatomic, strong) IBOutlet UILabel *trackNameLabel;
@property (nonatomic, strong) IBOutlet UIImageView *artworkImageView;
@property (nonatomic, weak) VLCMovieViewControlPanelViewController *controlPanelController;
- (IBAction)closePlayback:(id)sender;
- (IBAction)minimizePlayback:(id)sender;
......@@ -86,14 +84,8 @@ typedef NS_ENUM(NSInteger, VLCMovieJumpState) {
- (IBAction)positionSliderDrag:(id)sender;
- (IBAction)toggleTimeDisplay:(id)sender;
- (IBAction)playPause;
- (IBAction)backward:(id)sender;
- (IBAction)forward:(id)sender;
- (IBAction)switchTrack:(id)sender;
- (IBAction)sleepTimer:(id)sender;
- (IBAction)moreActions:(id)sender;
- (IBAction)videoFilterToggle:(id)sender;
- (IBAction)videoFilterSliderAction:(id)sender;
- (IBAction)playbackSliderAction:(id)sender;
......
......@@ -2,7 +2,7 @@
* VLCMovieViewController.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013-2015 VideoLAN. All rights reserved.
* Copyright (c) 2013-2017 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
......@@ -32,7 +32,7 @@
#import "VLCPlayerDisplayController.h"
#import "VLCAppDelegate.h"
#import "VLCStatusLabel.h"
#import "VLCMovieViewControlPanelViewController.h"
#import "VLCMovieViewControlPanelView.h"
#import "VLCSlider.h"
#import "VLCLibraryViewController.h"
......@@ -367,33 +367,55 @@ typedef NS_ENUM(NSInteger, VLCPanType) {
//Sleep Timer initialization
[self sleepTimerInitializer:deviceSpeedCategory];
[self setupControlPanel];
VLCMovieViewControlPanelViewController *panelVC = [[VLCMovieViewControlPanelViewController alloc] initWithNibName:@"VLCMovieViewControlPanel"
bundle:nil];
[self addChildViewController:panelVC];
[self.view addSubview:panelVC.view];
panelVC.view.translatesAutoresizingMaskIntoConstraints = NO;
CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale];
_screenSizePixel = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale);
_saveLocation = CGPointMake(-1.f, -1.f);
[self setupConstraints];
}
- (void)setupControlPanel
{
_controllerPanel = [[VLCMovieViewControlPanelView alloc] initWithFrame:CGRectZero];
[_controllerPanel.bwdButton addTarget:self action:@selector(backward:) forControlEvents:UIControlEventTouchUpInside];
[_controllerPanel.fwdButton addTarget:self action:@selector(forward:) forControlEvents:UIControlEventTouchUpInside];
[_controllerPanel.playPauseButton addTarget:self action:@selector(playPause) forControlEvents:UIControlEventTouchUpInside];
[_controllerPanel.moreActionsButton addTarget:self action:@selector(moreActions:) forControlEvents:UIControlEventTouchUpInside];
[_controllerPanel.playbackSpeedButton addTarget:self action:@selector(showPlaybackSpeedView) forControlEvents:UIControlEventTouchUpInside];
[_controllerPanel.trackSwitcherButton addTarget:self action:@selector(switchTrack:) forControlEvents:UIControlEventTouchUpInside];
[_controllerPanel.videoFilterButton addTarget:self action:@selector(videoFilterToggle:) forControlEvents:UIControlEventTouchUpInside];
// HACK: get the slider from volume view
UISlider *volumeSlider = nil;
for (id aView in _controllerPanel.volumeView.subviews){
if ([aView isKindOfClass:[UISlider class]]){
volumeSlider = (UISlider *)aView;
break;
}
}