iPhone progressive download audio player [closed] - iphone

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I'm trying to implement a progressive download audio player for the iPhone, using http and fixed size mp3-files.
I found the AudioStreamer project but it seems very complicated and works best with endless streams.
I need to be able to find out the total length of audio files and I also need to be able to seek in the files. I found a hacked deviation from AudioStreamer but it doesn't seem to work very well for me. http://www.saygoodnight.com/?p=14
I'm wondering if there is a simpler way to achieve my goals or if there are some better working samples out there? I found the bass library but not much documentation about it.
/Br Johannes

There's unfortunately nothing simple about playing audio streams on the iPhone. Here's the article that got me started:
Streaming and playing an MP3 stream
It's an OSX project, but most of it will work with the iPhone too. As for getting the full play time of it, you'd probably have to figure that out based on the content-length property of http header, provided it's a CBR file. Otherwise, I imagine you'd have to download the entire file before determining that.

If you only need to play MP3 files, why are you writing your own downloader/player? You have a few options built into iOS, each of which support progressive download and MP3 playback:
MPMoviePlayerController
AVPlayer
Safari <audio> player
I've personally had issues with the progressive download capabilities of MPMoviePlayerController and AVPlayer, so perhaps this is your issue also. I've found that these players try to be smart by requesting the mp3 multiple times, checking to see if the server supports progressive download via http range offsets. But when the server doesn't support range offsets the file is downloaded multiple times, eating bandwidth (!).
In my latest project I embedded a UIWebView having a html <audio> tag embedded. The Safari player seems to behave better than AVPlayer and MPMoviePlayerController, but it had its own caveats as well. For one, getting autoplay to work was a PITA.

There's a really good chapter about streaming audio in iPhone Cool Projects.
http://apress.com/book/view/9781430223573
It shows a simpler approach then AudioStreamer (Using NSURLConnection instead of CFNetwork), better suited for progressive downloading, and no multi threading code.
And for finding out the size of the audio file you can use [response expectedContentLength] in
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response

I know this is a rather old post, but wanted to suggest a solid library that is open source. It is based on Matt Gallagher's original post recommended by #pzearfoss above. The current version uses AudioUnits now, rather than the AudioQueue classes, so it gives you access to the raw PCM samples for any manipulation you want to make (filtering, etc.) before playback. It also gives you progressive download capabilities for free, with rather minimal effort. The library seems to be actively updated which is a huge plus!
StreamingKit by #tumtumtum

Related

Video streaming solutions

I am attempting to stream a video, in a format unity3d can access, like an mjpg. I have gone through several possible solutions, including gstreamer(only does client side as far as I could tell by the examples), yawcam(I couldn't find a way to access the image directly), and silverlight(due to simply not being able to find how the heck webcam streaming was doable) I am currently just looking for any more methods of getting video over from one side to the other. Could I possibly simply read the images into a byte array and send it over a socket? Maybe I missed something in the previous three possible solutions?
If you are looking to stream video from a server than you can use Ogg encoding + WWW.movie to map it to a texture. Assuming you have a Pro license, as I think this is a Pro only feature. If this is a local file, either bundled with the app or in external folder, we use the brilliant AVPro Windows Media or AVPro QuickTime. MJPEG does offers super smooth scrubbing with AVPro but generates enormous files. Definitely not ideal for streaming or even download!
Finally RenderHead also has a Live Camera capture plugin that could meet your needs.

Record streaming radio to MP3 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Background
My father has an old radio program that he loves.
It is a series of recordings done 30-40 years ago, but now he has found out that they are sent now and then as a historical retrospects. He loves them and don't want to miss a single one.
He is eager to record them so I found a little program called CoolRecord that can record from broadcast through web player. It works OK, but the problem is that there recording is done through audio card and when he uses Skype to talk to his grandchildren he always messes up sound settings and when the next recording session comes everything is chaos ....
Idea
Now I recently found out that it is possible to catch the radio stream BEFORE it passes through the audio card. This is great news! I searched and found the url to the broadcast. On http://www.listenlive.eu/sweden.html I found the following url that looks promising: http://sverigesradio.se/topsy/direkt/1602-hi-mp3.pls. It is an MP3 decoded stream with 192 kbps.
I searched the web and found several software for listening to radio and even record, but all Windows based software that I have found records audio stream after it has passed through the computer audio card ....
I actually found a freeware for Mac who does the right thing. It is called FStream but it has no Windows version ;-)
My intention is therefore to build a VERY simple program that will always connect to the same radio station and catch the stream directly without going through the audio card.
I want to keep it dead simple to my father: All he needs to do is to push a big red record button when it is time for his favorite program! No hassle with confusing audio settings, just a file automatically saved to his audio directory.
Questions
I prefer to use C#.
I guess the .Net class library has some useful methods that might help me on ....
But I have never worked with radio streaming and broadcast technology.
1) How do I set up a "stream listener"?
2) Is it possible to detect program title and automate the recording start/stop?
3) How do I save the stream to a MP3 file? Do I need to add headers etc?
4) Do I need to take care of possible interrupts in the streaming?
Have a look at streamripper. It seems to be doing what you're trying to achieve and is also available on windows. It also seems to be generating separate mp3s automatically using silent marks in the audio stream if you want to.
There also exists a "dead simple" frontend to streamripper, called SimpleRipper which might be just what you need.
The latest version of NAudio added support for MP3 streams. It's a very mature audo management library for .NET that is easy to work with.
You can stream the incoming buffer into most supported audio formats.

iOS Advanced Audio API for decompressing format

On iOS, is it possible to get the user's audio stream in a decompressed format? For example, the MP3 is returned as a WAV that can be used for audio analysis? I'm relatively new to the iOS platform, and I remember seeing that this wasn't possible in older iOS versions. I read that iOS 4 brought in some advanced APIs but I'm not sure where I can find documentations/samples for these.
If you don't mind using API for iOS 4.1 and above, you could try using the AVAssetReader class and friends. In this similar question you have a full example on how to extract video frames. I would expect the same to work for audio, and the nice thing is that the reader deals with all the details of decompression. You can even do composition with AVComposition to merge several streams.
These classes are part of the AVFramework, which allows not only reading but also creating your own content.
Apple has an OpenAL example at http://developer.apple.com/library/mac/#samplecode/OpenALExample/Introduction/Intro.html where Scene.m should interest you.
The Apple documentation has this picture where the Core Audio framework clearly shows that it gives you MP3 out. It also states that you can access audio units in a more radical way if you so need.
The same Core Audio document gives also some information about using MIDI if it may help you.
Edit:
You're in luck today.
In this example an audio file is loaded and fed into an AudioUnit graph. You could fairly easily write an AudioUnit of your own to put into this graph and which analyzes the PCM stream as you see fit. You can even do it in the callback function, although that's probably not a good idea because callbacks are encouraged to be as simple as possible.

Creating YouTube videos in iPhone app

I'm doing a project where we want to create a video inside an iPhone app and upload it to YouTube. I've seen the you upload the video using Google's Data API (http://code.google.com/p/gdata-objectivec-client/).
However it seems that you need to upload the movie as an actual movie. Has anyone got any experience on making a movie in a format that YouTube will accept via the Data API and care to give me a few pointers on what would work?
(Just a quick note, I cannot use hidden APIs for this project)
Many thanks
Youtube accepts a broad range of formats. Just try it yourself, use any free video editing software to create a short movie and upload that movie to youtube, you're almost guaranteed that youtube would be able to process that.
The second part of your question is whether ios is able to produce a movie from still frames, then the answer is - yes - and you want to look at AVFoundation, particularly at AVAssetWriter

iPhone SDK: Is it possible to process audio file from local library

Well, I will try best not to make it as a 'I just want the code' question...
I'm recently working on a project which requires some audio signal processing from local music files (e.g. iTunes Library). The whole work includes:
Get the PCM data of an audio file (normally from iTunes library); <--AudioQueue (?)
Write the PCM data to a new file (it seems that Apple does not allow direct modification on music tracks); <--CoreAudio(?)
Do some processing and modification, like filters, manipulators, etc. <-- Will be developed in C++
Play the processed track. <--RemoteIO
The problem is, after going through some blogs and discussions:
http://lists.apple.com/archives/coreaudio-api/2009/Aug/msg00100.html, http://atastypixel.com/blog/using-remoteio-audio-unit/
http://osdir.com/ml/coreaudio-api/2009-08/msg00093.html
as well as the official sample codes, I got a feeling that the CoreAudio SDK allow us to apply audio processing only on voice demos recorded from Mic.
My question is that:
Can I get raw data from iTunes library tracks instead of Mic input?
If the first question is 'No', is there a way to 'fool' the SDK to let it think it is getting data from Mic input, not from iTunes? (I have done some similar 'hacking' stuff in C# before XD)
If the whole processing just doesn't work, can anyone provide some alternative ideas?
Any help will be appreciated. Thank you very much :-)
Thanks.
Just found something really cool yesterday.
From iPhone Media Library to PCM Samples in Dozens of Confounding, Potentially Lossy Steps
(http://www.subfurther.com/blog/?p=1103
And also a class library by MIT:
TSLibraryImport: Objective-C class + sample code for importing files from user's iPod Library in iOS4.
(http://bitbucket.org/artgillespie/tslibraryimport/changeset/a81838f8c78a
Hope they help!
Cheers,
Manca
1) No. Apple does not allow direct access to PCM data of songs. Otherwise you could create music-sharing apps, which is not in Apple's interests.
2) No. Hacking and getting approved is impossible due to Apple's code approval mechanism.
3) The only alternative I could think of is that you have to do the processing part on PC/Mac and then transfer it to the iPhone. Or you would have to store the files in your own applications folder - you should be able to load and process these via CoreAudio.
I know this thread is old but... did this work for you, Manca? And did this app get approved?
EDIT: just discovered the AVAssetReader class, introduced since iOS 4.1, should help