This commit is contained in:
lianxiang
2018-10-19 20:23:26 +08:00
parent e06dc32099
commit d845ed2cb0
12 changed files with 255 additions and 49 deletions
@@ -36,10 +36,11 @@
#import "MaskHistryRecord.h"
#import "MaskTimeTopAnimationView.h"
#import <AudioToolbox/AudioToolbox.h>
#import "GIGaDateHelper.h"
@interface GiGaMaskTaskViewController ()<MaskCirCularProGressViewDelegate,MaskTimeTextViewDelegate>
{
AVAudioPlayer *_musicPalyer;
AVAudioPlayer *_startMaskMusic;
}
@@ -258,8 +259,25 @@
[self setUpNav];
[self initUI];
[self addNotify];
[self creatBackGroundMusic];
//[self creatBackGroundMusic];
[self creatMaskTimeSatrtMusic];
//判断是否有倒数计时
[self digIsMasking];
}
-(void)digIsMasking{
AppDelegate *delegate =(AppDelegate *) [[UIApplication sharedApplication] delegate];
NSString *st = nil;
if (delegate.isMasking) {
NSLog(@"倒计时中");
st = @"YES";
[self animaMask];
}else{
st = @"NO";
}
}
@@ -288,6 +306,8 @@
[self.cicleProgressView stop];
//手动结束时结束peding通知
[[GiGaLocalNotificationManager localNotifiationCenter] cancelAllLocalNoitification];
[GIGaDateHelper removeStartDate];
[GIGaDateHelper saveisMaskingflag:NO];
[self maskTimeEnd];
}
}];
@@ -473,7 +493,7 @@
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:musicUrl error:&payerError];
player.numberOfLoops = -1;//-1 无限
player.volume = 0;
_musicPalyer = player;
//_musicPalyer = player;
[[AVAudioSession sharedInstance] setActive:YES error:nil];
//设置后台模式和锁屏模式下依然能够播放
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];
@@ -502,18 +522,14 @@
[self sendBengainMaskTime];
[self createInputView]; //出现弹幕
AppDelegate *delegate =(AppDelegate *) [[UIApplication sharedApplication] delegate];
if (delegate.isMasking) {
return;
}
NSTimeInterval timeInterVal = [GiGaUserDefault getUserMaskeTime];
[self.cicleProgressView startWith:timeInterVal];
delegate.isMasking = YES;
[_startMaskMusic play];
[_musicPalyer play];
//[_musicPalyer play];
// [self setBackGroundPlayingInfo];//锁屏音频信息
//总时间隔 s
NSTimeInterval timeInterVal = [GiGaUserDefault getUserMaskeTime];
[self.cicleProgressView startWith:timeInterVal];
//底部弹窗
//[self showWaringView];
@@ -563,13 +579,15 @@
#pragma mark 面膜时间结束
-(void)maskTimeEnd{
self.openDanmuButton.hidden = YES;
[self sendEndMaskTime];
NC_POST_NAME_OBJECT(kUserNoti_MASKEND, nil);
//面膜时间结束时设置 全局变量 不再发送本地通知 提醒
AppDelegate *delegate =(AppDelegate *) [[UIApplication sharedApplication] delegate];
delegate.isMasking = NO;
[_musicPalyer stop];
//[_musicPalyer stop];
//震动 需用户手动开启震动模式
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
@@ -792,6 +810,7 @@
[UIView animateWithDuration:0.4 animations:^{
self.waringView.frame = CGRectMake(0,CGRectGetMaxY(self.view.frame) - 44 - PhoneX_BottomMargin, self.view.frame.size.width, 44);
}];
[self.waringView showView];
}