- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我们在使用 cocoalibspotify 播放时出现崩溃:问题看起来像在 SPSession.m 下的回调函数 music_delivery() 中,实例启动的回调不是 SPSessionAudioDeliveryDelegate 兼容实例。但是,我们使用的唯一与播放相关的实例是 SPPlaybackManager。我们用来使用 spotify 播放歌曲的函数是:
#pragma mark - Domain function
- (void)searchForKeywords:(NSString *)keywords{
//construct search string
SPSearch *search = [[SPSearch alloc] initWithSearchQuery:keywords inSession:[SPSession sharedSession]];
//search track
[SPAsyncLoading waitUntilLoaded:search timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *results, NSArray *notLoadedResults) {
if ([results count]>0) {
//search returns results.
SPSearch *thisSearch = [results objectAtIndex:0];
if ([[thisSearch tracks] count]>0) {
// Add loading flag for album art
[[ImageManager sharedInstance] setLoadingFlagForSong:self.namedSong];
SPTrack *track = [[thisSearch tracks]objectAtIndex:0];
[SPAsyncLoading waitUntilLoaded:track timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *tracks, NSArray *notLoadedTracks) {
self.currentTrack = track;
}];
}else{
}
}else{
//search didn't return results.
}
}];
}
- (void)play
{
[SPSession dispatchToLibSpotifyThread:^{
[[SPSession sharedSession]setPlaybackDelegate:self];
// Change the current track of the session
if (currentTrack) {
self.playbackManager = [[SPPlaybackManager alloc] initWithPlaybackSession:[SPSession sharedSession]];
[[SPSession sharedSession]setPlaybackDelegate:self];
[self.playbackManager playTrack:currentTrack callback:^(NSError *error) {
// Failure playing
if (error) {
}
// Success
}];
}
// Play
else {
}
}];
}
- (void)pause
{
[SPSession dispatchToLibSpotifyThread:^{
[SpotifyHelper sharedInstance].playbackManager.isPlaying = NO;
} waitUntilDone:YES];
}
- (void)stop
{
[SPSession dispatchToLibSpotifyThread:^{
[SpotifyHelper sharedInstance].playbackManager.isPlaying = NO;
[[SpotifyHelper sharedInstance].playbackManager sessionDidEndPlayback:[SPSession sharedSession]];
} waitUntilDone:YES];
}
-(void)seekToLocation:(float)location
{
[SPSession dispatchToLibSpotifyThread:^{
[[SpotifyHelper sharedInstance].playbackManager seekToTrackPosition:location * self.currentTrack.duration];
} waitUntilDone:YES];
}
错误信息:-[__NSCFType session:shouldDeliverAudioFrames:ofCount:streamDescription:]: 无法识别的选择器发送到实例 0x21328a90
Stack:
0 libsystem_kernel.dylib __pthread_kill + 8
1 libsystem_c.dylib pthread_kill + 58
2 libsystem_c.dylib abort + 94
3 libc++abi.dylib abort_message + 74
4 libc++abi.dylib default_terminate() + 24
5 libobjc.A.dylib _objc_terminate() + 146
6 libc++abi.dylib safe_handler_caller(void (*)()) + 78
7 libc++abi.dylib std::terminate() + 19
8 libc++abi.dylib __cxa_throw + 122
9 libobjc.A.dylib objc_exception_throw + 94
10 CoreFoundation __methodDescriptionForSelector
11 CoreFoundation ___forwarding___ + 392
12 CoreFoundation _CF_forwarding_prep_0 + 24
crash->13 OURAPP music_delivery
14 OURAPP sp_playlist_get_offline_download_completed
15 OURAPP sp_error_message
16 OURAPP sp_error_message
最佳答案
两件事:
1) 在调用 CocoaLibSpotify 方法时不要分派(dispatch)给 CocoaLibSpotify 线程——这是在内部完成的。删除 dispatchToLibSpotifyThread
行。
2) 删除 [[SPSession sharedSession]setPlaybackDelegate:self];
行。这就是导致你崩溃的原因。
关于ios - cocoalibspotify : Crash during playback callback under music_delivery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17712864/
在我的上一个项目中,我使用了 rxJava,我意识到 observable.doOnError('onErrorCallback').subscribe(action) 和 observable.su
我是一名 C++ 初学者,我认为要真正学习指针和引用,我应该尝试创建一个回调函数,这是我在 JavaScript 中认为理所当然的事情。 但是,对于我的一生,我不知道为什么这些括号在 (*callba
我在库中有一个类,它具有在事件发生时执行的“onMessage”方法。 OnMessage 在执行时需要调用属于主应用程序中的类的“回调”方法。我假设这将通过构造函数完成,但我不知道它是如何实现的。
两者的 jQuery 文档基本上说明了相同的事情,所以我想知道两者之间是否有任何重大差异(如果有的话)。谢谢! 最佳答案 这方面的文档实际上非常糟糕,所以这是我在 studying the sourc
这个问题在这里已经有了答案: Using &&'s short-circuiting as an if statement? (6 个答案) Omitting the second expressi
我正在尝试在 golang 中定义一个回调: package main func main() { x, y := "old x ", "old y" callback
我有一个页面,其中包含从 Google 电子表格生成的许多图表。 典型代码如下所示: var url = "http://my.googlespreadsheet.com/tq?argumentshe
当我运行 linter 时,它显示: subscribe is deprecated: Use an observer instead of an error callback 代码来自 this a
对于异步套接字 // accept ... listener.BeginAccept( new AsyncCallback(AcceptCallback), listener); // listene
我希望能够根据在前面的函数中调用的是 callback(true) 还是 callback(false) 在回调函数中执行一些逻辑。 示例: foo.doFunction = function (pa
从 jQuery.scrollTo.js 库中看到这个 block (在 v1.4 的第 184 行)。 function animate( callback ){ $elem.animate
我正在尝试在我的应用中使用一些回调,它与 "callback(value)" 和 "callback.invoke(value)" 一起工作正确调用回调。 我想知道“回调(值)”是否只是一个缩短版本,
我决定从 keras 切换到 tf.keras(建议使用 here)。因此我安装了 tf.__version__=2.0.0和 tf.keras.__version__=2.2.4-tf .在我的旧版
我认为这实际上可能会回答我关于 Stack Overflow 的另一个问题如果我能确认这一点。 返回回调和只调用回调有什么区别? 我看到代码执行其中之一/或/两者,并试图思考为什么以及何时执行哪个。
我目前正在学习 Rust 并希望用它来开发 GUI基于 GTK+ 的应用程序。我的问题与注册回调有关在这些回调中响应 GTK 事件/信号和变异状态。我有一个有效但不优雅的解决方案,所以我想问一下是否有
我在回调函数中传递参数时遇到问题。我使用 redux-form,当我更改 SkinList 中的选择时,它会触发 onChange 回调 - activeSkinChange 方法 在activeSk
我有 8 个相互依赖的回调。我的想法是要有一个更具可读性的过程,但我不明白如何处理这个问题。 我的回调 hell 的一个例子是: return new Promise(function (resolv
因此,我的函数接受一个值和任意数量的回调作为参数(我应该使用扩散操作符吗?)该函数应该返回通过所有给定回调传递该值的最终结果。。我返回的“CB2(Res1)”不是一个函数。如何将第一个回调的结果传递给
在谈到 future 和回调时,documentation说是 The Vert.x core APIs are based on callbacks to notify of asynchronou
我开始觉得自己很蠢。我正在关注 Facebook-Connect 演示“The Run Around”。 当我导航到 http://www.[mysite].com/testing/register_
我是一名优秀的程序员,十分优秀!