ernesto logo
Torna al Magazine
Disinfestazione parassiti del limone: come trovare ditte di disinfestazioni
consigli
Disinfestazione parassiti del limone: come trovare ditte di disinfestazioni

Trovare una Ditta di Disinfestazione per Parassiti del Limone.

Cercare un'Azienda di Disinfestazione per Parassiti del Limone.

Scopri come scegliere la ditta di disinfestazione ideale per combattere i parassiti del limone. Questo articolo offre una guida dettagliata sui servizi di disinfestazione, evidenziando l'importanza di esperti nel settore per garantire la salute delle tue piante. Leggi per saperne di più!

Trova professionisti vicino a te

Trova professionisti
// // BoFangViewController.m // Music // // Created by laouhn on 15/10/21. // Copyright (c) 2015年 laouhn. All rights reserved. // #import "BoFangViewController.h" #import "MusicModel.h" #import #import "MusicDataBaseHandle.h" #import "UIImageView+WebCache.h" #import "ProgressView.h" #import "SongListViewController.h" #import "LYRViewController.h" #import "MusicTool.h" @interface BoFangViewController () @property (weak, nonatomic) IBOutlet UIImageView *image; @property (weak, nonatomic) IBOutlet UIView *backGroundView; @property (weak, nonatomic) IBOutlet UITableView *tableView; @property (nonatomic, strong) AVAudioPlayer *player; @property (nonatomic, strong) NSTimer *timer; @property (nonatomic, strong) ProgressView *progress; @property (nonatomic, assign) BOOL isPlaying; @property (nonatomic, assign) BOOL isFinish; @property (nonatomic, assign) BOOL isC; @property (nonatomic, assign) BOOL isF; @property (nonatomic, strong) NSMutableArray *dataSource; @property (nonatomic, strong) MusicModel *model; @end @implementation BoFangViewController - (void)viewDidLoad { [super viewDidLoad]; [self configUI]; [self configData]; [self addTimer]; } - (void)configUI { self.backGroundView.layer.cornerRadius = 8; self.backGroundView.layer.masksToBounds = YES; self.tableView.backgroundColor = [UIColor clearColor]; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.progress = [[ProgressView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width - 30, 30)]; self.progress.center = self.view.center; [self.view addSubview:self.progress]; self.progress.hidden = YES; [self.view bringSubviewToFront:self.backGroundView]; self.tableView.delegate = self; self.tableView.dataSource = self; } - (void)configData { self.dataSource = [NSMutableArray arrayWithCapacity:0]; self.dataSource = [[MusicDataBaseHandle shareInstance] selectAllMusic]; self.model = self.dataSource[self.index]; [self.image sd_setImageWithURL:[NSURL URLWithString:self.model.picUrl] placeholderImage:nil]; self.title = self.model.name; self.player = [AVAudioPlayer audioPlayerWithPath:self.model.mp3Url]; self.player.delegate = self; [self.player prepareToPlay]; self.player.numberOfLoops = 0; [self.player play]; self.isPlaying = YES; [self.tableView reloadData]; } - (void)addTimer { self.timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(changeProgress) userInfo:nil repeats:YES]; [[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes]; } - (void)changeProgress { self.progress.currentTime = self.player.currentTime; self.progress.totalTime = self.player.duration; self.progress.value = self.player.currentTime / self.player.duration; if (self.progress.value == 1) { [self nextMusic:nil]; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBAction)backToMainPage:(id)sender { [self.timer invalidate]; self.timer = nil; [self.player stop]; self.player = nil; [self.navigationController popViewControllerAnimated:YES]; } - (IBAction)playOrPauseMusic:(UIButton *)sender { sender.selected = !sender.selected; if (sender.selected) { [self.player play]; self.isPlaying = YES; }else { [self.player pause]; self.isPlaying = NO; } } - (IBAction)lastMusic:(id)sender { self.index --; if (self.index < 0) { self.index = self.dataSource.count - 1; } [self.image sd_setImageWithURL:[NSURL URLWithString:[self.dataSource[self.index] picUrl]] placeholderImage:nil]; self.title = [self.dataSource[self.index] name]; [self.player stop]; self.player = [AVAudioPlayer audioPlayerWithPath:[self.dataSource[self.index] mp3Url]]; [self.player prepareToPlay]; self.player.delegate = self; self.player.numberOfLoops = 0; [self.player play]; self.isPlaying = YES; } - (IBAction)nextMusic:(id)sender { self.index ++; if (self.index > self.dataSource.count - 1) { self.index = 0; } [self.image sd_setImageWithURL:[NSURL URLWithString:[self.dataSource[self.index] picUrl]] placeholderImage:nil]; self.title = [self.dataSource[self.index] name]; [self.player stop]; self.player = [AVAudioPlayer audioPlayerWithPath:[self.dataSource[self.index] mp3Url]]; [self.player prepareToPlay]; self.player.delegate = self; self.player.numberOfLoops = 0; [self.player play]; self.isPlaying = YES; } - (IBAction)changeMode:(UIButton *)sender { sender.selected = !sender.selected; if (sender.selected) { self.player.numberOfLoops = -1; self.isC = YES; }else { self.player.numberOfLoops = 0; self.isC = NO; } } - (IBAction)changeFinish:(UIButton *)sender { sender.selected = !sender.selected; if (sender.selected) { self.isF = YES; }else { self.isF = NO; } } - (void)viewWillDisappear:(BOOL)animated { [self.player stop]; self.player = nil; [self.timer invalidate]; self.timer = nil; NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:0]; dict[@"name"] = self.model.name; dict[@"author"] = self.model.singer; dict[@"URL"] = self.model.mp3Url; dict[@"picUrl"] = self.model.picUrl; dict[@"index"] = [NSString stringWithFormat:@"%ld", self.index]; dict[@"isPlaying"] = [NSString stringWithFormat:@"%d", self.isPlaying]; dict[@"isC"] = [NSString stringWithFormat:@"%d", self.isC]; dict[@"isF"] = [NSString stringWithFormat:@"%d", self.isF]; dict[@"progress"] = [NSString stringWithFormat:@"%f", self.progress.value]; [[NSUserDefaults standardUserDefaults] setObject:dict forKey:@"music"]; [[NSUserDefaults standardUserDefaults] synchronize]; [[MusicTool shareMusicTool] setMusicModel:self.model]; } - (void)viewWillAppear:(BOOL)animated { NSDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:@"music"]; if (dict) { self.index = [dict[@"index"] integerValue]; self.model = self.dataSource[[dict[@"index"] integerValue]]; [self.image sd_setImageWithURL:[NSURL URLWithString:dict[@"picUrl"]] placeholderImage:nil]; self.title = dict[@"name"]; self.player = [AVAudioPlayer audioPlayerWithPath:dict[@"URL"]]; self.player.delegate = self; [self.player prepareToPlay]; self.player.numberOfLoops = 0; self.progress.value = [dict[@"progress"] floatValue]; if ([dict[@"isC"] boolValue] == YES) { self.player.numberOfLoops = -1; self.isC = YES; } if ([dict[@"isF"] boolValue] == YES) { self.isF = YES; } if ([dict[@"isPlaying"] boolValue] == YES) { [self.player play]; self.isPlaying = YES; } } [self.tableView reloadData]; } #pragma mark - tableview delegate - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.dataSource.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellid = @"cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellid]; if (!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellid]; } MusicModel *model = self.dataSource[indexPath.row]; cell.backgroundColor = [UIColor clearColor]; cell.textLabel.textColor = [UIColor whiteColor]; cell.detailTextLabel.textColor = [UIColor whiteColor]; cell.textLabel.text = model.name; cell.detailTextLabel.text = model.singer; if (indexPath.row == self.index) { cell.backgroundColor = [UIColor lightGrayColor]; } cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { self.index = indexPath.row; [self.image sd_setImageWithURL:[NSURL URLWithString:[self.dataSource[indexPath.row] picUrl]] placeholderImage:nil]; self.title = [self.dataSource[indexPath.row] name]; [self.player stop]; self.player = [AVAudioPlayer audioPlayerWithPath:[self.dataSource[indexPath.row] mp3Url]]; [self.player prepareToPlay]; self.player.delegate = self; self.player.numberOfLoops = 0; [self.player play]; self.isPlaying = YES; [tableView reloadData]; } #pragma mark - AVAudioPlayerDelegate - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag { if (self.isF) { [self nextMusic:nil]; } } - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"songList"]) { SongListViewController *vc = segue.destinationViewController; vc.dataSource = self.dataSource; } if ([segue.identifier isEqualToString:@"lyr"]) { LYRViewController *vc = segue.destinationViewController; vc.model = self.dataSource[self.index]; } } @end
Ultimo aggiornamento
30 Mar 2025
Luca De Santis
Luca De Santis

Autore specializzato nel raccontare come funziona il mondo dei servizi locali e come trovare i professionisti migliori.