 |
 |
|
 |
07-23-2008, 09:52 AM
|
#1 (permalink)
|
|
Junior Member
Join Date: Jul 2008
Posts: 19
Rep Power: 0
|
Mp3 Playback
I everybody.
I have question about the mp3 playback with the audio queue services.
I've take the SpeakHere Sample, and I just kept the AudioPlayer part since I don't need to record audio.
With it I've been able to play wav files without problem, but that don't work with mp3 or aac files. The playbackCallback function is only called when the setupAudioQueueBuffers is called and never again...
So is their anything I need to change this sample in order to play mp3 files...?
Thanks
|
|
|
07-24-2008, 08:33 AM
|
#2 (permalink)
|
|
Junior Member
Join Date: Jul 2008
Posts: 19
Rep Power: 0
|
Any body with an idea? ...
|
|
|
07-24-2008, 11:00 AM
|
#3 (permalink)
|
|
Senior Member
Join Date: Jul 2008
Posts: 132
Rep Power: 1
|
Well...
Quote:
Originally Posted by StrAbZ
I everybody.
I have question about the mp3 playback with the audio queue services.
I've take the SpeakHere Sample, and I just kept the AudioPlayer part since I don't need to record audio.
With it I've been able to play wav files without problem, but that don't work with mp3 or aac files. The playbackCallback function is only called when the setupAudioQueueBuffers is called and never again...
So is their anything I need to change this sample in order to play mp3 files...?
Thanks
|
I wouldn't recommend using mp3 period. I don't think the iphone likes mp3 files very well. I would use .caf files for sound only. Just convert your mp3 to caf. It's the best bet since you only can play 5 sec files anyway. Hope this helps.
|
|
|
07-24-2008, 11:30 AM
|
#4 (permalink)
|
|
Junior Member
Join Date: Jul 2008
Posts: 19
Rep Power: 0
|
The fact is that I need to play mp3 since, the user of the application downloads the files before they are played, and mp3 are still one of the smallest audio files.
Maybe I didn't used the right word, by using "sound", since, that's audio files from about 5 to 10 min that I need to play...
You said that I only can play 5 sec files... but AudioQueueServices can play longer files... (the wav I play is about 40s). So I don't understand what you meaned...
thank u
|
|
|
07-24-2008, 11:31 AM
|
#5 (permalink)
|
|
Member
Join Date: Jul 2008
Posts: 93
Rep Power: 0
|
Quote:
Originally Posted by MaCeXpErTo
I wouldn't recommend using mp3 period. I don't think the iphone likes mp3 files very well. I would use .caf files for sound only. Just convert your mp3 to caf. It's the best bet since you only can play 5 sec files anyway. Hope this helps.
|
StrAbZ is using the Audio Queue services which can play sounds without a time limit....
Starbz I had the same problem as you... and the answer couldn't even be answered on the apple support forums. I decided to go with aif.. MP3 or AAC would be better for me since I can make the file sizes very small.
I hope you find the answer ... if you do, please share with us. I'll be researching it also.
|
|
|
07-24-2008, 11:50 AM
|
#6 (permalink)
|
|
Senior Member
Join Date: Jul 2008
Posts: 132
Rep Power: 1
|
Oh...
Quote:
Originally Posted by StrAbZ
The fact is that I need to play mp3 since, the user of the application downloads the files before they are played, and mp3 are still one of the smallest audio files.
Maybe I didn't used the right word, by using "sound", since, that's audio files from about 5 to 10 min that I need to play...
You said that I only can play 5 sec files... but AudioQueueServices can play longer files... (the wav I play is about 40s). So I don't understand what you meaned...
thank u
|
Oh... Sorry, I missed the part of (AudioQueueServices) lol... Yea, you should be able to use mp3 in it. I've always been told to stay away from mp3 on the iphone. So that's why I convert everything but in your case you said you need it because of file size. I don't see why you couldn't use AAC? AAC isn't that far off from mp3 in size.
Anyways, have a look at this link. It should help you.
iPhone Audio (7 Parts)
|
|
|
07-24-2008, 12:45 PM
|
#7 (permalink)
|
|
Junior Member
Join Date: Jul 2008
Posts: 19
Rep Power: 0
|
I'll be really happy to use AAC, but as the mp3 they don't play
I'll try your link, it's look like the code I already have, but maybe I miss something.
I'll be back soon
|
|
|
07-24-2008, 12:48 PM
|
#8 (permalink)
|
|
Member
Join Date: Jul 2008
Posts: 93
Rep Power: 0
|
Quote:
Originally Posted by MaCeXpErTo
Oh... Sorry, I missed the part of (AudioQueueServices) lol... Yea, you should be able to use mp3 in it. I've always been told to stay away from mp3 on the iphone. So that's why I convert everything but in your case you said you need it because of file size. I don't see why you couldn't use AAC? AAC isn't that far off from mp3 in size.
Anyways, have a look at this link. It should help you.
iPhone Audio (7 Parts)
|
That article was great... but sadly.. it doesn't explain how to use mp3 format or aac format.
|
|
|
07-25-2008, 04:08 AM
|
#9 (permalink)
|
|
Junior Member
Join Date: Jul 2008
Posts: 19
Rep Power: 0
|
So, I took a look at this link, but without success... I'm still getting the same thing... no sound
Just to be sure, for all my mp3 the "numPacketsToRead" calcuted is 19... is that good?
What's kills me , is that the code seems to work. It gives me the right audiofiles length, bitrate etc...
|
|
|
08-20-2008, 12:08 PM
|
#10 (permalink)
|
|
Code Monkey
Join Date: Aug 2008
Location: San Jose
Posts: 7
Rep Power: 0
|
I know the answer for you, I think! But I can only get you so far... since even though I can now play MP3 files perfectly on the simulator, I'm still having trouble getting them to behave correctly on the phone. But I CAN get at least one to play on the phone itself... so I know I'm 99% of the way there.
The SpeakHere sample (which I used as well, leading to much frustration) leaves out a hugely important piece of code. You need to manually allocate the package decriptions for VBR content... and AAC/MP3 files are always considered VBR even if they're encoded CBR!!! Here's the test and allocation:
Code:
// Test for VBR format files, which need extra initialization
if (audioFormat.mBytesPerPacket == 0 || audioFormat.mFramesPerPacket == 0) {
packetDescriptions = (AudioStreamPacketDescription*)malloc(
numPacketsToRead * sizeof(AudioStreamPacketDescription)
);
} else {
packetDescriptions = NULL;
}
Just stick a version of this somewhere in your code, after you've loaded the audio format information and calculated your packets to read and buffer sizes, but before you read and enqueue the data. It's all spelled out in the documentation, but it's easy to miss or think you don't need it (like I did). Once I added this allocation step, MP3s play just fine in the simulator! Woo!
Audio Queue Services Guide - Set Sizes for a Playback Audio Queue
I hope this helps, or helps anyone else who stumbles across your post when trying to figure this stuff out like I did!
And maybe now someone else can help me with my problem!
|
|
|
08-20-2008, 12:08 PM
|
#11 (permalink)
|
|
Code Monkey
Join Date: Aug 2008
Location: San Jose
Posts: 7
Rep Power: 0
|
Quote:
Originally Posted by StrAbZ
So, I took a look at this link, but without success... I'm still getting the same thing... no sound
Just to be sure, for all my mp3 the "numPacketsToRead" calcuted is 19... is that good?
What's kills me , is that the code seems to work. It gives me the right audiofiles length, bitrate etc... 
|
BTW, 19 is exactly what I get when trying to play MP3s, so it looks like your data is good at least.
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
|
» Online Users: 184 |
| 10 members and 174 guests |
| Alexman, atsd, BostonMerlin, comtek, lepetitapps, Neverever, Raphy, Slecorne, Stitch, _mubashir |
| Most users ever online was 779, 05-11-2009 at 09:55 AM. |
» Stats |
Members: 8,172
Threads: 20,132
Posts: 89,979
Top Poster: RickMaddy (2,121)
|
| Welcome to our newest member, juicysen |
|