iOS 播放音频文件

//        播放音乐

        NSString *path = [[NSBundle mainBundle] pathForResource:@"1670" ofType:@"mp3"];

    

        NSError * error;

    

        self.avaPlayer= [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path]error:&error];

    

        self.avaPlayer.volume = 1;

    

        [self.avaPlayer prepareToPlay];

    

        [self.avaPlayer setNumberOfLoops:100];

    

        [self.avaPlayer play];

posted @ 2017-10-17 10:33  graveliang  阅读(992)  评论(0编辑  收藏  举报