reloaddata,btn,info,play,timer,

#pragma mark - 播放原wav

- (IBAction)playWav:(id)sender {

    

 

        UIButton *btn = (UIButton *)sender;

        ChatMessageInfo *info = [self.dataArray objectAtIndex:btn.tag];

        NSString *fileName = info.localPath;

        self.soundBtn = btn;

//    当本地没有的时候,去下载

        if (fileName.length == 0) {

            [self downloadVoice:info];

        }

    

        if (fileName.length > 0)

        {

            if (![fileName isEqualToString:tempFileName])

            {

                if (currentPlayer) {

                    if ([currentPlayer isPlaying]) {

                        [currentPlayer stop];

                        [currentPlayer setCurrentTime:0.0];

                        

                    }

 

                }

                

                self.player = [self.player initWithContentsOfURL:[NSURL URLWithString:fileName] error:nil];

                self.player.delegate = self;

                currentPlayer = self.player;

            }

            tempFileName = fileName;

 

            if ([self.player isPlaying])

            {

                [self.player stop];

                [self.player setCurrentTime:0.0];

                playIndex = -1;

                [soundTimer setFireDate:[NSDate distantFuture]];

 

                

 

            }else

            {

                [self.player play];

                info.isPlay = YES;

                playIndex = btn.tag;

 

            }

       }

    [selfupdateVoicePlayState];

 

}

 

 

-(void)updateVoicePlayState

{

    for (int i = 0; i< self.dataArray.count; i++) {

        ChatMessageInfo *info = [self.dataArray objectAtIndex:i];

        if (i == playIndex) {

            info.isPlay = YES;

        }else{

            info.isPlay = NO;

        }

    }

    [self.tableViewreloadData];

}

 

-(void)updateMeter

{

    if (!soundTimer) {

 

//        soundTimer = [NSTimer scheduledTimerWithTimeInterval:0.2f target:self selector:@selector(updateSound) userInfo:Nil repeats:YES];

        soundTimer = [NSTimertimerWithTimeInterval:0.2ftarget:selfselector:@selector(updateSound) userInfo:Nilrepeats:YES];

        [[NSRunLoopcurrentRunLoop] addTimer:soundTimerforMode:NSRunLoopCommonModes];

 

    }

    [soundTimersetFireDate:[NSDatedistantPast]];

 

    

}

 

 

-(void)updateSound

{

   NSIndexPath *_path = [NSIndexPathindexPathForItem:playIndexinSection:0];

   IMVoiceCell *cell = (IMVoiceCell *)[self.tableViewcellForRowAtIndexPath:_path];

    self.soundBtn = cell.soundBtn;

    

    TTLog(@".......................%d",self.soundBtn.tag);

    switch (soundCount)

    {

        case 0:

        {

            [self.soundBtnsetImage:[UIImageimageNamed:@"celebrity_chatto_voice_playing_f1.png"] forState:UIControlStateNormal];

            break;

 

        }

            case 1:

        {

            [self.soundBtnsetImage:[UIImageimageNamed:@"celebrity_chatto_voice_playing_f2.png"] forState:UIControlStateNormal];

            break;

        }

        default:

        {

            [self.soundBtnsetImage:[UIImageimageNamed:@"celebrity_chatto_voice_playing_f3.png"] forState:UIControlStateNormal];

            break;

 

        }

       

    }

    soundCount ++;

    if (soundCount > 3) {

        soundCount = 0;

    }

}

 if (!info.isPlay) {

                [voiceCell.soundBtnsetImage:[UIImageimageNamed:@"celebrity_chatto_voice_playing.png"] forState:UIControlStateNormal];

            }else{

                [self updateMeter];

            }

reloaddata,btn,info,play,timer,

上一篇:接口


下一篇:Java中使用RabbitMQ传递对象