iOS播放器视频亮度和音量展示

2019-04-29  本文已影响0人  子小每文

1:控制器界面进行提前加载View;

pragma mark --- 判断是点击还是滑动

    if (currentLocation.y - prevLocation.y  != 0) {
        _gestureType = GestureTypeOfVolume;
    } else {
        _gestureType = GestureTypeOfNone;
    }
}
else if ((currentLocation.x < frame.size.height*0.5) && (ABS(offset_x) <= ABS(offset_y)))
{
    if (currentLocation.y - prevLocation.y  != 0) {
    _gestureType = GestureTypeOfBrightness;
   } else {
    _gestureType = GestureTypeOfNone;
    }
}else if ((ABS(offset_x) > ABS(offset_y)))
{
    if (currentLocation.x - prevLocation.x  != 0) {
        _gestureType = GestureTypeOfProgress;
       // NSLog(@"进度");
    } else {
        _gestureType = GestureTypeOfNone;
        //finger touch went downwards
    }
}

if (_gestureType == GestureTypeOfProgress)
{
    if (ABS(offset_x)<1.0) {
        return;
    }
    self.mViewProgress.hidden = NO;
    if (offset_x < -2.0) {
        [self progressAdd:-progressStep];
        self.KProgressimage.image = [UIImage imageNamed:@"kuaitui"];
    }
    if (offset_x > 2.0) {
        [self progressAdd:progressStep];
        self.KProgressimage.image = [UIImage imageNamed:@"kuaijin"];
    }
}
else if (_gestureType == GestureTypeOfVolume)
{
    NSLog(@"上下滑动的距离 %f",offset_y);
    if (offset_y > 2.0)
    {
        [self volumeAdd:-VolumeStep];
    }else if (offset_y < -2.0)
    {
        [self volumeAdd:VolumeStep];
    }
    else{

    }
}else if (_gestureType == GestureTypeOfBrightness)
{
    if (offset_y > 0)
    {
        [self brightnessAdd:-VolumeStep];
    }else{
        [self brightnessAdd:VolumeStep];
    }
}

}
//音量调节

//下面是View展示UI的代码
//使用别人创建好的类,这个View创建的还可以,最好优化下就OK了

@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;
}

-(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 - 单例

pragma makr - Tips的创建

pragma mark - 状态栏方向改变当前View的方向,UI更新

pragma mark - Brightness显示

pragma mark -关闭时间

pragma mark - 亮度值展示

pragma mark - 刷新VIew

上一篇 下一篇

猜你喜欢

热点阅读