美文网首页
商户详情

商户详情

作者: 焉逢12 | 来源:发表于2017-02-28 14:17 被阅读0次

    一.播放音频

    NSURL *url = [NSURL URLWithString:voiceintro];
    
    NSData * audioData = [NSData dataWithContentsOfURL:url];
    
    //将数据保存到本地指定位置
    
    NSString *docDirPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
    
    NSString *filePath = [NSString stringWithFormat:@"%@/%@.mp3", docDirPath , @"temp"];
    
    [audioData writeToFile:filePath atomically:YES];
    
    //播放本地音乐
    
    NSURL *fileURL = [NSURL fileURLWithPath:filePath];
    
    avAudioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
    
    //预播放
    
    [avAudioPlayer prepareToPlay];
    
    [voicebtn setTitleColor:MainColor forState:UIControlStateNormal];
    
    [voicebtn addTarget:self action:@selector(startvoice) forControlEvents:UIControlEventTouchUpInside];
    
    //点击播放按钮
    
    -(void)startvoice
    
    {
    
    [avAudioPlayer play];
    
    }
    

    二.TggStarEvaluationView 星星评价视图

    TggStarEvaluationView 星星评价视图

    相关文章

      网友评论

          本文标题:商户详情

          本文链接:https://www.haomeiwen.com/subject/vsuxgttx.html