From a4242fa7b71b6297e5e8cfda747c09709876e1c5 Mon Sep 17 00:00:00 2001 From: lianxiang <13052344590@163.com> Date: Fri, 24 Aug 2018 22:33:42 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E8=83=8C=E6=99=AF=E9=9F=B3=E4=B9=90?= =?UTF-8?q?=E9=94=81=E5=B1=8F=E5=B1=95=E7=A4=BAapp=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GiGaLocalNotificationManager.m | 2 +- .../Controller/GiGaMaskTaskViewController.m | 43 ++++++++++++++++--- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/GIGA/Common/GiGaLocalNotificationManager/GiGaLocalNotificationManager.m b/GIGA/Common/GiGaLocalNotificationManager/GiGaLocalNotificationManager.m index 35960f1..090a6a3 100644 --- a/GIGA/Common/GiGaLocalNotificationManager/GiGaLocalNotificationManager.m +++ b/GIGA/Common/GiGaLocalNotificationManager/GiGaLocalNotificationManager.m @@ -40,7 +40,7 @@ NSURL *vedioUrl = [[NSBundle mainBundle] URLForResource:@"emojizone" withExtension:@"mp4"]; UNNotificationAttachment *vedioAudio = [UNNotificationAttachment attachmentWithIdentifier:@"vedio" URL:vedioUrl options:nil error:nil]; - content.attachments = @[attach,attachAudio,vedioAudio]; + content.attachments = @[vedioAudio]; //延迟通知 第一个参数是重复的时间间隔,最小60s,第二个参数是是否重复。 diff --git a/GIGA/Modules/Mask/Controller/GiGaMaskTaskViewController.m b/GIGA/Modules/Mask/Controller/GiGaMaskTaskViewController.m index 44f2515..1043132 100644 --- a/GIGA/Modules/Mask/Controller/GiGaMaskTaskViewController.m +++ b/GIGA/Modules/Mask/Controller/GiGaMaskTaskViewController.m @@ -120,16 +120,18 @@ #pragma mark 面膜时间背景音乐 -(void)creatBackGroundMusic{ - - //设置后台模式和锁屏模式下依然能够播放 - [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil]; - [[AVAudioSession sharedInstance] setActive:YES error:nil]; //初始化音频播放器 NSError *payerError; NSURL *musicUrl = [[NSURL alloc] initWithString:[[NSBundle mainBundle] pathForResource:@"pomodoSound" ofType:@"m4a"]] ; AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:musicUrl error:&payerError]; player.numberOfLoops = -1; _musicPalyer = player; + [[AVAudioSession sharedInstance] setActive:YES error:nil]; + //设置后台模式和锁屏模式下依然能够播放 + //[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil]; + [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil]; + + } @@ -140,10 +142,10 @@ delegate.isMasking = YES; [_musicPalyer play]; - [self setBackGroundPlayingInfo]; + [self setBackGroundPlayingInfo];//锁屏音频信息 //总时间隔 s - NSTimeInterval timeInterVal = 10; + NSTimeInterval timeInterVal = 58; NSString *timeformat = [GiGaHelper stringWithNSTimerinterval:timeInterVal]; NSArray *timesArr = [timeformat componentsSeparatedByString:@":"]; @@ -165,12 +167,39 @@ MPMediaItemArtwork *arwork = [[MPMediaItemArtwork alloc] initWithImage:[UIImage imageNamed:@"MaskTime.png"]]; NSDictionary *dic = @{ - MPMediaItemPropertyTitle:@"专辑名字专辑", + MPMediaItemPropertyTitle:@"面膜时间", MPMediaItemPropertyAlbumArtist:@"专辑专辑专辑专辑", + MPMediaItemPropertyArtist:@"lianxiang", + MPMediaItemPropertyAlbumTitle:@"hahah", + MPMediaItemPropertyGenre:@"???", + MPMediaItemPropertyLyrics:@"歌词", + MPMediaItemPropertyPodcastTitle:@"PodcastTitle", MPMediaItemPropertyArtwork:arwork }; [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:dic]; + [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; + +} +- (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent { + + if (receivedEvent.type == UIEventTypeRemoteControl) { + switch (receivedEvent.subtype) { + + case UIEventSubtypeRemoteControlPlay: + //暂时不处理 + //[_musicPalyer play]; + break; + + case UIEventSubtypeRemoteControlPause: + // [_musicPalyer pause]; + break; + + default: + NSLog(@"没有处理过这个事件------receivedEvent.subtype==%ld",(long)receivedEvent.subtype); + break; + } + } } #pragma mark 面膜时间结束