在iphone中同时有2个mp3声音?

编程入门 行业动态 更新时间:2024-10-27 10:32:15
本文介绍了在iphone中同时有2个mp3声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我们可以在iphone上同时播放2个mp3声音吗?iphone是否支持此功能?

Can we play 2 mp3 sounds on the same time on the iphone?Does iphone support this feature?

推荐答案

使用音频队列服务(AudioToolbox / AudioQueue.h)中的接口。为要播放的每个声音创建一个音频队列对象。然后使用AudioQueueEnqueueBufferWithParameters函数指定每个音频队列中第一个音频缓冲区的同时开始时间。

Use the interfaces in Audio Queue Services (AudioToolbox/AudioQueue.h). Create one audio queue object for each sound that you want to play. Then specify simultaneous start times for the first audio buffer in each audio queue, using the AudioQueueEnqueueBufferWithParameters function.

以下限制适用于iPhone OS中的同步声音,具体取决于音频数据格式:

The following limitations pertain for simultaneous sounds in iPhone OS, depending on the audio data format:

AAC,MP3和ALAC(Apple Lossless)音频:您可以同时播放多种AAC,MP3和ALAC格式的声音;播放这些格式的多个声音将需要CPU资源进行解码。

AAC, MP3, and ALAC (Apple Lossless) audio: You may play multiple AAC, MP3, and ALAC format sounds simultaneously; playback of multiple sounds of these formats will require CPU resources for decoding.

线性PCM和IMA / ADPCM(IMA4音频):您可以播放多个线性PCM或IMA4格式的声音同时没有CPU资源问题。

Linear PCM and IMA/ADPCM (IMA4 audio): You can play multiple linear PCM or IMA4 format sounds simultaneously without CPU resource concerns.

在一次播放多个声音方面,这很容易,只需为你想玩的每一个创建一个新的播放器实例(并记住)在你完成时释放它们)

In terms of playing multiple sounds at once, that's easy, just create a new player instance for every one that you want to play (and remember to release them when you're done)

NSString *path = [[NSBundle mainBundle] pathForResource:@"YOUR_FILE_NAME" ofType:@"m4a"]; AVAudioPlayer* objAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]; objAudio.delegate = self; [objAudio play];

要将MP3转换为IMA4(您可以同时播放多个),您可以运行以下(在终端,豹子):

To convert an MP3 into something like IMA4 (which you can play more than one at once) you would run the following (in terminal, in leopard):

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

更多信息,请访问音频播放/录制

更多推荐

在iphone中同时有2个mp3声音?

本文发布于:2023-07-11 08:57:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1093501.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:声音   iphone

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!