AudioStreamer appDelegate
我有两件事与 AudioStreamer
有关,我希望我能在这里得到一些线索:
1. 我已经设置了一个 UITabBarController
并在我的 < code>Appdelegate 是一个 AudioStreamer
对象。两个视图引用了appDelegate.streamer
。看起来,当我发布并分配新的它时,我得到了两个会话。我得到两个正在运行的音频会话。
2. 我使用 UITableView
来播放此列表。在 didSelectRowAtIndexPath
方法中,我使用 URL 进行初始化。当用户快速双击或三次点击时。音频会话将启动 3 次。尽管我使用 bool
来防止这种情况发生。所以我的肮脏解决方案是将系统设置为休眠一秒钟。这很丑,因为屏幕冻结了一秒钟。
感谢
西蒙的一些提示
I have two things concerning AudioStreamer
and i hope I'm getting some clues here:
1. I have set up a UITabBarController
and in my Appdelegate
is a AudioStreamer
-Object. Two views refer to the appDelegate.streamer
. It it looks like that im getting two sessions when i release and alloc it new. I get two running audiosession.
2. I use a UITableView
to play out of this list. in the didSelectRowAtIndexPath
-method I initialize with a URL. when the user taps with a fast double, or tripple-click. the audiosession will get startet three times. although i'm using a bool
to prevent that. so my dirty solution is to set the system sleeping for a second. it is ugly because the screen freezes for a sec.
Thankfull for some hints
Simon
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就您的问题而言,听起来您应该将 AudioSteamer 实现为单例,因为这将防止创建多个实例并提供单点来控制播放(即:防止多次点击触发多个播放)。
有关如何创建单例类的更多信息,请参阅 Apple Cocoa 基础指南。
In terms of your problems, it sounds like you should implement your AudioSteamer as a singleton, as this will prevent multiple instances from being created and provide a single point to control playback (i.e.: prevent multiple taps from triggering multiple playbacks).
For more information on how to create a singleton class, see the "Creating a Singleton Instance" section within Apple's Cocoa Fundamentals Guide.
对于第二点。这是AudioStreamer类的一个bug。此外,这个问题已经解决,代码已发布在 gitHub 查看链接。另外,如果这似乎不起作用,那么您可以转到暂停方法并添加更多状态,如下所示,
这解决了我同样的问题。希望这也能帮助您...
for 2nd point. It is a bug of AudioStreamer class. Also this has been solved and code is put up on gitHub see link. also if this does not seems working then you can go to the pause method and add more states as below
this solved my same problem. Hope this will help you also...