小编bor*_*rel的帖子

AVFoundation:使用 AVAudioEngine 和 AVAudioFile 的格式错误的 .m4a 文件

我在使用 iOS 8 beta 中新的 AVFoundation 框架使用 AVAudioEngine 和 AVAudioFile 写入数据时遇到问题。

我想使用 m4a 格式在输入节点上点击来写入数据。但是,输出文件似乎已损坏,但使用完全相同的设置将文件格式更改为 .aac,文件格式正确并且可以成功播放:

import Foundation
import AVFoundation

func captureMicrophoneInput() {
    var error : NSError?

    var audioFileSettings = Dictionary<NSObject, AnyObject>()
    audioFileSettings[AVFormatIDKey]                 = kAudioFormatMPEG4AAC
    audioFileSettings[AVNumberOfChannelsKey]         = 1
    audioFileSettings[AVSampleRateKey]               = 44100.0
    audioFileSettings[AVEncoderBitRatePerChannelKey] = 16
    audioFileSettings[AVEncoderAudioQualityKey]      = AVAudioQuality.Medium.toRaw()

    let audioEngine = AVAudioEngine()
    let inputNode = audioEngine.inputNode

    // by using .acc the output file can be played successfully
    let url : CFURL = NSURL.fileURLWithPath("/path/to/outputdir/myFileWithProblematicExtension.m4a") as CFURL
    var audioFile = AVAudioFile(forWriting: url, settings: audioFileSettings, …
Run Code Online (Sandbox Code Playgroud)

beta avfoundation swift ios8

5
推荐指数
1
解决办法
3870
查看次数

AVAudioConverter在iOS 10中被破坏了

AVAudioConverter似乎在iOS 10中被破坏了.该代码现在在iOS 9中运行

错误域= NSOSStatusErrorDomain代码= -50"(null)"

无论使用何种音频格式,都会返回.每年都让我感到惊讶,基本的库功能停止工作.

func audioConverterFailureIOS10() {
    // Describe the audio format
    let inFormat = AVAudioFormat(standardFormatWithSampleRate: 44100, channels: 2)
    let outFormat = AVAudioFormat(standardFormatWithSampleRate: 22050, channels: 2)

    // Allocate buffers
    let outBuffer = AVAudioPCMBuffer(pcmFormat: outFormat, frameCapacity: 1024)

    // Create an input block that is called when the converter needs input
    let inputBlock : AVAudioConverterInputBlock = { (inNumPackets, outStatus) -> AVAudioBuffer? in
        // Fails before entering here
        return nil
    }

    // Create the audio converter
    let converter = AVAudioConverter(from: …
Run Code Online (Sandbox Code Playgroud)

avfoundation ios10 avaudioconverter

5
推荐指数
1
解决办法
876
查看次数

在Android中嵌套片段是不是很糟糕?

我有iOS开发人员的背景,目前我正在使用Xamarin将应用程序从iOS移植到Android.在这方面,我对Android上的视图层次结构有一些疑问.

附加的UML图显示了应用程序片段之间交互的子集.我希望我的视图控制器类具有有限的责任,通过嵌套片段(相当于iOS上的容器视图控制器)以一种干净利落的方式封装功能.

但是,Android开发人员告诉我,由于严重的性能下降,嵌套碎片很糟糕.我不关心性能的小幅下降,但应用程序当然应该是响应式的.我们只针对较新的平板电脑和手机.

是否应该在Android上避免嵌套片段?什么是性能下降,如果有的话?(这里给出的例子约为1毫秒:http://developer.android.com/training/improving-layouts/optimizing-layout.html)

谢谢! 在此输入图像描述

更新:应用程序的布局如下所示.ModelControllerFragment内部的功能相当复杂,因为加载了2D/3D模型并且可以完成模型操作(全屏),并且从应用程序中的多个位置使用来自ImageEditFlowActivity的流.CommentListFragment也有一些非默认行为.在一个片段内具有所有这些功能是不可取的. 在此输入图像描述

android android-fragments

1
推荐指数
1
解决办法
2354
查看次数