PDA

View Full Version : Develop player to play .mp3 file in iphone




hemalimojidra
Jan 12, 2009, 04:04 AM
Hi friends,
I am not getting how to play .mp3 file in iphone. I want to develop a player that can play multiple .mp3 file in iphone. And also want to control volume of that file.Is there any online tutorial or else that can help me to solve my problem?

Hopefully...
Hemali



fenrus110
Jan 12, 2009, 02:17 PM
I think it is against the rules to develop a competing Apple application.

vineetpatidar
Jan 13, 2009, 06:49 AM
Hi Hemali,

I am also facing same problem, can you help me how are you going to sloving this issuse, are you using Audiotoolkit framework(Speak here) example. or you know it other way

Thanks

Vineet

jnic
Jan 13, 2009, 08:16 AM
http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AudioandVideoTechnologies/chapter_9_section_2.html
http://developer.apple.com/iphone/library/codinghowtos/AudioAndVideo/index.html

hemalimojidra
Jan 16, 2009, 06:35 AM
Hi Hemali,

I am also facing same problem, can you help me how are you going to sloving this issuse, are you using Audiotoolkit framework(Speak here) example. or you know it other way

Thanks

Vineet

Hello vineetpatidar,
Yes i am also using this application (Speak here) for reference and oalTouch application. And also using AudioToolkit Framwork. But can not play .mp3 file.

Thanks,
I can play .aif, .caf, .wave file. But i can not play .mp3 file.


i have change the file type in code is
///////
OSStatus result = AudioFileOpenURL (
(CFURLRef)audioFileURL,
0x01,
kAudioFileMP3Type,//
&audioFileID
);

NSLog(@"openPlaybackFile File Statud :%@",result);
////////////
And also change the buffersize in code.

But can't play .mp3 file. Bcoz it is vbr(Variable bitrate file formate) file.

If you get ant solution than please help me.

hemalimojidra
Jan 16, 2009, 06:42 AM
http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AudioandVideoTechnologies/chapter_9_section_2.html
http://developer.apple.com/iphone/library/codinghowtos/AudioAndVideo/index.html

hello jnic,
I have already read this all thing. :confused: I can play .aif, .caf, .wave file. But i can not play .mp3 with this. Have you any example related to this point? Than please tell me. I have tried my best level. Stile trying.. Will get than inform you!:)

Thank you,

jnic
Jan 16, 2009, 07:40 AM
First link I posted mentions "mp3" almost a dozen times...

#import <AVFoundation/AVFoundation.h>

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"foo" ofType:@"mp3"]];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
[audioPlayer play];

hemalimojidra
Jan 16, 2009, 10:21 PM
First link I posted mentions "mp3" almost a dozen times...

#import <AVFoundation/AVFoundation.h>

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"foo" ofType:@"mp3"]];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
[audioPlayer play];

Hello jnic,
i have already Use this framwork. But this AVFoundation is awaylable with iphone-os-2.2. and mac-os-10.5.5. I have this sdk2.2(iphone os-2.2) but i have not that mac-os-10.5.5. that's way i couldn't compile it with my sdk and my mac. Have you any idea related to this? Have you face this kind of problem? If you have any idea related to this than please help me. I have mac-os-10.5.5 update but using this my mac-os is being corrupted. If you know this problem than also please reply me.

From where i can solve my this type of probleme?

hopefully;
Hemali Mojidra

hemalimojidra
Jan 16, 2009, 10:46 PM
I think it is against the rules to develop a competing Apple application.

How it is against the rules to develop a competing Apple application?

firewood
Jan 16, 2009, 11:19 PM
How it is against the rules to develop a competing Apple application?

Read the SDK agreement. There are rules somewhere around section 3.3.

.

firewood
Jan 16, 2009, 11:21 PM
I think it is against the rules to develop a competing Apple application.

Not every app that plays mp3's is a competing app. Most games with built-in mp3 background music for instance.

.

hemalimojidra
Jan 17, 2009, 04:50 AM
Not every app that plays mp3's is a competing app. Most games with built-in mp3 background music for instance.

.

Yes I got it.
Thank you.

hemalimojidra
Jan 17, 2009, 05:08 AM
First link I posted mentions "mp3" almost a dozen times...

#import <AVFoundation/AVFoundation.h>

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"foo" ofType:@"mp3"]];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
[audioPlayer play];

Thank you jnic,
I have read your all post related to this and finally i can play .mp3 file.
I have use MediaPlayerFramework to play .mp3 file.
I have still probleme with AVFoundation FrameWork.If you get solution than please reply. Waiting.....:)


Can we play multiple .mp3 file at same time?
I think No.. But if you know than plz tell.

Thank you,
Hemali mojidra

kientt
Feb 6, 2009, 07:28 PM
Hi friends,
I am not getting how to play .mp3 file in iphone. I want to develop a player that can play multiple .mp3 file in iphone. And also want to control volume of that file.Is there any online tutorial or else that can help me to solve my problem?

Hopefully...
Hemali

Hi all!
You can add this code in .mm file bellow:

if (audioFormat.mBytesPerPacket == 0 || audioFormat.mFramesPerPacket == 0) {
packetDescriptions = (AudioStreamPacketDescription*)malloc(
numPacketsToRead * sizeof(AudioStreamPacketDescription)
);
} else {
packetDescriptions = NULL;
}

I have try and very good,
best regards