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];
});
但它不工作。有人對此有經驗嗎?