zoukankan      html  css  js  c++  java
  • 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];

                }

  • 相关阅读:
    掌上风云
    骗子太多傻子不够用了
    关于WP7的一点想法
    诺基亚的抉择
    Windows Embedded Compact 7 试用笔记(3)
    Windows Embedded Compact 试用笔记(2)——系统定制
    重开博客
    结构体的嵌套问题
    Delphi 2010 新增功能之: IOUtils 单元(1): 初识 TDirectory.GetFiles
    TImage、TPaintBox、TPicture、TBitmap、TCanvas、TGraphic 的关系与区别
  • 原文地址:https://www.cnblogs.com/guligei/p/3531071.html
Copyright © 2011-2022 走看看