600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > html同时播放多个文件夹 ios – 如何同时播放多个音频文件

html同时播放多个文件夹 ios – 如何同时播放多个音频文件

时间:2021-12-29 18:42:38

相关推荐

html同时播放多个文件夹 ios – 如何同时播放多个音频文件

以下格式的文件可以在iPhone上同时播放.

AAC,MP3和ALAC(Apple Lossless)音频:有CPU资源问题.

线性PCM和IMA / ADPCM(IMA4音频):没有CPU资源问题.

您只需要为要播放的每个音乐文件创建一个新的播放器实例.

示例代码段:

-(void)playSounds{

[self playSound1];

[self playSound2];

}

-(void)playSound1{

NSString *path = [[NSBundle mainBundle] pathForResource:@"file1"

ofType:@"m4a"];

AVAudioPlayer* player= [[AVAudioPlayer alloc] initWithContentsOfURL:

[NSURL fileURLWithPath:path]

error:NULL];

player.delegate = self;

[player play];

}

-(void)playSound2{

SString *path = [[NSBundle mainBundle] pathForResource:@"file2"

ofType:@"m4a"];

AVAudioPlayer* player= [[AVAudioPlayer alloc] initWithContentsOfURL:

[NSURL fileURLWithPath:path]

error:NULL];

player.delegate = self;

[player play];

}

转换为支持的格式(即mp3到caf):

/usr/bin/afconvert -f caff -d ima4 sound.mp3 sound.caf

详细教程:

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。