Commit 1a92e35f authored by Felix Paul Kühne's avatar Felix Paul Kühne

Add equalizer UI (refs #9032)

It currently lacks a button for profile selection, labels for each slider and a button to bring-up the UI on iPhone
parent 7319b0b4
......@@ -171,7 +171,7 @@
</navigationItem>
</items>
</navigationBar>
<view hidden="YES" contentMode="scaleToFill" id="242" userLabel="Controls panel" customClass="VLCFrostedGlasView">
<view hidden="YES" contentMode="scaleToFill" id="242" userLabel="Scrubbing info" customClass="VLCFrostedGlasView">
<rect key="frame" x="0.0" y="63" width="768" height="46"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<subviews>
......@@ -192,7 +192,7 @@
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.60999999999999999" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<view contentMode="scaleToFill" id="176" userLabel="Controls panel" customClass="VLCFrostedGlasView">
<view contentMode="scaleToFill" id="176" userLabel="Delays &amp; Speed" customClass="VLCFrostedGlasView">
<rect key="frame" x="123" y="849" width="320" height="122"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
......@@ -295,7 +295,7 @@
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" id="272" userLabel="Controls panel" customClass="VLCFrostedGlasView">
<view contentMode="scaleToFill" id="272" userLabel="Toolbar" customClass="VLCFrostedGlasView">
<rect key="frame" x="0.0" y="974" width="768" height="50"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<subviews>
......@@ -450,9 +450,20 @@
<action selector="switchChapter:" destination="-1" eventType="touchUpInside" id="NHE-kB-Qpz"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="iAS-0C-clq">
<rect key="frame" x="657" y="6" width="32" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="22"/>
<inset key="contentEdgeInsets" minX="0.0" minY="4" maxX="0.0" maxY="4"/>
<state key="normal" title="E"/>
<connections>
<action selector="equalizer:" destination="-2" eventType="touchUpInside" id="fpe-ay-cLY"/>
</connections>
</button>
</subviews>
</view>
<view contentMode="scaleToFill" id="141" userLabel="Controls panel" customClass="VLCFrostedGlasView">
<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"/>
<subviews>
......
/*****************************************************************************
* VLCEqualizerView.h
* VLC for iOS
*****************************************************************************
* Copyright (c) 2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan dot org>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import <UIKit/UIKit.h>
#import "VLCFrostedGlasView.h"
@protocol VLCEqualizerViewDelegate <NSObject>
@required
@property (readwrite) CGFloat preAmplification;
- (void)setAmplification:(CGFloat)amplification forBand:(unsigned)index;
- (CGFloat)amplificationOfBand:(unsigned)index;
- (NSArray *)equalizerProfiles;
- (void)resetEqualizerFromProfile:(unsigned)profile;
@end
@interface VLCEqualizerView : VLCFrostedGlasView
@property (weak) id <VLCEqualizerViewDelegate>delegate;
- (void)reloadData;
@end
/*****************************************************************************
* VLCEqualizerView.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan dot org>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCEqualizerView.h"
@interface VLCEqualizerView ()
{
UISlider *_preAmp_slider;
UISlider *_60_slider;
UISlider *_170_slider;
UISlider *_310_slider;
UISlider *_600_slider;
UISlider *_1K_slider;
UISlider *_3K_slider;
UISlider *_6K_slider;
UISlider *_12K_slider;
UISlider *_14K_slider;
UISlider *_16K_slider;
}
@end
@implementation VLCEqualizerView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (!self)
return self;
#define horizontal_padding 6.
#define vertical_padding 8.
#define spacer 8.
CGFloat sliderHeight = frame.size.height - (vertical_padding * 2.);
CGFloat sliderWidth = (frame.size.width - (spacer * 10.)) / 11.;
CGFloat sliderY = (sliderHeight / 2.) - horizontal_padding;
_preAmp_slider = [[UISlider alloc] initWithFrame:CGRectMake(-sliderWidth + horizontal_padding, sliderY, sliderHeight, sliderWidth)];
_preAmp_slider.transform = CGAffineTransformMakeRotation(-M_PI_2);
_preAmp_slider.minimumValue = -20.;
_preAmp_slider.maximumValue = 20.;
[_preAmp_slider addTarget:self action:@selector(preampSliderChangedValue:) forControlEvents:UIControlEventValueChanged];
[self addSubview:_preAmp_slider];
_60_slider = [[UISlider alloc] initWithFrame:CGRectMake(horizontal_padding * 2., sliderY, sliderHeight, sliderWidth)];
_60_slider.transform = CGAffineTransformMakeRotation(-M_PI_2);
_60_slider.tag = 0;
_60_slider.minimumValue = -20.;
_60_slider.maximumValue = 20.;
[_60_slider addTarget:self action:@selector(sliderChangedValue:) forControlEvents:UIControlEventValueChanged];
[self addSubview:_60_slider];
_170_slider = [[UISlider alloc] initWithFrame:CGRectMake(horizontal_padding * 3. + sliderWidth, sliderY, sliderHeight, sliderWidth)];
_170_slider.transform = CGAffineTransformMakeRotation(-M_PI_2);
_170_slider.tag = 1;
_170_slider.minimumValue = -20.;
_170_slider.maximumValue = 20.;
[_170_slider addTarget:self action:@selector(sliderChangedValue:) forControlEvents:UIControlEventValueChanged];
[self addSubview:_170_slider];
_310_slider = [[UISlider alloc] initWithFrame:CGRectMake(horizontal_padding * 4. + sliderWidth * 2., sliderY, sliderHeight, sliderWidth)];
_310_slider.transform = CGAffineTransformMakeRotation(-M_PI_2);
_310_slider.tag = 2;
_310_slider.minimumValue = -20.;
_310_slider.maximumValue = 20.;
[_310_slider addTarget:self action:@selector(sliderChangedValue:) forControlEvents:UIControlEventValueChanged];
[self addSubview:_310_slider];
_600_slider = [[UISlider alloc] initWithFrame:CGRectMake(horizontal_padding * 5. + sliderWidth * 3., sliderY, sliderHeight, sliderWidth)];
_600_slider.transform = CGAffineTransformMakeRotation(-M_PI_2);
_600_slider.tag = 3;
_600_slider.minimumValue = -20.;
_600_slider.maximumValue = 20.;
[_600_slider addTarget:self action:@selector(sliderChangedValue:) forControlEvents:UIControlEventValueChanged];
[self addSubview:_600_slider];
_1K_slider = [[UISlider alloc] initWithFrame:CGRectMake(horizontal_padding * 6. + sliderWidth * 4., sliderY, sliderHeight, sliderWidth)];
_1K_slider.transform = CGAffineTransformMakeRotation(-M_PI_2);
_1K_slider.tag = 4;
_1K_slider.minimumValue = -20.;
_1K_slider.maximumValue = 20.;
[_1K_slider addTarget:self action:@selector(sliderChangedValue:) forControlEvents:UIControlEventValueChanged];
[self addSubview:_1K_slider];
_3K_slider = [[UISlider alloc] initWithFrame:CGRectMake(horizontal_padding * 7. + sliderWidth * 5., sliderY, sliderHeight, sliderWidth)];
_3K_slider.transform = CGAffineTransformMakeRotation(-M_PI_2);
_3K_slider.tag = 5;
_3K_slider.minimumValue = -20.;
_3K_slider.maximumValue = 20.;
[_3K_slider addTarget:self action:@selector(sliderChangedValue:) forControlEvents:UIControlEventValueChanged];
[self addSubview:_3K_slider];
_6K_slider = [[UISlider alloc] initWithFrame:CGRectMake(horizontal_padding * 8. + sliderWidth * 6., sliderY, sliderHeight, sliderWidth)];
_6K_slider.transform = CGAffineTransformMakeRotation(-M_PI_2);
_6K_slider.tag = 6;
_6K_slider.minimumValue = -20.;
_6K_slider.maximumValue = 20.;
[_6K_slider addTarget:self action:@selector(sliderChangedValue:) forControlEvents:UIControlEventValueChanged];
[self addSubview:_6K_slider];
_12K_slider = [[UISlider alloc] initWithFrame:CGRectMake(horizontal_padding * 9. + sliderWidth * 7., sliderY, sliderHeight, sliderWidth)];
_12K_slider.transform = CGAffineTransformMakeRotation(-M_PI_2);
_12K_slider.tag = 7;
_12K_slider.minimumValue = -20.;
_12K_slider.maximumValue = 20.;
[_12K_slider addTarget:self action:@selector(sliderChangedValue:) forControlEvents:UIControlEventValueChanged];
[self addSubview:_12K_slider],
_14K_slider = [[UISlider alloc] initWithFrame:CGRectMake(horizontal_padding * 10. + sliderWidth * 8., sliderY, sliderHeight, sliderWidth)];
_14K_slider.transform = CGAffineTransformMakeRotation(-M_PI_2);
_14K_slider.tag = 8;
_14K_slider.minimumValue = -20.;
_14K_slider.maximumValue = 20.;
[_14K_slider addTarget:self action:@selector(sliderChangedValue:) forControlEvents:UIControlEventValueChanged];
[self addSubview:_14K_slider];
_16K_slider = [[UISlider alloc] initWithFrame:CGRectMake(horizontal_padding * 11. + sliderWidth * 9., sliderY, sliderHeight, sliderWidth)];
_16K_slider.transform = CGAffineTransformMakeRotation(-M_PI_2);
_16K_slider.tag = 9;
_16K_slider.minimumValue = -20.;
_16K_slider.maximumValue = 20.;
[_16K_slider addTarget:self action:@selector(sliderChangedValue:) forControlEvents:UIControlEventValueChanged];
[self addSubview:_16K_slider];
return self;
}
- (IBAction)sliderChangedValue:(UISlider *)sender
{
if (self.delegate)
[self.delegate setAmplification:[sender value] forBand:[sender tag]];
}
- (IBAction)preampSliderChangedValue:(UISlider *)sender
{
if (self.delegate)
[self.delegate setPreAmplification:sender.value];
}
- (void)reloadData
{
if (self.delegate) {
_preAmp_slider.value = [self.delegate preAmplification];
_60_slider.value = [self.delegate amplificationOfBand:0];
_170_slider.value = [self.delegate amplificationOfBand:1];
_310_slider.value = [self.delegate amplificationOfBand:2];
_600_slider.value = [self.delegate amplificationOfBand:3];
_1K_slider.value = [self.delegate amplificationOfBand:4];
_3K_slider.value = [self.delegate amplificationOfBand:5];
_6K_slider.value = [self.delegate amplificationOfBand:6];
_12K_slider.value = [self.delegate amplificationOfBand:7];
_14K_slider.value = [self.delegate amplificationOfBand:8];
_16K_slider.value = [self.delegate amplificationOfBand:9];
}
}
@end
......@@ -2,7 +2,7 @@
* VLCMovieViewController.h
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013-2014 VideoLAN. All rights reserved.
* Copyright (c) 2013-2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
......@@ -39,6 +39,7 @@
@property (nonatomic, strong) IBOutlet UIButton *lockButtonLandscape;
@property (nonatomic, strong) IBOutlet UIButton *chapterButton;
@property (nonatomic, strong) IBOutlet UIButton *chapterButtonLandscape;
@property (nonatomic, strong) IBOutlet UIButton *equalizerButton;
@property (nonatomic, strong) IBOutlet UINavigationBar *toolbar;
@property (nonatomic, strong) IBOutlet VLCFrostedGlasView *controllerPanel;
@property (nonatomic, strong) IBOutlet VLCFrostedGlasView *controllerPanelLandscape;
......@@ -110,6 +111,7 @@
- (IBAction)switchTrack:(id)sender;
- (IBAction)lock:(id)sender;
- (IBAction)switchChapter:(id)sender;
- (IBAction)equalizer:(id)sender;
- (IBAction)videoFilterToggle:(id)sender;
- (IBAction)videoFilterSliderAction:(id)sender;
......
......@@ -2,7 +2,7 @@
* VLCMovieViewController.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013-2014 VideoLAN. All rights reserved.
* Copyright (c) 2013-2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
......@@ -24,6 +24,7 @@
#import "VLCThumbnailsCache.h"
#import "VLCTrackSelectorTableViewCell.h"
#import "VLCTrackSelectorHeaderView.h"
#import "VLCEqualizerView.h"
#import "OBSlider.h"
#import "VLCStatusLabel.h"
......@@ -39,7 +40,7 @@
if (_interfaceIsLocked) \
return
@interface VLCMovieViewController () <UIGestureRecognizerDelegate, AVAudioSessionDelegate, VLCMediaDelegate, UITableViewDataSource, UITableViewDelegate>
@interface VLCMovieViewController () <UIGestureRecognizerDelegate, AVAudioSessionDelegate, VLCMediaDelegate, UITableViewDataSource, UITableViewDelegate, VLCEqualizerViewDelegate>
{
VLCMediaListPlayer *_listPlayer;
VLCMediaPlayer *_mediaPlayer;
......@@ -76,6 +77,8 @@ return
UIView *_trackSelectorContainer;
UITableView *_trackSelectorTableView;
VLCEqualizerView *_equalizerView;
}
@property (nonatomic, strong) UIPopoverController *masterPopoverController;
......@@ -387,6 +390,12 @@ return
_trackSelectorTableView.backgroundColor = [UIColor blackColor];
[self.view addSubview:_trackSelectorContainer];
_equalizerView = [[VLCEqualizerView alloc] initWithFrame:CGRectMake((rect.size.width - 450.) / 2., self.controllerPanel.frame.origin.y - 120., 450., 120.)];
_equalizerView.delegate = self;
_equalizerView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
_equalizerView.hidden = YES;
[self.view addSubview:_equalizerView];
}
- (BOOL)_blobCheck
......@@ -467,7 +476,7 @@ return
if (self.pathToExternalSubtitlesFile)
_listPlayer = [[VLCMediaListPlayer alloc] initWithOptions:@[[NSString stringWithFormat:@"--%@=%@", kVLCSettingSubtitlesFilePath, self.pathToExternalSubtitlesFile]]];
else
_listPlayer = [[VLCMediaListPlayer alloc] init];
_listPlayer = [[VLCMediaListPlayer alloc] initWithOptions:@[@"-vvvv"]];
_mediaPlayer = _listPlayer.mediaPlayer;
[_mediaPlayer setDelegate:self];
......@@ -881,6 +890,8 @@ return
_playbackSpeedView.hidden = _playbackSpeedViewHidden;
_trackSelectorContainer.alpha = 0.0f;
_trackSelectorContainer.hidden = YES;
_equalizerView.alpha = 0.0f;
_equalizerView.hidden = YES;
}
void (^animationBlock)() = ^() {
......@@ -890,6 +901,7 @@ return
_videoFilterView.alpha = alpha;
_playbackSpeedView.alpha = alpha;
_trackSelectorContainer.alpha = alpha;
_equalizerView.alpha = alpha;
};
void (^completionBlock)(BOOL finished) = ^(BOOL finished) {
......@@ -899,6 +911,7 @@ return
_videoFilterView.hidden = _videoFiltersHidden;
_playbackSpeedView.hidden = _playbackSpeedViewHidden;
_trackSelectorContainer.hidden = YES;
_equalizerView.hidden = YES;
};
UIStatusBarAnimation animationType = animated? UIStatusBarAnimationFade: UIStatusBarAnimationNone;
......@@ -1208,6 +1221,28 @@ return
_interfaceIsLocked = !_interfaceIsLocked;
}
- (IBAction)equalizer:(id)sender
{
LOCKCHECK;
if (_equalizerView.hidden) {
if (!_playbackSpeedViewHidden)
self.playbackSpeedView.hidden = _playbackSpeedViewHidden = YES;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
if (!_controlsHidden) {
self.controllerPanel.hidden = _controlsHidden = YES;
self.controllerPanelLandscape.hidden = YES;
}
}
self.videoFilterView.hidden = _videoFiltersHidden = YES;
_equalizerView.alpha = 1.;
_equalizerView.hidden = NO;
} else
_equalizerView.hidden = YES;
}
#pragma mark - track selector table view
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
......@@ -1546,6 +1581,44 @@ return
[self _resetIdleTimer];
}
#pragma mark - equalizer
- (void)setAmplification:(CGFloat)amplification forBand:(unsigned int)index
{
[self _resetIdleTimer];
if (!_mediaPlayer.equalizerEnabled)
[_mediaPlayer setEqualizerEnabled:YES];
[_mediaPlayer setAmplification:amplification forBand:index];
}
- (CGFloat)amplificationOfBand:(unsigned int)index
{
return [_mediaPlayer amplificationOfBand:index];
}
- (NSArray *)equalizerProfiles
{
return _mediaPlayer.equalizerProfiles;
}
- (void)resetEqualizerFromProfile:(unsigned int)profile
{
[_mediaPlayer resetEqualizerFromProfile:profile];
}
- (void)setPreAmplification:(CGFloat)preAmplification
{
[self _resetIdleTimer];
[_mediaPlayer setPreAmplification:preAmplification];
}
- (CGFloat)preAmplification
{
return [_mediaPlayer preAmplification];
}
#pragma mark - playback view
- (IBAction)playbackSliderAction:(UISlider *)sender
{
......
......@@ -211,6 +211,7 @@
7D3784E9183A9A15009EE944 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D3784E8183A9A15009EE944 /* main.m */; };
7D3E6CE518589EE000D584E7 /* AppIcon512x512.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D3E6CE418589EE000D584E7 /* AppIcon512x512.png */; };
7D3EB014174A353E002062C2 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D3EB013174A353E002062C2 /* SystemConfiguration.framework */; };
7D4625881A5614A1001A80B4 /* VLCEqualizerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D4625871A5614A1001A80B4 /* VLCEqualizerView.m */; };
7D47D6F91760CD8700E86BAD /* subtitleIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D47D6CB1760CD8700E86BAD /* subtitleIcon.png */; };
7D47D6FA1760CD8700E86BAD /* subtitleIcon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D47D6CC1760CD8700E86BAD /* subtitleIcon@2x.png */; };
7D47D6FB1760CD8700E86BAD /* videoEffectsIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 7D47D6CD1760CD8700E86BAD /* videoEffectsIcon.png */; };
......@@ -856,6 +857,8 @@
7D4136641896710500D7B4B2 /* si */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = si; path = "si.lproj/badgeUnread@2x~iphone.png"; sourceTree = "<group>"; };
7D4136651896710500D7B4B2 /* si */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = si; path = "si.lproj/badgeUnread~ipad.png"; sourceTree = "<group>"; };
7D4136661896710500D7B4B2 /* si */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = si; path = "si.lproj/badgeUnread~iphone.png"; sourceTree = "<group>"; };
7D4625861A5614A1001A80B4 /* VLCEqualizerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCEqualizerView.h; path = Sources/VLCEqualizerView.h; sourceTree = SOURCE_ROOT; };
7D4625871A5614A1001A80B4 /* VLCEqualizerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCEqualizerView.m; path = Sources/VLCEqualizerView.m; sourceTree = SOURCE_ROOT; };
7D47D6CB1760CD8700E86BAD /* subtitleIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = subtitleIcon.png; sourceTree = "<group>"; };
7D47D6CC1760CD8700E86BAD /* subtitleIcon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "subtitleIcon@2x.png"; sourceTree = "<group>"; };
7D47D6CD1760CD8700E86BAD /* videoEffectsIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = videoEffectsIcon.png; sourceTree = "<group>"; };
......@@ -1938,6 +1941,8 @@
7D37848E183A98B6009EE944 /* VLCMovieViewController.m */,
7D378490183A98BF009EE944 /* VLCExternalDisplayController.h */,
7D378491183A98BF009EE944 /* VLCExternalDisplayController.m */,
7D4625861A5614A1001A80B4 /* VLCEqualizerView.h */,
7D4625871A5614A1001A80B4 /* VLCEqualizerView.m */,
7D5CAA871A4AD763003F2CBC /* VLCTrackSelectorTableViewCell.h */,
7D5CAA881A4AD763003F2CBC /* VLCTrackSelectorTableViewCell.m */,
7D5CAA8A1A4AD8E5003F2CBC /* VLCTrackSelectorHeaderView.h */,
......@@ -3188,6 +3193,7 @@
7D3784BE183A9938009EE944 /* UIBarButtonItem+Theme.m in Sources */,
41B93C051A53835300102E8B /* VLCCloudServiceCell.m in Sources */,
7D3784BF183A9938009EE944 /* UINavigationController+Theme.m in Sources */,
7D4625881A5614A1001A80B4 /* VLCEqualizerView.m in Sources */,
7DF9352F1958AB0600E60FD4 /* UIColor+Presets.m in Sources */,
7D50903218F41C7900180139 /* VLCAlertView.m in Sources */,
7DBBF182183AB3B80009A339 /* VLCAppDelegate.m in Sources */,
......
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