0
我的应用程序播放在线流。在视图控制器之间导航时播放声音
但是,当用户导航到下一个视图控制器时,音乐停止。下面是播放声音的代码:
- (void)start
{
@synchronized (self)
{
if (state == AS_PAUSED)
{
[self pause];
}
else if (state == AS_INITIALIZED)
{
NSAssert([[NSThread currentThread] isEqual:[NSThread mainThread]],
@"Playback can only be started from the main thread.");
notificationCenter =
[[NSNotificationCenter defaultCenter] retain];
self.state = AS_STARTING_FILE_THREAD;
internalThread =
[[NSThread alloc]
initWithTarget:self
selector:@selector(startInternal)
object:nil];
[internalThread setName:@"InternalThread"];
[internalThread start];
}
}
}
我已经试过:
dispatch_async(dispatch_get_main_queue(),
^{
[internalThread start];
});
但它不工作。有人对此有经验吗?