音频单元图暂停和重复 [英] Audio Unit Graph pause and repeating

查看:264
本文介绍了音频单元图暂停和重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用苹果提供的code来实现音频单元图:
<一href=\"http://developer.apple.com/library/ios/#sample$c$c/iPhoneMixerEQGraphTest/Introduction/Intro.html\"相对=nofollow> IphoneMixerEQGraphTest 。到目前为止,我已经遇到了两个问题:

I've been trying to implement Audio Unit Graph using Apple provided code: IphoneMixerEQGraphTest. So far I have encountered two problems:

1)。我找不到任何方式暂停播放

1.) I can't find any way to pause playing

2)提供的示例不休重复。有没有办法我可以禁用或重复或停止吗? - 使用定时器,拦截某种缓冲值,打几乎是在结束的时候

2.) Provided example repeats endlessly. Is There a way I can disable repeat or or stop it - using a timer, intercept some kind of buffer value, when playing is almost at the end?

感谢你。

推荐答案

非重复的功能

到目前为止,我已经找到一种方法来处理音频停止 - 虽然它不是pretty:

So far I have found a way to deal with audio stopping - although it's not pretty:

我AVAudioPlayer加载相同的音频文件 - 并从中声音文件的持续时间得到的。然后,用

I load same audio file in AVAudioPlayer - and get from it sound file duration. Then, using

performSelector:withObject:afterDelay: 

我可以停止AUGraph时的声音文件应该结束播放。

I can stop AUGraph when sound file should end playing.

暂停AUGRAPH的功能

原来,实施暂停是pretty简单。虽然AUGraph数据源不改变 - 通过调用

It turns out that implementing pause is pretty simple. While AUGraph data source is not changed - by calling

[graphController startAUGraph]; or [graphController stopAUGraph];

只会暂停/恢复播放。

will only pause/resume playing.

虽然这会影响performSelector定时器。因此,同时使用 - 暂停/无重复的可能性,应该使用的NSTimer - 当AUGraph暂停 - 那么计时器暂停了。当AUGraph恢复 - 计时器重新开始计数,当它到达提供的声音文件时间 - 它停止播放

Although this affects performSelector timer. So, to use both - pause/no-repeating possibilities, one should use NSTimer - when AUGraph paused - then timer pauses too. When AUGraph resumed - timer resumes counting, and when it reaches provided sound file duration - it stops playing.

底线

通过使用来自AVAudioPlayer(或提供期限任何其他球员)持续时间值 - 这是可能实现AUGraph声音播放器,播放/暂停/停止(不重复/重复)/下一曲/ previous歌曲/功能+扳平比分。

By using duration value from AVAudioPlayer (or any other player which provides duration) - it is possible to implement AUGraph sound player with play/pause/stop (no-repeat/repeat)/next song/previous song/ functions + EQUALIZER.

这篇关于音频单元图暂停和重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆