[翻译] 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 登陆了.咱们看看它可以做什么!深入之前,我还想提一下,严格来说,这些事情中的大部分以前都可以做.如果你 ...
随机推荐
- 安装部署Apache Hadoop (完全分布式模式并且实现NameNode HA和ResourceManager HA)
本节内容: 环境规划 配置集群各节点hosts文件 安装JDK1.7 安装依赖包ssh和rsync 各节点时间同步 安装Zookeeper集群 添加Hadoop运行用户 配置主节点登录自己和其他节点不 ...
- Django实战(12):增加目录页,设定统一布局
针对上一节的新需求,界面设计师还为我们设计了一个新的界面,不仅仅是目录页,还包含了站点的整体风格,如下图: 感谢界面设计师为我们提供的“又黑又硬”的工具条,这个看起来真的很酷.下面,让我们来享用她的工 ...
- vector 邻接表的建立(好笨啊,才懂,可能太困了吧)。。
原创,未经允许不得转载. 图的建立有两种,邻接矩阵和邻接表. 邻接矩阵适用于图较为密集,(稀疏图太浪费存储空间了),图如果较为稀疏,则使用邻接表为宜,dijkstra算法就是以邻接表为基础的. 有向无 ...
- JVM快速入门
最近开始了全面的JAVA生态环境学习,因此,JVM的学习是必不可少的一个环节.和.NET的CLR一样,一起的JAVA应用均跑在JVM虚拟机上,不过相对我们只能干看看的CLR,JVM有很大的灵活性,可以 ...
- C# 非模式窗体show()和模式窗体showdialog()的区别
对话框不是模式就是无模式的.模式对话框,在可以继续操作应用程序的其他部分之前,必须被关闭(隐藏或卸载).例如,如果一个对话框,在可以切换到其它窗 体或对话框之前要求先单击"确定"或 ...
- luoguP4571 [JSOI2009]瓶子和燃料 裴蜀定理
裴蜀定理的扩展 最后返回的一定是\(k\)个数的\(gcd\) 因此对于每个数暴力分解因子统计即可 #include <map> #include <cstdio> #incl ...
- [BZOJ3309]DZY Loves Math(莫比乌斯反演+线性筛)
$\sum\limits_{T=1}^{n}\lfloor\frac{n}{T}\rfloor\lfloor\frac{m}{T}\rfloor\sum\limits_{d|T}f(d)\mu(\fr ...
- 用Win32编写发送消息至Notepad++的程序
这次利用Win32编程写一个发送"Win32 Assembly,My First SendMessage Program !" 每个程序要发送消息至另一个程序的时候,通常使用Sen ...
- shell十三问?
shell 十三问: 1) 为何叫做 shell ? 2) shell prompt(PS1) 与 Carriage Return(CR) 的关系? 3) 别人 echo.你也 echo ,是问 ...
- [COGS 2066]七十与十七
http://218.28.19.228/cogs/problem/problem.php?pid=2066 [题目描述] 七十君最近爱上了排序算法,于是Ta让十七君给Ta讲冒泡排序. 十七君给七十君 ...
