How to play a downloaded mp3 file? - ios

I have downloaded a mp3 file from a server successfully, but the problem I encountered is, I don't know how to play that file.. Should I use AVAudioPlayer or AudioQueue to play the file?? I will be appreciate if you could post some sample code here.

Both AVAudioPlayer and the Audio Queue API can be used to play MP3 files. The AVAudioPlayer is well documented and has a lot of sample code available. So why not give it try first and if that does not work, post a more specific question here.

Related

How to let AVPlayer plays mp3 from URL without waiting to load the whole file in swift

I am playing a file using AVPlayer and it is working fine. What I am looking for is that when the application plays the file it should play as soon as some enough buffer available. Currently what I have noticed is that if the file is big it waits for longer time to start playing the file which means it waits until the file is loaded in the buffer or so.
Any thoughts?
First, thank you Paul, your hint helped.
I have resolved the issue as follow:
Instead of having the URL as the mp3 file; I have created a text file and called it audio.m3u then I have just wrote the url address of my mp3 file in the newly created file (the m3u). Then played the file (audio.m3u) in the AVPlayer.
thats all :)

Why isn't AVPlayer playing .wav file

I am downloading a .wav file from a server and storing it locally in the file system. Once the file has been downloaded I try and play the file using the AVPlayer.
The url of the file being stored is something like this:
/Users/user/Library/Developer/CoreSimulator/Devices/FC767376-76BC-4402-B51B-SDFS/data/Containers/Data/Application/FA18B9RE-8D6E-4553-0617-4A064478AFF4/Documents/voice/test.wav
I have gone through all the related questions and have checked that I am doing the following:
Keeping reference to the AVPlayer in the viewController
Setting the category on the AVAudioSession
Setting the AVAudioSession to active
using NSURL(fileURLWithPath:) to retrieve the file url
I have tried using AVAudioPlayer
I have also confirmed the url being set on the AVPlayer does infact contain the audio file.
I have generated a test project that reproduces this issues. It can be found at https://github.com/va3093/AVAudioTest
Is it the way that I am storing the file? Is there something wrong with the file formats?
It turns out that the webservice I was using to generate the audiofiles genertate .mp3 files while I was saving them as .wav. When I changed to .mp3 then the audio player started playing the audio files.

Can I extract or convert a video file to audio?

I have a case where i need to get audio out from video file. Is this possible in iOS ??
I need only the output file as an audio any type. I have the video file in my documents directory which I record earlier in application.
1.Convert Video Reverse
2.Extract audio from a video file
3.Add Audio & Video Together
Download Code From Here
may be helpful to you.
Yes, it can be done. See Extract audio from video file for ideas.
Extracting is probably the more accurate term.

Create AAC file programmatically in iOS?

I am creating an iOS app that can play instrument sounds.
The user can play and record his melody.
Now, I need some help to export his record into an AAC file.
Any idea ?
Thanks ;)
Here is a great project that does exactly that by Michael Tayson
you could think about starting with LPCM and then convert this down to AAC.
Have a look at Apple's 'Audio Converter Services Reference' specifically the following:
AudioConverterFillComplexBuffer

Buffering in Blackberry

Currently I am working on the application for which I have to use audio buffering. Please tell me how I can achieve this task as I am trying myself.
read this Buffer and play streamed media
Also, there's a great example in the Blackberry SDK, which shows buffered playback of a MP3 file.
Take a look in the 'samples' folder of JDE/Eclipse Plugin.

Resources