Xcode中如何制作只要按住按钮就循环播放声音?
那么,如何让声音文件仅在(iOS)中按住某个按钮时播放和循环?当松开按钮时我还需要它停止吗?我尝试搜索谷歌,只找到了有人提问的论坛,但没有关于如何做到这一点的真正答案。
So, how would I make a sound file play and loop only while a certain button is held in (iOS) ? I would also need it to stop when the button was let go? I have tried searching google and have only found forums with people asking but no real answers on how to do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用按钮控制事件 touchdown、touchupinside 和 touchupoutside:
编辑:
意识到您的问题可能更多是关于播放声音文件?!
有不同的框架,您可以使用 AVAudioPlayer:
导入框架并定义播放器,
为主文件中的按钮创建 ibactions:
和
use a buttons control events touchdown, touchupinside and touchupoutside:
edit:
realized your question may have been more about playing sound files?!
there's different frameworks, you could use AVAudioPlayer:
import framework and define a player
create your ibactions for buttons in the main file:
and