| | |
| | | // |
| | | |
| | | #import "MusicSetPage.h" |
| | | #import "MusicPlayCell.h" |
| | | #import "HotelAccount.h" |
| | | #import "CSAudioManager.h" |
| | | #import "NetworkSingleton.h" |
| | | #import "MusicPlayCell.h" |
| | | #import "MusicModel.h" |
| | | #import "SysTipsView.h" |
| | | #import "QWAlertView.h" |
| | | #import "SysSoundSetPage.h" |
| | | #import "BaseNaviController.h" |
| | | |
| | | #define kPlayID @"ID001" |
| | | #define kPlayID2 @"ID002" |
| | | |
| | | @interface MusicSetPage ()<UITableViewDelegate,UITableViewDataSource,musicPlayDelegate> |
| | | @interface MusicSetPage ()<UITableViewDelegate,UITableViewDataSource,musicPlayDelegate,SelectedActionDelegate> |
| | | { |
| | | |
| | | } |
| | |
| | | @property (nonatomic,strong) CSAudioManager *csManager; |
| | | @property(nonatomic,strong) UITableView * tableView; |
| | | @property (nonatomic, strong) NSMutableArray *modelArray; |
| | | @property (nonatomic, strong) SysTipsView * sysTipsView; // 广告控件 |
| | | @end |
| | | |
| | | @implementation MusicSetPage |
| | |
| | | return _tableView; |
| | | } |
| | | |
| | | - (SysTipsView *)sysTipsView |
| | | { |
| | | if(!_sysTipsView) |
| | | { |
| | | _sysTipsView = [[SysTipsView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) tipsTitle:@"温馨提示" tipsContext:@"是否重置为默认铃声"]; |
| | | self.sysTipsView.delegate = self; |
| | | } |
| | | else |
| | | { |
| | | [_sysTipsView setHidden:FALSE]; |
| | | } |
| | | |
| | | return _sysTipsView; |
| | | } |
| | | |
| | | - (void)didSelectedAction:(NSInteger)type |
| | | { |
| | | [self.sysTipsView setHidden:TRUE]; |
| | | [[QWAlertView sharedMask] dismiss]; |
| | | |
| | | // 确定重置 |
| | | if (type == 1) |
| | | { |
| | | [self.csManager stopAllMusic]; |
| | | [self.modelArray removeAllObjects]; |
| | | |
| | | MusicModel * model1 = [[MusicModel alloc] init]; |
| | | model1.username = [NSString stringWithFormat:@"%@",@"轻微铃声"]; |
| | | model1.user_id = [NSString stringWithFormat:@"%@",@"ID0001"]; |
| | | model1.musicName = [NSString stringWithFormat:@"%@",@"默认"]; |
| | | model1.musicStatus = 0; |
| | | model1.musicUrl = [NSString stringWithFormat:@"%@",@"http://yfsapi.7drlb.com/video/music.mp3"]; |
| | | [self.modelArray addObject:model1]; |
| | | |
| | | MusicModel * model2 = [[MusicModel alloc] init]; |
| | | model2.username = [NSString stringWithFormat:@"%@",@"中度铃声"]; |
| | | model2.user_id = [NSString stringWithFormat:@"%@",@"ID0002"]; |
| | | model2.musicName = [NSString stringWithFormat:@"%@",@"默认"]; |
| | | model2.musicStatus = 0; |
| | | model2.musicUrl = [NSString stringWithFormat:@"%@",@"http://yfsapi.7drlb.com/video/music1.mp3"]; |
| | | [self.modelArray addObject:model2]; |
| | | |
| | | MusicModel * model3 = [[MusicModel alloc] init]; |
| | | model3.username = [NSString stringWithFormat:@"%@",@"严重铃声"]; |
| | | model3.user_id = [NSString stringWithFormat:@"%@",@"ID0003"]; |
| | | model3.musicName = [NSString stringWithFormat:@"%@",@"默认"]; |
| | | model3.musicStatus = 0; |
| | | model3.musicUrl = [NSString stringWithFormat:@"%@",@"http://yfsapi.7drlb.com/video/music2.mp3"]; |
| | | |
| | | [self.modelArray addObject:model3]; |
| | | |
| | | [self.tableView reloadData]; |
| | | } |
| | | } |
| | | |
| | | - (void)viewDidLoad |
| | | { |
| | | [super viewDidLoad]; |
| | | // Do any additional setup after loading the view. |
| | | self.navigationItem.title = @"铃声设置"; |
| | | [self setNavigationLeft:@"返回" sel:@selector(backAction)]; |
| | | |
| | | [self setNavigationRight:@"重置" sel:@selector(resetAction)]; |
| | | |
| | | |
| | | self.csManager = [CSAudioManager defaultManager]; |
| | | self.mp3Data = nil; |
| | | |
| | |
| | | |
| | | |
| | | self.modelArray = [[NSMutableArray alloc] init]; |
| | | for( int i =0; i<10;i++) |
| | | // @property(nonatomic, strong) NSString * _id; |
| | | // @property(nonatomic, strong) NSString * user_id; |
| | | // @property(nonatomic, strong) NSString * username; |
| | | // @property(nonatomic, strong) NSString * musicName; |
| | | // @property(nonatomic, strong) NSString * musicUrl; // 音乐地址 |
| | | // @property(nonatomic, strong) NSString * xuhaoIndex; |
| | | // |
| | | // @property(nonatomic, assign) int cmd; // 1 播放 2 设置默认 |
| | | // @property(nonatomic, assign) int playStatus; // 默认0 播放状态命令 1 播放操作 2 暂停操作 |
| | | // @property(nonatomic, assign) int musicStatus; // 默认0 设置状态命令 1 默认设置 2 默认取消 |
| | | // @property(nonatomic, assign) NSInteger indexRow; // 当前索引 http://yfsapi.7drlb.com/video/music.mp3 |
| | | |
| | | // [UserDefault stringForKey:@"username"] |
| | | // 0 默认 1 自定义 |
| | | NSInteger musicStatus1 = [UserDefault integerForKey:@"musicStatus1"]; |
| | | NSInteger musicStatus2 = [UserDefault integerForKey:@"musicStatus2"]; |
| | | NSInteger musicStatus3 = [UserDefault integerForKey:@"musicStatus3"]; |
| | | |
| | | if( musicStatus1 == 0 ) |
| | | { |
| | | HotelAccount * model = [[HotelAccount alloc] init]; |
| | | [self.modelArray addObject:model]; |
| | | MusicModel * model1 = [[MusicModel alloc] init]; |
| | | model1.username = [NSString stringWithFormat:@"%@",@"轻微铃声"]; |
| | | model1.user_id = [NSString stringWithFormat:@"%@",@"ID0001"]; |
| | | model1.musicName = [NSString stringWithFormat:@"%@",@"默认"]; |
| | | model1.musicStatus = 0; |
| | | model1.musicUrl = [NSString stringWithFormat:@"%@",@"http://yfsapi.7drlb.com/video/music.mp3"]; |
| | | [self.modelArray addObject:model1]; |
| | | } |
| | | else |
| | | { |
| | | MusicModel * model1 = [[MusicModel alloc] init]; |
| | | model1.username = [NSString stringWithFormat:@"%@",@"轻微铃声"]; |
| | | model1.user_id = [NSString stringWithFormat:@"%@",@"ID0001"]; |
| | | model1.musicName = [UserDefault stringForKey:@"ID0001Name"]; |
| | | model1.musicStatus = 1; |
| | | model1.musicUrl = [UserDefault stringForKey:@"ID0001PATH"]; |
| | | [self.modelArray addObject:model1]; |
| | | } |
| | | |
| | | |
| | | if( musicStatus2 == 0 ) |
| | | { |
| | | MusicModel * model2 = [[MusicModel alloc] init]; |
| | | model2.username = [NSString stringWithFormat:@"%@",@"中度铃声"]; |
| | | model2.user_id = [NSString stringWithFormat:@"%@",@"ID0002"]; |
| | | model2.musicName = [NSString stringWithFormat:@"%@",@"默认"]; |
| | | model2.musicStatus = 0; |
| | | model2.musicUrl = [NSString stringWithFormat:@"%@",@"http://yfsapi.7drlb.com/video/music1.mp3"]; |
| | | [self.modelArray addObject:model2]; |
| | | } |
| | | else |
| | | { |
| | | MusicModel * model2 = [[MusicModel alloc] init]; |
| | | model2.username = [NSString stringWithFormat:@"%@",@"中度铃声"]; |
| | | model2.user_id = [NSString stringWithFormat:@"%@",@"ID0002"]; |
| | | model2.musicName = [UserDefault stringForKey:@"ID0002Name"]; |
| | | model2.musicStatus = 1; |
| | | model2.musicUrl = [UserDefault stringForKey:@"ID0002PATH"]; |
| | | [self.modelArray addObject:model2]; |
| | | } |
| | | |
| | | if( musicStatus3 == 0 ) |
| | | { |
| | | MusicModel * model3 = [[MusicModel alloc] init]; |
| | | model3.username = [NSString stringWithFormat:@"%@",@"严重铃声"]; |
| | | model3.user_id = [NSString stringWithFormat:@"%@",@"ID0003"]; |
| | | model3.musicName = [NSString stringWithFormat:@"%@",@"默认"]; |
| | | model3.musicStatus = 0; |
| | | model3.musicUrl = [NSString stringWithFormat:@"%@",@"http://yfsapi.7drlb.com/video/music2.mp3"]; |
| | | |
| | | [self.modelArray addObject:model3]; |
| | | } |
| | | else |
| | | { |
| | | MusicModel * model3 = [[MusicModel alloc] init]; |
| | | model3.username = [NSString stringWithFormat:@"%@",@"严重铃声"]; |
| | | model3.user_id = [NSString stringWithFormat:@"%@",@"ID0003"]; |
| | | model3.musicName = [UserDefault stringForKey:@"ID0003Name"]; |
| | | model3.musicStatus = 1; |
| | | model3.musicUrl = [UserDefault stringForKey:@"ID0003PATH"]; |
| | | |
| | | [self.modelArray addObject:model3]; |
| | | } |
| | | |
| | | self.tableView.hidden = NO; |
| | | [self.tableView reloadData]; |
| | | } |
| | | |
| | | - (void)viewWillAppear:(BOOL)animated |
| | | { |
| | | [super viewWillAppear:animated]; |
| | | |
| | | [self.modelArray removeAllObjects]; |
| | | // 0 默认 1 自定义 |
| | | NSInteger musicStatus1 = [UserDefault integerForKey:@"musicStatus1"]; |
| | | NSInteger musicStatus2 = [UserDefault integerForKey:@"musicStatus2"]; |
| | | NSInteger musicStatus3 = [UserDefault integerForKey:@"musicStatus3"]; |
| | | |
| | | if( musicStatus1 == 0 ) |
| | | { |
| | | MusicModel * model1 = [[MusicModel alloc] init]; |
| | | model1.username = [NSString stringWithFormat:@"%@",@"轻微铃声"]; |
| | | model1.user_id = [NSString stringWithFormat:@"%@",@"ID0001"]; |
| | | model1.musicName = [NSString stringWithFormat:@"%@",@"默认"]; |
| | | model1.musicStatus = 0; |
| | | model1.musicUrl = [NSString stringWithFormat:@"%@",@"http://yfsapi.7drlb.com/video/music.mp3"]; |
| | | [self.modelArray addObject:model1]; |
| | | } |
| | | else |
| | | { |
| | | MusicModel * model1 = [[MusicModel alloc] init]; |
| | | model1.username = [NSString stringWithFormat:@"%@",@"轻微铃声"]; |
| | | model1.user_id = [NSString stringWithFormat:@"%@",@"ID0001"]; |
| | | model1.musicName = [UserDefault stringForKey:@"ID0001Name"]; |
| | | model1.musicStatus = 1; |
| | | model1.musicUrl = [UserDefault stringForKey:@"ID0001PATH"]; |
| | | [self.modelArray addObject:model1]; |
| | | } |
| | | |
| | | |
| | | if( musicStatus2 == 0 ) |
| | | { |
| | | MusicModel * model2 = [[MusicModel alloc] init]; |
| | | model2.username = [NSString stringWithFormat:@"%@",@"中度铃声"]; |
| | | model2.user_id = [NSString stringWithFormat:@"%@",@"ID0002"]; |
| | | model2.musicName = [NSString stringWithFormat:@"%@",@"默认"]; |
| | | model2.musicStatus = 0; |
| | | model2.musicUrl = [NSString stringWithFormat:@"%@",@"http://yfsapi.7drlb.com/video/music1.mp3"]; |
| | | [self.modelArray addObject:model2]; |
| | | } |
| | | else |
| | | { |
| | | MusicModel * model2 = [[MusicModel alloc] init]; |
| | | model2.username = [NSString stringWithFormat:@"%@",@"中度铃声"]; |
| | | model2.user_id = [NSString stringWithFormat:@"%@",@"ID0002"]; |
| | | model2.musicName = [UserDefault stringForKey:@"ID0002Name"]; |
| | | model2.musicStatus = 1; |
| | | model2.musicUrl = [UserDefault stringForKey:@"ID0002PATH"]; |
| | | [self.modelArray addObject:model2]; |
| | | } |
| | | |
| | | if( musicStatus3 == 0 ) |
| | | { |
| | | MusicModel * model3 = [[MusicModel alloc] init]; |
| | | model3.username = [NSString stringWithFormat:@"%@",@"严重铃声"]; |
| | | model3.user_id = [NSString stringWithFormat:@"%@",@"ID0003"]; |
| | | model3.musicName = [NSString stringWithFormat:@"%@",@"默认"]; |
| | | model3.musicStatus = 0; |
| | | model3.musicUrl = [NSString stringWithFormat:@"%@",@"http://yfsapi.7drlb.com/video/music2.mp3"]; |
| | | |
| | | [self.modelArray addObject:model3]; |
| | | } |
| | | else |
| | | { |
| | | MusicModel * model3 = [[MusicModel alloc] init]; |
| | | model3.username = [NSString stringWithFormat:@"%@",@"严重铃声"]; |
| | | model3.user_id = [NSString stringWithFormat:@"%@",@"ID0003"]; |
| | | model3.musicName = [UserDefault stringForKey:@"ID0003Name"]; |
| | | model3.musicStatus = 1; |
| | | model3.musicUrl = [UserDefault stringForKey:@"ID0003PATH"]; |
| | | |
| | | [self.modelArray addObject:model3]; |
| | | } |
| | | |
| | | self.tableView.hidden = NO; |
| | | [self.tableView reloadData]; |
| | | } |
| | | |
| | | -(void)resetAction |
| | | { |
| | | [[QWAlertView sharedMask] show:self.sysTipsView withType:(QWAlertViewStyle)QWAlertViewStyleAlert]; |
| | | } |
| | | |
| | | -(void)backAction |
| | | { |
| | | [self.csManager stopAllMusic]; |
| | | [self dismissViewControllerAnimated:YES completion:nil]; |
| | | //[self.navigationController popViewControllerAnimated:YES]; |
| | | } |
| | |
| | | |
| | | cell.delegate = self; |
| | | |
| | | HotelAccount * model = [self.modelArray objectAtIndex:indexPath.row]; |
| | | |
| | | MusicModel * model = [self.modelArray objectAtIndex:indexPath.row]; |
| | | NSInteger selIndex = [[UserDefault stringForKey:@"video"] integerValue]; |
| | | if( selIndex == indexPath.row ) |
| | | { |
| | |
| | | } |
| | | |
| | | model.indexRow = indexPath.row; |
| | | model.musicName = @"music.mp3"; |
| | | model._id = [NSString stringWithFormat:@"judqiowu%ld",indexPath.row]; |
| | | model.xuhaoIndex = [NSString stringWithFormat:@"%02ld",indexPath.row+1]; |
| | | [cell setItemView:model]; |
| | |
| | | //[self showActionForPhoto]; |
| | | } |
| | | |
| | | - (void)musicPlaySection:(HotelAccount*)model |
| | | - (void)musicPlaySection:(MusicModel*)model |
| | | { |
| | | if ( model.cmd == 1 ) |
| | | { |
| | | if( model.playStatus == 1 ) |
| | | { |
| | | // 已存在销毁音频文件 |
| | | if( self.mp3Data != nil ) |
| | | { |
| | | //停止音频 |
| | | [self.csManager stopMusicWithPlayID:kPlayID]; |
| | | [self.csManager disposeSoundWithPlayID:kPlayID]; |
| | | } |
| | | // //if( self.mp3Data != nil ) |
| | | // { |
| | | // //停止音频 |
| | | // [self.csManager stopMusicWithPlayID:model.user_id]; |
| | | // [self.csManager disposeSoundWithPlayID:model.user_id]; |
| | | // } |
| | | |
| | | // 其他播放恢复默认值 |
| | | for( NSUInteger i = 0; i < self.modelArray.count;i++) |
| | | { |
| | | HotelAccount * tempModel = [self.modelArray objectAtIndex:i]; |
| | | MusicModel * tempModel = [self.modelArray objectAtIndex:i]; |
| | | if( [tempModel._id isEqualToString:model._id] ) |
| | | continue; |
| | | //停止音频 |
| | | if(tempModel.playStatus == 1) |
| | | { |
| | | [self.csManager stopMusicWithPlayID:tempModel.user_id]; |
| | | [self.csManager disposeSoundWithPlayID:tempModel.user_id]; |
| | | } |
| | | |
| | | tempModel.playStatus = 0; |
| | | } |
| | | |
| | | NSString *mp3Path = [[NSBundle mainBundle] pathForResource:model.musicName ofType:nil]; |
| | | NSLog(@"mp3Path : %@",mp3Path); |
| | | self.mp3Data = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:mp3Path]]; |
| | | |
| | | //播放音频 |
| | | [self.csManager playingMusicWithData:self.mp3Data playID:kPlayID]; |
| | | if( model.musicStatus == 0 ) |
| | | { |
| | | [self.csManager playingMusicWithURL:[NSURL URLWithString:model.musicUrl] playID:model.user_id]; |
| | | } |
| | | else |
| | | { |
| | | |
| | | // NSString *mp3Path = [[NSBundle mainBundle] pathForResource:model.musicUrl ofType:nil]; |
| | | // NSLog(@"mp3Path : %@",mp3Path); |
| | | self.mp3Data = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:model.musicUrl]]; |
| | | //播放音频 |
| | | [self.csManager playingMusicWithData:self.mp3Data playID:model.user_id]; |
| | | } |
| | | } |
| | | else if( model.playStatus == 2 ) |
| | | { |
| | | //停止音频 |
| | | [self.csManager stopMusicWithPlayID:kPlayID]; |
| | | [self.csManager stopMusicWithPlayID:model.user_id]; |
| | | } |
| | | } |
| | | else if( model.cmd == 2 ) |
| | | { |
| | | if( model.setStatus == 1 ) |
| | | { |
| | | //设置默认 |
| | | // 其他恢复默认值 |
| | | for( NSUInteger i = 0; i < self.modelArray.count;i++) |
| | | { |
| | | HotelAccount * tempModel = [self.modelArray objectAtIndex:i]; |
| | | if( [tempModel._id isEqualToString:model._id] ) |
| | | continue; |
| | | |
| | | tempModel.setStatus = 0; |
| | | } |
| | | |
| | | // 调用设置方法 |
| | | [self update_video:model]; |
| | | |
| | | } |
| | | else if( model.setStatus == 2 ) |
| | | { |
| | | //取消默认 |
| | | [self update_video:model]; |
| | | } |
| | | [self.csManager stopAllMusic]; |
| | | // 打开本地音频文件 |
| | | SysSoundSetPage* Page = [[SysSoundSetPage alloc] initIsFirstPage:NO]; |
| | | Page.soundIndex = [model.xuhaoIndex integerValue]; |
| | | BaseNaviController *baseNav = [[BaseNaviController alloc] initWithRootViewController:Page]; |
| | | [self presentViewController:baseNav animated:YES completion:nil]; |
| | | } |
| | | } |
| | | |
| | | |
| | | -(void)update_video:(HotelAccount *)model |
| | | -(void)update_video:(MusicModel *)model |
| | | { |
| | | //[UserDefault stringForKey:@"user_id"] |
| | | NSString *path = [[NSString alloc] initWithFormat:UPDATE_USERINFO]; |