AVAudioPlayer 仪表值仍然 - 160
尝试实现 AVAudioplayer 并获取播放音乐的一些计量数据,但仍然获得值 -160。 看起来很容易使用,只需启用 Meter,然后在计时器下拾取数据,但到目前为止还没有结果。
playerAV = [[AVAudioPlayer alloc] initWithContentsOfURL:outURL error:nil]; playerAV.delegate = self; playerAV.meteringEnabled = YES; [playerAV prepareToPlay]; [playerAV play]; NSLog(@"Peak left: %f Avg right: %f", [playerAV peakPowerForChannel:0],[playerAV averagePowerForChannel:1]);
欢迎任何想法。
Trying to implement AVAudioplayer and get some metering data of the played music, but still getting value -160.
It looks easy to use, just enable Meter and then pickup data under a timer, but no results so far.
playerAV = [[AVAudioPlayer alloc] initWithContentsOfURL:outURL error:nil]; playerAV.delegate = self; playerAV.meteringEnabled = YES; [playerAV prepareToPlay]; [playerAV play]; NSLog(@"Peak left: %f Avg right: %f", [playerAV peakPowerForChannel:0],[playerAV averagePowerForChannel:1]);
any thoughts are welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否正在拨打
updateMeters
?两者的文档peakPowerForChannel:
和averagePowerForChannel:
说:Are you calling
updateMeters
? The docs for bothpeakPowerForChannel:
andaveragePowerForChannel:
say:您如何知道网址有效,并且其末尾的数据格式正确?你能听到扬声器发出的声音吗?
你是否以某种方式制作了两个playerAV对象,一个具有可以播放的正确URL,另一个具有不播放任何内容的错误URL,并且是计时器在调用NSLog()时看到的对象?
How do you know the url works, and the data at the end of it is the right format? Can you hear stuff coming from the speakers?
Are you somehow making two playerAV objects, one with the correct URL which plays, the other with a bad url which plays nothing, and is the one that the timer sees when it calls NSLog()?