FreeStreamer is an audio player engine for the iPhone/iPad, designed for playing audio streams. The engine has a minimal UI for demonstration; hopefully, it is a helpful example for using the engine.
The engine is written in C++ and the FSAudioController Objective-C class wraps the implementation.
FreeStreamer has the following features:
- Fast and low memory footprint (no overhead of Objective-C method calls)
- Supports ShoutCast and IceCast audio streams + standard HTTP
- Can detect the stream type based on the content type
- Supports ShoutCast metadata
- Supports interruptions (for example a phone call during playing the stream)
- Supports backgrounding
Please follow the following steps to use the player in your own project:
1. Make sure you have the following frameworks linked to your project:
- AVFoundation.framework
- MediaPlayer.framework
- CFNetwork.framework
- AudioToolbox.framework
2. If you want to support background audio, add App plays audio to the target’s Required background modes. You can find the property by clicking on the target on Xcode and opening the Info tab.
3. Copy FSAudioStream.h, FSAudioStream.mm, and everything in the astreamer directory to your project. Try building the project now and it should compile successfully.
You can now stream an audio file like this:
#import "FSAudioStream.h" FSAudioStream *audioStream = [[FSAudioStream alloc] init]; [audioStream playFromURL:[NSURL URLWithString:@"http://www.example.com/audio_file.mp3"]];
That’s it! For more examples, please take a look at the example project. For instance, you may want to observe notifications on the audio stream state.
Some servers may send an incorrect MIME type. In this case, FreeStreamer may not be able to play the stream. If you encounter this problem, please uncomment the AS_RELAX_CONTENT_TYPE_CHECK macro in astreamer/audio_stream.cpp.
Your contributions are most welcome. If you want to send code, please a send a patch and make sure it can be merged to the master branch without conflicts.
If you have anything to ask, you can use email.
The BSD license which the files are licensed under allows is as follows:
Copyright (c) 2011-2012 Matias Muhonen <mmu@iki.fi> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.