iPhone / iPad的 - 循环背景音乐? [英] iPhone/iPad - Loop Background Music?

查看:121
本文介绍了iPhone / iPad的 - 循环背景音乐?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

第一次这样做,希望大家能有所帮助。

First time doing this, hope you can help.


  1. 什么播放背景音乐我的iPad游戏中最好的方法是什么?
    1B。我该怎么做呢?

  1. What the best way of playing background music for my iPad game? 1b. How do I do this?

请告诉我具有音乐文件进行播放的最佳格式?

Whats the best format of having that music file in for playback?

这会不会这首歌高高兴兴地通过整个游戏玩,没有中断时改变看法?

Will this this song happily play through the entire game, no interruptions when changing view?

如何循环这样的音乐?

感谢。

推荐答案

您可以使用 AVAudioPlayer

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的

player.currentTime = 10; //jump to 10th second

这篇关于iPhone / iPad的 - 循环背景音乐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆