Commit 98ebf965 authored by Han Ruisong's avatar Han Ruisong
Browse files

升级到 4.4.2

1.播放页面新增手势调节功能。
parent a793c64c
No preview for this file type
This diff is collapsed.
......@@ -3,4 +3,46 @@
uuid = "D493E4A5-FF32-4C5D-B61B-0D88D4BD1AD4"
type = "1"
version = "2.0">
<<<<<<< .working
<<<<<<< .working
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "DE53A975-9630-4280-B01B-8814706A834B"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Demo/Classes/View/Player/DWVodPlayerPanGesture.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "67"
endingLineNumber = "67"
landmarkName = "-handlePan"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
=======
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "AFBDA185-F80C-4FB7-9C05-D31B5996C717"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Demo/Plugins/HDMarqueeView.m"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "118"
endingLineNumber = "118"
landmarkName = "-stopMarquee"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
=======
>>>>>>> .merge-right.r2371
>>>>>>> .merge-right.r2366
</Bucket>
......@@ -244,10 +244,7 @@
}
}
}
// if (CGRectGetMaxY(lastView.frame) > self.bgScrollView.frame.size.height) {
// self.bgScrollView.contentSize = CGSizeMake(self.view.frame.size.width, CGRectGetMaxY(lastView.frame));
// }
}
@end
//
// Created by zlcode on 2017/4/19.
// Copyright © 2017年 zlcode. All rights reserved.
//
#import <UIKit/UIKit.h>
#define ZLScreenWidth [UIScreen mainScreen].bounds.size.width
#define ZLScreenHeight [UIScreen mainScreen].bounds.size.height
#define ZLSystemVersion ([[[UIDevice currentDevice] systemVersion] floatValue])
@interface BrightnessView : UIView
+ (instancetype)sharedBrightnessView;
@end
//
// Created by zlcode on 2017/4/19.
// Copyright © 2017年 zlcode. All rights reserved.
//
#import "BrightnessView.h"
@interface BrightnessView ()
@property (nonatomic, strong) UIImageView *backImage;
@property (nonatomic, strong) UILabel *title;
@property (nonatomic, strong) UIView *brightnessLevelView;
@property (nonatomic, strong) NSMutableArray *tipArray;
@property (nonatomic, strong) NSTimer *timer;
@end
@implementation BrightnessView
#pragma mark - 懒加载
-(UILabel *)title {
if (!_title) {
_title = [[UILabel alloc] initWithFrame:CGRectMake(0, 5, self.bounds.size.width, 30)];
_title.font = [UIFont boldSystemFontOfSize:16];
_title.textColor = [UIColor colorWithRed:0.25f green:0.22f blue:0.21f alpha:1.00f];
_title.textAlignment = NSTextAlignmentCenter;
_title.text = @"亮度";
}
return _title;
}
- (UIImageView *)backImage {
if (!_backImage) {
_backImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 79, 76)];
_backImage.image = [UIImage imageNamed:@"brightness.png"];
}
return _backImage;
}
-(UIView *)brightnessLevelView {
if (!_brightnessLevelView) {
_brightnessLevelView = [[UIView alloc]initWithFrame:CGRectMake(13, 132, self.bounds.size.width - 26, 7)];
_brightnessLevelView.backgroundColor = [UIColor colorWithRed:0.25f green:0.22f blue:0.21f alpha:1.00f];
[self addSubview:_brightnessLevelView];
}
return _brightnessLevelView;
}
#pragma mark - 单例
+ (instancetype)sharedBrightnessView {
static BrightnessView *instance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [[BrightnessView alloc] init];
[[[UIApplication sharedApplication].windows firstObject] addSubview:instance];
});
return instance;
}
- (instancetype)init {
if (self = [super init]) {
[self setupUI];
}
return self;
}
- (void)setupUI {
self.frame = CGRectMake(ZLScreenWidth * 0.5, ZLScreenHeight * 0.5 - 20, 155, 155);
self.layer.cornerRadius = 10;
self.layer.masksToBounds = YES;
// 毛玻璃效果
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:self.bounds];
[self addSubview:toolbar];
[self addSubview:self.backImage];
[self addSubview:self.title];
[self addSubview:self.brightnessLevelView];
[self createTips];
[self addStatusBarNotification];
[self addKVOObserver];
self.alpha = 0.0;
}
#pragma makr - 创建 Tips
- (void)createTips {
self.tipArray = [NSMutableArray arrayWithCapacity:16];
CGFloat tipW = (self.brightnessLevelView.bounds.size.width - 17) / 16;
CGFloat tipH = 5;
CGFloat tipY = 1;
for (int i = 0; i < 16; i++) {
CGFloat tipX = i * (tipW + 1) + 1;
UIImageView *image = [[UIImageView alloc] init];
image.backgroundColor = [UIColor whiteColor];
image.frame = CGRectMake(tipX, tipY, tipW, tipH);
[self.brightnessLevelView addSubview:image];
[self.tipArray addObject:image];
}
[self updateBrightnessLevel:[UIScreen mainScreen].brightness];
}
#pragma makr - 通知 KVO
- (void)addStatusBarNotification {
/** 注册 UIApplicationDidChangeStatusBarOrientationNotification -状态栏方向改变
*/
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(statusBarOrientationNotification:)
name:UIApplicationDidChangeStatusBarOrientationNotification
object:nil];
}
- (void)addKVOObserver {
[[UIScreen mainScreen] addObserver:self
forKeyPath:@"brightness"
options:NSKeyValueObservingOptionNew context:NULL];
}
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
CGFloat levelValue = [change[@"new"] floatValue];
[self removeTimer];
[self appearBrightnessView];
[self updateBrightnessLevel:levelValue];
}
#pragma mark - 状态栏方向改变通知
- (void)statusBarOrientationNotification:(NSNotification *)notify {
[self setNeedsLayout];
}
#pragma mark - Brightness显示 隐藏
- (void)appearBrightnessView {
[UIView animateWithDuration:0.5 animations:^{
self.alpha = 1;
} completion:^(BOOL finished) {
[self addtimer];
}];
}
- (void)disAppearBrightnessView {
if (self.alpha == 1.0) {
[UIView animateWithDuration:0.5 animations:^{
self.alpha = 0.0;
} completion:^(BOOL finished) {
[self removeTimer];
}];
}
}
#pragma mark - 定时器
- (void)addtimer {
if (self.timer) {
return;
}
self.timer = [NSTimer timerWithTimeInterval:2
target:self
selector:@selector(disAppearBrightnessView)
userInfo:nil
repeats:NO];
[[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSDefaultRunLoopMode];
}
- (void)removeTimer{
[self.timer invalidate];
self.timer = nil;
}
#pragma mark - 更新亮度值
- (void)updateBrightnessLevel:(CGFloat)brightnessLevel {
CGFloat stage = 1 / 15.0;
NSInteger level = brightnessLevel / stage;
for (int i = 0; i < self.tipArray.count; i++) {
UIImageView *img = self.tipArray[i];
if (i <= level) {
img.hidden = NO;
} else {
img.hidden = YES;
}
}
}
#pragma mark - 更新布局
- (void)layoutSubviews {
[super layoutSubviews];
//InterfaceOrientation值
UIInterfaceOrientation currInterfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
switch (currInterfaceOrientation)
{
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
{
self.center = CGPointMake(ZLScreenWidth * 0.5, (ZLScreenHeight - 10) * 0.5);
}
break;
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
{
self.center = CGPointMake(ZLScreenWidth * 0.5, (ZLScreenHeight) * 0.5);
}
break;
default:
break;
}
self.backImage.center = CGPointMake(155 * 0.5, 155 * 0.5);
[self.superview bringSubviewToFront:self];
}
#pragma mark - 销毁
- (void)dealloc {
[[UIScreen mainScreen] removeObserver:self forKeyPath:@"brightness"];
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end
//
// DWPlayerTimeSilder.h
// BrightnessVolumeView
//
// Created by zwl on 2020/3/12.
// Copyright © 2020 admin. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface DWPlayerTimeSilder : UIView
@property(nonatomic,assign)CGFloat duration;
@property(nonatomic,assign)CGFloat progress;
@end
//
// DWPlayerTimeSilder.m
// BrightnessVolumeView
//
// Created by zwl on 2020/3/12.
// Copyright © 2020 admin. All rights reserved.
//
#import "DWPlayerTimeSilder.h"
@interface DWPlayerTimeSilder ()
@property(nonatomic,strong)UILabel * timeLabel;
@property(nonatomic,strong)UIView * progressView;
@end
@implementation DWPlayerTimeSilder
- (instancetype)init
{
self = [super init];
if (self) {
self.timeLabel = [[UILabel alloc]init];
self.timeLabel.font = [UIFont systemFontOfSize:12];
self.timeLabel.textColor = [UIColor colorWithRed:255/255.0 green:146/255.0 blue:10/255.0 alpha:0.8];
self.timeLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.timeLabel];
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.and.top.equalTo(@0);
make.width.equalTo(self);
make.height.equalTo(@12);
}];
UIView * bgView = [[UIView alloc]init];
bgView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.8];
bgView.layer.masksToBounds = YES;
bgView.layer.cornerRadius = 1.5;
[self addSubview:bgView];
[bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.and.bottom.equalTo(@0);
make.width.equalTo(self);
make.height.equalTo(@4);
}];
self.progressView = [[UIView alloc]init];
self.progressView.backgroundColor = [UIColor colorWithRed:255/255.0 green:146/255.0 blue:10/255.0 alpha:0.8];
[bgView addSubview:self.progressView];
[self.progressView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(@0);
make.top.equalTo(@0);
make.height.equalTo(bgView);
make.width.equalTo(@0);
}];
}
return self;
}
-(void)setDuration:(CGFloat)duration
{
_duration = duration;
NSString * time = [NSString stringWithFormat:@"00:00 / %@", [DWTools formatSecondsToString:duration]];
self.timeLabel.text = time;
[self.progressView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.equalTo(@0);
}];
}
-(void)setProgress:(CGFloat)progress
{
_progress = progress;
NSString * time = [NSString stringWithFormat:@"%@ / %@",[DWTools formatSecondsToString:self.duration * progress],[DWTools formatSecondsToString:self.duration]];
self.timeLabel.text = time;
//修改进度
[self.progressView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.equalTo(@(self.frame.size.width * progress));
}];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
// Drawing code
}
*/
@end
//
// DWVodPlayerPanGesture.h
// BrightnessVolumeView
//
// Created by zwl on 2020/3/11.
// Copyright © 2020 admin. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSUInteger, DWVodPlayerPanGestureStatus) {
DWVodPlayerPanGestureStatusNone,//无
DWVodPlayerPanGestureStatusVolume,//音量调节
DWVodPlayerPanGestureStatusBrightness,//亮度调节
DWVodPlayerPanGestureStatusFast,//快进
DWVodPlayerPanGestureStatusRewind //快退
};
@protocol DWVodPlayerPanGestureDelegate <NSObject>
//左右滑动事件结束
-(void)playerPanHandleEnd:(CGFloat)sliderProgress;
@end
@interface DWVodPlayerPanGesture : UIPanGestureRecognizer
-(instancetype)initWithFatherView:(UIView *)fatherView;
@property(nonatomic,assign)CGFloat duration;
@property(nonatomic,assign)CGFloat progress;
@property(nonatomic,assign)BOOL canResponse;
@property(nonatomic,weak) id <DWVodPlayerPanGestureDelegate> vodPanDelegate;
@end
//
// DWVodPlayerPanGesture.m
// BrightnessVolumeView
//
// Created by zwl on 2020/3/11.
// Copyright © 2020 admin. All rights reserved.
//
#import "DWVodPlayerPanGesture.h"
#import "DWPlayerTimeSilder.h"
#import <MediaPlayer/MediaPlayer.h>
#import "BrightnessView.h"
@interface DWVodPlayerPanGesture ()
@property(nonatomic,assign)DWVodPlayerPanGestureStatus status;
@property(nonatomic,weak)UIView * fatherView;
//手势落点
@property(nonatomic,assign)CGPoint location;
@property(nonatomic,strong)DWPlayerTimeSilder * timeSilder;
@property(nonatomic,assign)CGFloat lastProgress;
@property(nonatomic,strong)UISlider * volumeSlider;
@property(nonatomic,assign)CGFloat lastVolume;
@property(nonatomic,assign)CGFloat lastBrightness;
@end
@implementation DWVodPlayerPanGesture
-(instancetype)initWithFatherView:(UIView *)fatherView
{
self = [super init];
if (self) {
self.fatherView = fatherView;
self.canResponse = YES;
[self addTarget:self action:@selector(handlePan)];
[self.fatherView addGestureRecognizer:self];
self.status = DWVodPlayerPanGestureStatusNone;
[BrightnessView sharedBrightnessView];
}
return self;
}
-(void)setDuration:(CGFloat)duration
{
_duration = duration;
self.timeSilder.duration = duration;
}
-(void)handlePan
{
//外部是否禁用手势
if (!self.canResponse) {
return;
}
//只在横屏状态下,相应手势
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
UIInterfaceOrientation interfaceOrientation = (UIInterfaceOrientation)orientation;
if (!(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)) {
return;
}
//这个用于判断落点是在左边还是右边,判断音量 or 亮度
CGPoint position = [self translationInView:self.view];
CGFloat absX = fabs(position.x);
CGFloat absY = fabs(position.y);
switch (self.state) {
case UIGestureRecognizerStateBegan:
{
self.location = [self locationInView:self.view];
self.lastProgress = self.progress;
if (absX > absY) {
//左右滑动
if (position.x < 0) {
//向左滑动
self.status = DWVodPlayerPanGestureStatusRewind;
}else{
//向右滑动
self.status = DWVodPlayerPanGestureStatusFast;
}
if (self.duration == 0) {
return;
}
self.timeSilder.hidden = NO;
self.timeSilder.progress = self.lastProgress;
} else{
//上下滑动
if (self.location.x <= CGRectGetWidth(self.view.frame) * 0.5) {
//亮度
self.status = DWVodPlayerPanGestureStatusBrightness;
self.lastBrightness = [UIScreen mainScreen].brightness;
}else{
//音量
self.status = DWVodPlayerPanGestureStatusVolume;
self.lastVolume = [self getCurrentVolume];
}
}
// NSLog(@"status %ld",self.status);
}
break;
case UIGestureRecognizerStateChanged:
{
[self gestureChange:position];
}
break;