[翻译] FreeStreamer 在线流媒体播放

FreeStreamer
https://github.com/muhku/FreeStreamer
Introduction
FreeStreamer is an audio player engine for iOS and OS X, designed for playing audio streams. The engine has a minimal UI for demonstration. Respectfully, see the FreeStreamerDesktop directory for OS X, and,FreeStreamerMobile for the iOS UI.
FreeStreamer 是一个为 iOS 和 OS X 编写的音频播放引擎,用来播放音频流的。这个引擎有一个极简单的 UI 用来示范。你直接查看为 OS X 编写的 FreeStreamerDesktop ,以及为 iOS 编写的 FreeStreamerMobile 。
The engine is written in C++ and the FSAudioController Objective-C class wraps the implementation.
这是用 C++ 写的引擎,用 FSAudioController 类来封装了实现。
FreeStreamer has the following features:
FreeStreamer 有着如下的一些特性:
- 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
- Supports a subset of the ID3v2 tag specification
- Supports Podcast RSS feeds
- The stream contents can be stored in a file (see the OS X application for an example)
- It is possible to access the PCM audio samples (useful if you want your own audio analyzer, for instance)
- Includes a frequency analyzer and visualization, see Additions and the iOS application
- 快速低耗的打印信息(不是 OC 上层方法的调用)
- 支持 ShoutCast 和 IceCast 音频流 + 标准 HTTP
- 能检测流类型,基于包的内容
- 支持 ShoutCast 元数据
- 支持中断(例如,播放音频流的时候打进来了一个电话)
- 支持后台
- 支持 ID3v2 标签子集说明
- 支持广播 RSS feed
- 流内容可以保存到文件中(看看 OS X 应用的例子)
- 他可以处理 PCM 音频
- 包含一个频率分析器并可视化,可以参考 Additions 的例子
API documentation
See here.
Using the player in your own project
Please follow the following steps to use the player in your own project:
请按照以下的步骤来把它添加到你的工程当中:
Make sure you have the following frameworks linked to your project:(包含如下的框架)
- CFNetwork.framework
- AudioToolbox.framework
- AVFoundation.framework
- libxml2.dylib (add
$(SDKROOT)/usr/include/libxml2to the header search path, if not found) - MediaPlayer.framework (iOS only)
Add the Common and astreamer directories to your project. Try building the project now and it should compile successfully.(把文件夹 Common 和 astreamer)添加到你的工程当中,试着编译一下看会不会出错。
iOS only: 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.仅支持 iOS :如果你想支持后台音乐,你可以在 Xcode 的 info tab 中找到相关信息。
You can now stream an audio file like this. Declare the stream in your header file:
你可以这么使用,在你的头文件中声明一下:
@class FSAudioStream;
@interface MyClass : NSObject {
FSAudioStream *_audioStream;
}
Initialize and use the stream in your implementation:
在你的实现文件中初始化:
#import "FSAudioStream.h"
_audioStream = [[FSAudioStream alloc] init];
[_audioStream playFromURL:[NSURL URLWithString:@"http://www.example.com/audio_file.mp3"]];
Note that FSAudioStream must exist during the playback of the stream. Do not declare the class as a local variable of a method or the stream will be deallocated and will not play.
注意,FSAudioStream 必须在播放音频的期间一直存在。不要把它定义成一个实例变量,一个 alloc init 只能播放一个流媒体。
Some servers may send an incorrect MIME type. In this case, FreeStreamer may not be able to play the stream. If you want to avoid the content-type checks (that the stream actually is an audio file), you can set the following property:
许多服务器也许会给你发送错误的 MIME 类型。这种情况下,FreeStreamer 也许就不能播放这个音频了。如果你想避免 content-type 检查(但是这个 steam 依然是音频文件),你可以设置如下的属性:
audioStream.strictContentTypeChecking = NO;
// Optionally, set the content-type where to fallback to
audioStream.defaultContentType = "audio/mpeg";
For streaming playlists, you need to use the FSAudioController.h class. The class has some additional logic to resolve the playback URLs. Again, declare the class:
为了设置播放列表,你可以使用 FSAudioController.h 类。这个类有着一些额外的逻辑来解决回放问题,声明使用与上面的类似:
@class FSAudioController;
@interface MyClass : NSObject {
FSAudioController *_audioController;
}
And use it:
这么使用:
#import "FSAudioStream.h"
_audioController = [[FSAudioController alloc] init];
_audioController.url = @"http://www.example.com/my_playlist.pls";
[_audioController play];
It is also possible to check the exact content of the stream by using the FSCheckContentTypeRequest.h andFSParsePlaylistRequest.h classes:
你也可以精确的检查包的内容,使用 FSCheckContentTypeRequest.h 和 FSParsePlaylistRequest.h 这两个类:
FSCheckContentTypeRequest *request = [[FSCheckContentTypeRequest alloc] init];
request.url = @"http://www.example.com/not-sure-about-the-type-of-this-file";
request.onCompletion = ^() {
if (self.request.playlist) {
// The URL is a playlist; now do something with it...
}
};
request.onFailure = ^() {
};
[request start];
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.
就这些了!更多例子,请参考示例工程。例如,你也许需要监测视频流的状态。
FAQ
See here.
Debugging
To enable debug logging, enable the following line in astreamer/audio_stream.cpp:
#define AS_DEBUG 1
After enabling the line, compile the code and run it.
It is also possible to check the lastError property in the FSAudioStream class:
NSLog(@"Last error code: %i", audioStream.lastError);
Or if you are using the FSAudioController class, then:
NSLog(@"Last error code: %i", audioController.stream.lastError);
Reporting bugs and contributing
For code contributions, please create a pull request in Github.
For bugs, please create a Github issue. I don't have time for private email support, so usually the best way to get help is to interact in Github.
[翻译] FreeStreamer 在线流媒体播放的更多相关文章
- iOS中 流媒体播放和下载 韩俊强的博客
每日更新关注:http://weibo.com/hanjunqiang 新浪微博 iOS中关于流媒体的简介:介于下载本地播放与实时流媒体之间的一种播放形式,下载本地播放必须全部将文件下载完成后才能播 ...
- python制作查找单词翻译的脚本
本人由于英语渣,在linux底下经常看文档,但是有没有想有道词典这种软件,所以遇到不懂的单词只能手动复制粘贴在网上查找,这样就很不方便,学了python之后,就试着自己尝试下个在命令行下查找单词翻译的 ...
- ios流媒体
http://my.oschina.net/CgShare/blog/302303 渐进式下载(伪流媒体) 介于下载本地播放与实时流媒体之间的一种播放形式,下载本地播放必须全部将文件下载完成后才能播放 ...
- Python中urlopen()介绍
#以下介绍是基于Python3.4.3 一. 简介 urllib.request.urlopen()函数用于实现对目标url的访问. 函数原型如下:urllib.request.urlopen( ...
- 树莓派 (Raspberry Pi) 是什么?普通人怎么玩?(私有云NAS也会有;上传到百度盘的功能nas也有)
作者:王震宇链接:https://www.zhihu.com/question/20859055/answer/54734499来源:知乎著作权归作者所有,转载请联系作者获得授权. 我两年前买的(约2 ...
- 实用chrome插件
2015年最实用的9款chrome插件 随着14年chrome浏览器的市场超过IE浏览器,chrome凭借它强劲性能和出色的使用体验真正的登上了平民级的殿堂.今天小编就为大家推荐9款自己常用的chro ...
- MHA官方文档翻译
英文官方文档 http://code.google.com/p/mysql-master-ha/wiki/TableOfContents?tm=6 转载请注明出处 Overview MHA能够在较短的 ...
- 使用HttpClient进行Post通信
---------------siwuxie095 首先到 Apache官网 下载相关的库文件 Apache官网:http://www.apac ...
- iOS 7系列译文:认识 TextKit
OS 7:终于来了,TextKit. 功能 所以咱们到了.iOS7 带着 TextKit 登陆了.咱们看看它可以做什么!深入之前,我还想提一下,严格来说,这些事情中的大部分以前都可以做.如果你 ...
随机推荐
- N皇后问题的实现
N皇后问题是一个经典的问题,是回溯算法的典型案例.它是由国际西洋棋棋手马克斯·贝瑟尔于1848年提出的八皇后问题延伸而来的,具体要求如下:在N*N的方格棋盘放置N个皇后,使她们彼此不相互攻击,即任意2 ...
- 【LOJ】#2123. 「HEOI2015」最短不公共子串
题解 我们对于B串建出后缀自动机和序列自动机 对于问题1,枚举左端点然后跑后缀自动机,直到不能匹配作为这个左端点的答案 对于问题2,枚举左端点然后跑序列自动机,直到不能匹配 对于问题3,设f[i][j ...
- 2014-2015 ACM-ICPC, NEERC, Moscow Subregional Contest B - Bring Your Own Bombs 离散化+扫描线+计算期望
扫描线一边扫一边算期望,细节比较多. #include<bits/stdc++.h> #define LL long long #define fi first #define se se ...
- linux下更换pip源
pip不更换源的话,速度可能非常慢.这里将pip源更换为阿里云源. 1.修改文件~/.pip/pip.conf(没有该文件则创建一个) $ sudo vim ~/.pip/pip.conf 2.写入以 ...
- Think PHP 3.2 界面及JS多语言实现
1.多语言实现的原理在实现多语言的时候需要调用L()函数.那么L函数是如何实现多语言的输出呢?在L函数内部有一个静态变量$_lang一维数组.所有的语言数据都存在在这个数组中.系统在加载的时候根据选择 ...
- Unity:控制粒子特效的移动方向
前几天在项目中遇到一个问题,需求是界面中先展示一段闪光特效,停顿一段时间后特效飞往一个固定的位置然后消失,类似于跑酷游戏吃到金币后金币飞往固定的金币数值显示框那种效果(具体是通过特效来实现还是直接通过 ...
- Wannafly挑战赛9 B - 数一数
链接:https://www.nowcoder.com/acm/contest/71/B来源:牛客网 题目描述 设s,t为两个字符串,定义f(s,t) = t的子串中,与s相等的串的个数.如f(&qu ...
- OpenGL 笔记<3> 数据传递 一
Sending data to a shader using vertex attributes and vertex buffer object 上次我们说到着色器的编译和连接,后面的事情没有做过多 ...
- jQuery事件和动画
1.toggle事件 <!DOCTYPE html> <html> <head lang="en"> <meta charse ...
- hdu1527下沙小面的(二)
B - 下沙小面的(2) Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
