IOS online audio playback FreeStreamer

Source: Internet
Author: User

IOS online audio playback FreeStreamer

Preface:AboveIn iOS recording practices, we useAVAudioPlayer to play a local audio file. However, in practical applications, we need to play network audio files,In iOS, how does one play network streaming media? The Audio Queue service in the AudioToolbox framework is used. This article will introduce the third-party excellent open-source framework FreeStreamer

 

1. FreeStreamer features

FreeStreamer is an audio playback engine for iOS and OS X, designed specifically for playing audio streams. This engine demonstrates that the UI is simple, efficient, and occupies less memory. It is written in C ++.

Function:
High efficiency and low memory usage (Objective-C method calls do not consume extra performance)
Support for ShoutCast and IceCast streaming media and standard HTTP protocol
Detection of streaming media formats
Support for ShoutCast metadata
Pause is supported, for example, pause playing because of a call.
Supports background playback.
Supports ID3v2
Support for Podcast RSS feeds
Content can be stored in files (view OS X app)
Example of PCM audio that can be accessed
Contains a frequency analyzer (you can view Additions and iOS Apps)

 

2. Usage

 

1. Use cocoapods to install FreeStreamer.

2 Examples

 

# Import ViewController. h # import FSAudioStream. h @ interface ViewController () @ property (nonatomic, strong) FSAudioStream * audioStream; @ end @ implementation ViewController-(void) viewDidLoad {[super viewDidLoad]; [self. audioStream play];}/*** obtain the local file path ** @ return file path */-(NSURL *) getFileUrl {NSString * urlStr = [[NSBundle mainBundle] pathForResource: @ ofofoftype: nil]; NSURL * url = [NSURL fileURLWithPath: urlStr]; return url;}-(NSURL *) getNetworkUrl {NSString * urlStr = @ video address;
NSURL * url = [NSURL URLWithString: urlStr]; return url;}/*** create a FSAudioStream object ** @ return FSAudioStream object */-(FSAudioStream *) audioStream {if (! _ AudioStream) {NSURL * url = [self getNetworkUrl]; // create the FSAudioStream object _ audioStream = [[FSAudioStream alloc] initWithUrl: url]; _ audioStream. onFailure = ^ (FSAudioStreamError error, NSString * description) {NSLog (@ error occurred during playback, error message: % @, description) ;}; _ audioStream. onCompletion = ^ () {NSLog (@ playback completed !); }; [_ AudioStream setVolume: 0.5]; // sets the sound} return _ audioStream;} @ end

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.