Commit 3c9994f6 authored by Tobias's avatar Tobias

add dimming view while scrubbing

jump playback to scrubbed position with select button
cancel scrubbing by pressing menu button
fix buffering activity indicator
parent 20c1162d
......@@ -23,6 +23,7 @@
@property (readwrite, nonatomic, weak) IBOutlet UILabel *titleLabel;
@property (readwrite, nonatomic, weak) IBOutlet UILabel *bufferingLabel;
@property (readwrite, nonatomic, weak) IBOutlet UIActivityIndicatorView *activityIndicator;
@property (readwrite, nonatomic, weak) IBOutlet UIView *dimmingView;
+ (instancetype) fullscreenMovieTVViewController;
......
......@@ -47,6 +47,7 @@
self.transportBar.playbackFraction = 0.0;
self.transportBar.scrubbingFraction = 0.0;
self.dimmingView.alpha = 0.0;
self.bottomOverlayView.hidden = YES;
UITapGestureRecognizer *playpauseGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(playPausePressed)];
......@@ -56,10 +57,12 @@
UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGesture:)];
[self.view addGestureRecognizer:panGestureRecognizer];
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectTap:)];
tapGestureRecognizer.allowedPressTypes = @[@(UIPressTypeSelect)];
[self.view addGestureRecognizer:tapGestureRecognizer];
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];
}
#pragma mark - view events
......@@ -117,18 +120,14 @@
- (void)panGesture:(UIPanGestureRecognizer *)panGestureRecognizer
{
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
VLCTransportBar *bar = self.transportBar;
UIView *view = self.view;
CGPoint translation = [panGestureRecognizer translationInView:view];
if (!bar.scrubbing) {
if (translation.x > 100.0) {
bar.scrubbing = YES;
if (vpc.isPlaying) {
[vpc playPause];
}
if (ABS(translation.x) > 100.0) {
[self startScrubbing];
} else {
return;
}
......@@ -139,24 +138,90 @@
translation.x = 0.0;
[panGestureRecognizer setTranslation:translation inView:view];
CGFloat scrubbinFraction = MAX(0.0, MIN(bar.scrubbingFraction + fractionInView,1.0));
bar.scrubbingFraction = scrubbinFraction;
CGFloat scrubbingFraction = MAX(0.0, MIN(bar.scrubbingFraction + fractionInView,1.0));
bar.scrubbingFraction = scrubbingFraction;
[self updateTimeLabelsForScrubbingFraction:scrubbingFraction];
}
- (void)selectButtonPressed:(UITapGestureRecognizer *)recognizer
{
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
VLCTransportBar *bar = self.transportBar;
if (bar.scrubbing) {
[vpc.mediaPlayer setPosition:bar.scrubbingFraction];
[self stopScrubbing];
}
}
- (void)menuButtonPressed:(UITapGestureRecognizer *)recognizer
{
VLCTransportBar *bar = self.transportBar;
if (bar.scrubbing) {
[UIView animateWithDuration:0.3 animations:^{
bar.scrubbingFraction = bar.playbackFraction;
[bar layoutIfNeeded];
}];
[self updateTimeLabelsForScrubbingFraction:bar.playbackFraction];
[self stopScrubbing];
}
}
#pragma mark -
- (void)updateTimeLabelsForScrubbingFraction:(CGFloat)scrubbingFraction
{
VLCTransportBar *bar = self.transportBar;
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
// MAX 1, _ is ugly hack to prevent --:-- instead of 00:00
int scrubbingTimeInt = MAX(1,vpc.mediaDuration*scrubbinFraction);
int scrubbingTimeInt = MAX(1,vpc.mediaDuration*scrubbingFraction);
VLCTime *scrubbingTime = [VLCTime timeWithInt:scrubbingTimeInt];
bar.markerTimeLabel.text = [scrubbingTime stringValue];
VLCTime *remainingTime = [VLCTime timeWithInt:(int)vpc.mediaDuration-scrubbingTime.intValue];
bar.remainingTimeLabel.text = [remainingTime stringValue];
}
- (void)selectTap:(UITapGestureRecognizer *)recognizer
- (void)startScrubbing
{
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
VLCTransportBar *bar = self.transportBar;
if (bar.scrubbing) {
bar.scrubbing = NO;
[vpc.mediaPlayer setPosition:bar.scrubbingFraction];
[vpc.mediaPlayer play];
self.transportBar.scrubbing = YES;
[self updateDimmingView];
if (vpc.isPlaying) {
[vpc playPause];
}
}
- (void)stopScrubbing
{
self.transportBar.scrubbing = NO;
[self updateDimmingView];
VLCPlaybackController *vpc = [VLCPlaybackController sharedInstance];
[vpc.mediaPlayer play];
}
- (void)updateDimmingView
{
BOOL shouldBeVisible = self.transportBar.scrubbing;
BOOL isVisible = self.dimmingView.alpha == 1.0;
if (shouldBeVisible != isVisible) {
[UIView animateWithDuration:0.3 animations:^{
self.dimmingView.alpha = shouldBeVisible ? 1.0 : 0.0;
}];
}
}
- (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;
}
}
......@@ -179,20 +244,8 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
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;
}
[self updateActivityIndicatorForState:currentState];
if (controller.isPlaying && !self.bufferingLabel.hidden) {
[self.activityIndicator stopAnimating];
[UIView animateWithDuration:.3 animations:^{
self.bufferingLabel.hidden = YES;
self.bottomOverlayView.hidden = NO;
......@@ -213,6 +266,8 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
- (void)playbackPositionUpdated:(VLCPlaybackController *)controller
{
VLCMediaPlayer *mediaPlayer = [VLCPlaybackController sharedInstance].mediaPlayer;
// FIXME: hard coded state since the state in mediaPlayer is incorrectly still buffering
[self updateActivityIndicatorForState:VLCMediaPlayerStatePlaying];
VLCTransportBar *transportBar = self.transportBar;
transportBar.remainingTimeLabel.text = [[mediaPlayer remainingTime] stringValue];
......
......@@ -6,8 +6,10 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="VLCFullscreenMovieTVViewController">
<connections>
<outlet property="activityIndicator" destination="UcH-Yc-Sd0" id="9fo-IU-bbs"/>
<outlet property="bottomOverlayView" destination="SzB-KN-vRr" id="HdG-qX-fha"/>
<outlet property="bufferingLabel" destination="yaX-qU-D4t" id="pDV-iQ-eaa"/>
<outlet property="dimmingView" destination="VBa-d2-15H" id="5jE-Qy-meO"/>
<outlet property="movieView" destination="SpU-aa-czI" id="zKW-zZ-hB6"/>
<outlet property="preferredFocusedView" destination="iN0-l3-epB" id="obT-bV-VZv"/>
<outlet property="titleLabel" destination="epY-iV-5FH" id="7pR-09-6Fu"/>
......@@ -22,15 +24,14 @@
<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>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="VBa-d2-15H" userLabel="DimmingView">
<rect key="frame" x="0.0" y="0.0" width="1920" height="886"/>
<animations/>
<color key="backgroundColor" white="0.0" alpha="0.20000000000000001" colorSpace="calibratedWhite"/>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Please wait" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yaX-qU-D4t">
<rect key="frame" x="815" y="506" width="289" height="69"/>
<animations/>
......@@ -38,11 +39,15 @@
<color key="textColor" red="1" green="1" blue="1" alpha="0.59999999999999998" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<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="583" width="64" height="64"/>
<animations/>
</activityIndicatorView>
<view userInteractionEnabled="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="SzB-KN-vRr" customClass="VLCFrostedGlasView">
<rect key="frame" x="0.0" y="886" width="1920" height="194"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="epY-iV-5FH">
<rect key="frame" x="890" y="10" width="140" height="69"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="epY-iV-5FH">
<rect key="frame" x="960" y="10" width="0.0" height="69"/>
<animations/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="69" id="Cum-M9-lbH"/>
......@@ -76,15 +81,19 @@
<constraints>
<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 firstAttribute="trailing" secondItem="VBa-d2-15H" secondAttribute="trailing" id="5Pl-VN-MrE"/>
<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 firstItem="VBa-d2-15H" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="IZO-1L-Mhz"/>
<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="UcH-Yc-Sd0" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="WUO-qL-8wn"/>
<constraint firstItem="SpU-aa-czI" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="XAU-E6-19A"/>
<constraint firstItem="SzB-KN-vRr" firstAttribute="top" secondItem="VBa-d2-15H" secondAttribute="bottom" id="dwd-A2-fZz"/>
<constraint firstItem="yaX-qU-D4t" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="ecl-IU-ALU"/>
<constraint firstItem="UcH-Yc-Sd0" firstAttribute="top" secondItem="yaX-qU-D4t" secondAttribute="bottom" constant="8" symbolic="YES" id="jWW-Sc-AHB"/>
<constraint firstAttribute="trailing" secondItem="SpU-aa-czI" secondAttribute="trailing" id="loH-43-lbw"/>
<constraint firstItem="VBa-d2-15H" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="qef-Wc-yeD"/>
</constraints>
</view>
</objects>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment