Home News Forum Social Networking Support Us Advertise

Spanish Lesson 1 ($1.99)

aWake!Gently ($1.99)

The Bird & The Snail - Knock Knock - Deluxe ($4.99)

Match-It Trains ($0.99)

Tangled ($0.99)

iFlatter ($0.99)

The 15 puzzle ($0.99)

Tap Forms Database ($8.99)

Higher or Lower Card Game (Hi Lo) ($0.99)

Red Pixel ($0.99)

Time-Shift Radio ($0.99)

Want your application advertised here? Only $10/week!

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-23-2008, 09:52 AM   #1 (permalink)
Junior Member
 
Join Date: Jul 2008
Posts: 19
Rep Power: 0
StrAbZ is on a distinguished road
Default 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
StrAbZ is offline   Reply With Quote
Old 07-24-2008, 08:33 AM   #2 (permalink)
Junior Member
 
Join Date: Jul 2008
Posts: 19
Rep Power: 0
StrAbZ is on a distinguished road
Default

Any body with an idea? ...
StrAbZ is offline   Reply With Quote
Old 07-24-2008, 11:00 AM   #3 (permalink)
Senior Member
 
MaCeXpErTo's Avatar
 
Join Date: Jul 2008
Posts: 132
Rep Power: 1
MaCeXpErTo is on a distinguished road
Smile Well...

Quote:
Originally Posted by StrAbZ View Post
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.
MaCeXpErTo is offline   Reply With Quote
Old 07-24-2008, 11:30 AM   #4 (permalink)
Junior Member
 
Join Date: Jul 2008
Posts: 19
Rep Power: 0
StrAbZ is on a distinguished road
Default

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
StrAbZ is offline   Reply With Quote
Old 07-24-2008, 11:31 AM   #5 (permalink)
Member
 
Join Date: Jul 2008
Posts: 93
Rep Power: 0
mellomike is an unknown quantity at this point
Default

Quote:
Originally Posted by MaCeXpErTo View Post
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.
mellomike is offline   Reply With Quote
Old 07-24-2008, 11:50 AM   #6 (permalink)
Senior Member
 
MaCeXpErTo's Avatar
 
Join Date: Jul 2008
Posts: 132
Rep Power: 1
MaCeXpErTo is on a distinguished road
Arrow Oh...

Quote:
Originally Posted by StrAbZ View Post
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)
MaCeXpErTo is offline   Reply With Quote
Old 07-24-2008, 12:45 PM   #7 (permalink)
Junior Member
 
Join Date: Jul 2008
Posts: 19
Rep Power: 0
StrAbZ is on a distinguished road
Default

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
StrAbZ is offline   Reply With Quote
Old 07-24-2008, 12:48 PM   #8 (permalink)
Member
 
Join Date: Jul 2008
Posts: 93
Rep Power: 0
mellomike is an unknown quantity at this point
Default

Quote:
Originally Posted by MaCeXpErTo View Post
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.
mellomike is offline   Reply With Quote
Old 07-25-2008, 04:08 AM   #9 (permalink)
Junior Member
 
Join Date: Jul 2008
Posts: 19
Rep Power: 0
StrAbZ is on a distinguished road
Default

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...
StrAbZ is offline   Reply With Quote
Old 08-20-2008, 12:08 PM   #10 (permalink)
Code Monkey
 
Join Date: Aug 2008
Location: San Jose
Posts: 7
Rep Power: 0
PKMousie is on a distinguished road
Default

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!
PKMousie is offline   Reply With Quote
Old 08-20-2008, 12:08 PM   #11 (permalink)
Code Monkey
 
Join Date: Aug 2008
Location: San Jose
Posts: 7
Rep Power: 0
PKMousie is on a distinguished road
Default

Quote:
Originally Posted by StrAbZ View Post
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.
PKMousie is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


» 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
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:17 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0