测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | MIT |
发布最后发布 | 2014 年 12 月 |
由 Chris Kalafarski 维护。
依赖 | |
sndfile-Framework | >= 0 |
TwoLAME-Framework | >= 0 |
帮助在 Cocoa 和 iOS 应用中创建 MPEG-1 Layer 2 (.mp2) 音频文件。
TWLEncoder 与在 iOS 7 中介绍的 NSURLSession
库的工作方式类似。您使用配置编码器,并使用它创建和运行任务。关于编码器及其任务的信息通过委托进行通信。幕后场景,任务在操作队列中处理。
MP2 音频的主要用途之一是美国的公共广播系统。TWLEncoder附带了一个基本配置,应适用于大多数系统。您可以在使用之前自定义该配置,或从头开始构建配置以满足您的需求。
TWLEncoderConfiguration *config = TWLEncoderConfiguration.publicRadioConfiguration;
TWLEncoder *encoder = [TWLEncoder encoderWithConfiguration:config delegate:self operationQueue:nil];
NSURL *fileURL = [NSURL fileURLWithPath:@"~/Desktop/master-2014_02_19-b.wav"];
TWLEncoderTask *task = [encoder taskWithURL:fileURL];
[task resume]; // Tasks start suspended and must be resumed to begin
- (void)encoder:(TWLEncoder *)encoder task:(TWLEncoderTask *)task didWriteFrames:(int64_t)framesWritten totalFramesWritten:(int64_t)totalFramesWritten totalFrameExpectedToWrite:(int64_t)totalFramesExpectedToWrite bytesWritten:(int64_t)bytessWritten totalBytesWritten:(int64_t)totalBytesWritten {
// eg Update a progress bar in the UI
}
- (void)encoder:(TWLEncoder *)encoder task:(TWLEncoderTask *)task didFinishEncodingToURL:(NSURL *)location {
// eg Copy the encoded file to a permanent location
// The temporary file that the encoding was written to will be removed as soon
// as this method returns, so you must read or relocate the data before then.
}