草庐IT

ios - AVMediaTypeAudio 在 iOS 11 中不起作用

coder 2023-09-30 原文

我正在处理音频合并,它在 iOS 10 上运行良好,但在 iOS 11 上运行不正常。

如何在 iOS 11 中访问音频文件路径?

NSArray *path;
path = [NSArray arrayWithObjects:
        [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 
         NSUserDomainMask, YES) lastObject],
        [NSString stringWithFormat:@"%@%@",trackName,(i==0) ? 
        (_editRecoding) ? fileExtension : @".mp3" : ([trackName 
        isEqualToString:@"temp"]) ? @".mp3" : @""],
        nil];

AVURLAsset* audioAsset = [[AVURLAsset alloc] initWithURL:[NSURL 
                          fileURLWithPathComponents:path] options:nil];


 NSLog(@"audioAsset : %@", audioAsset);
 NSLog(@"AVMediaTypeAudio : %@", [audioAsset tracksWithMediaType:AVMediaTypeAudio]);

iOS 10 中的输出:

 audioAsset : <AVURLAsset: 0x17422b480, URL = file:///var/mobile/Containers/Data/Application/6E092FA1-BE2C-4ECC-897F-3599005F2936/Documents/temp.mp3>

 AVMediaTypeAudio : (
    "<AVAssetTrack: 0x170011fb0, trackID = 1, mediaType = soun>"
)

iOS 11 中的输出:

audioAsset : <AVURLAsset: 0x1c4437ba0, URL = file:///var/mobile/Containers/Data/Application/EC64309F-7E09-4DAE-B19C-2A8F160627C3/Documents/temp.mp3>

AVMediaTypeAudio : (
)

最佳答案

How can i access the audio path in ios 11?

与您已经在使用的方法没有什么不同。 根据 AVMediaType documentation IOS11 没有 api 变化。

解决方案:

我打赌你的 IOS 11 版本是 11.0.2,所以你应该升级到 11.0.3,他们在这个版本中修复了这个音频问题,看看发行说明。

Apple 的 iOS 11.0.3 发行说明列出了针对两个特定问题的修复:

1. 修复了音频和触觉反馈在某些 iPhone 7 和 iPhone 7 Plus 设备上不起作用的问题

2. 解决了在某些 iPhone 6s 显示屏上触摸输入无响应的问题,因为它们不是使用原装 Apple 部件的服务

并且在你更新到最新版本之前先检查一下升级后我会遇到什么新问题。

Prevention is better than cure

检查一下 11.0.3 update在你决定你应该做什么之后。

关于ios - AVMediaTypeAudio 在 iOS 11 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46908347/

有关ios - AVMediaTypeAudio 在 iOS 11 中不起作用的更多相关文章

  1. ruby-on-rails - 如果 Object::try 被发送到一个 nil 对象,为什么它会起作用? - 2

    如果您尝试在Ruby中的nil对象上调用方法,则会出现NoMethodError异常并显示消息:"undefinedmethod‘...’fornil:NilClass"然而,有一个tryRails中的方法,如果它被发送到一个nil对象,它只返回nil:require'rubygems'require'active_support/all'nil.try(:nonexisting_method)#noNoMethodErrorexceptionanymore那么try如何在内部工作以防止该异常? 最佳答案 像Ruby中的所有其他对象

  2. ruby-on-rails - s3_direct_upload 在生产服务器中不工作 - 2

    在Rails4.0.2中,我使用s3_direct_upload和aws-sdkgems直接为s3存储桶上传文件。在开发环境中它工作正常,但在生产环境中它会抛出如下错误,ActionView::Template::Error(noimplicitconversionofnilintoString)在View中,create_cv_url,:id=>"s3_uploader",:key=>"cv_uploads/{unique_id}/${filename}",:key_starts_with=>"cv_uploads/",:callback_param=>"cv[direct_uplo

  3. ruby - 如何验证 IO.copy_stream 是否成功 - 2

    这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下

  4. Ruby 文件 IO 定界符? - 2

    我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的

  5. ruby - 安装libv8(3.11.8.13)出错,Bundler无法继续 - 2

    运行bundleinstall后出现此错误:Gem::Package::FormatError:nometadatafoundin/Users/jeanosorio/.rvm/gems/ruby-1.9.3-p286/cache/libv8-3.11.8.13-x86_64-darwin-12.gemAnerroroccurredwhileinstallinglibv8(3.11.8.13),andBundlercannotcontinue.Makesurethat`geminstalllibv8-v'3.11.8.13'`succeedsbeforebundling.我试试gemin

  6. Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting - 2

    1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里

  7. ruby-on-rails - "assigns"在 Ruby on Rails 中有什么作用? - 2

    我目前正在尝试学习RubyonRails和测试框架RSpec。assigns在此RSpec测试中做什么?describe"GETindex"doit"assignsallmymodelas@mymodel"domymodel=Factory(:mymodel)get:indexassigns(:mymodels).shouldeq([mymodel])endend 最佳答案 assigns只是检查您在Controller中设置的实例变量的值。这里检查@mymodels。 关于ruby-o

  8. ruby - 为什么不能使用类IO的实例方法noecho? - 2

    print"Enteryourpassword:"pass=STDIN.noecho(&:gets)puts"Yourpasswordis#{pass}!"输出:Enteryourpassword:input.rb:2:in`':undefinedmethod`noecho'for#>(NoMethodError) 最佳答案 一开始require'io/console'后来的Ruby1.9.3 关于ruby-为什么不能使用类IO的实例方法noecho?,我们在StackOverflow上

  9. ruby - ri 有空文件 – Ubuntu 11.10, Ruby 1.9 - 2

    我正在运行Ubuntu11.10并像这样安装Ruby1.9:$sudoapt-getinstallruby1.9rubygems一切都运行良好,但ri似乎有空文档。ri告诉我文档是空的,我必须安装它们。我执行此操作是因为我读到它会有所帮助:$rdoc--all--ri现在,当我尝试打开任何文档时:$riArrayNothingknownaboutArray我搜索的其他所有内容都是一样的。 最佳答案 这个呢?apt-getinstallri1.8编辑或者试试这个:(非rvm)geminstallrdocrdoc-datardoc-da

  10. ruby - 字符串文字前面的 * 在 ruby​​ 中有什么作用? - 2

    这段代码似乎创建了一个范围从a到z的数组,但我不明白*的作用。有人可以解释一下吗?[*"a".."z"] 最佳答案 它叫做splatoperator.SplattinganLvalueAmaximumofonelvaluemaybesplattedinwhichcaseitisassignedanArrayconsistingoftheremainingrvaluesthatlackcorrespondinglvalues.Iftherightmostlvalueissplattedthenitconsumesallrvaluesw

随机推荐