首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >循环背景音乐?

循环背景音乐?
EN

Stack Overflow用户
提问于 2010-09-02 21:17:54
回答 1查看 11.4K关注 0票数 23
  1. 为我的iOS游戏播放背景音乐的最佳方式是什么?我是如何做到这一点的呢?
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-12-31 14:08:42

您可以使用AVAudioPlayer

代码语言:javascript
复制
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"mySound" ofType:@"mp3"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:nil];
player.numberOfLoops = -1; //infinite

[player play];

并且您可以通过设置currentTime来跳过

代码语言:javascript
复制
player.currentTime = 10; //jump to 10th second
票数 36
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3631353

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档