Libspotify打的问题 [英] Libspotify playing problems

查看:167
本文介绍了Libspotify打的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写身边libspotfiy一个C#包装,并有与播放曲目的问题。从我所知道的,当我想启动一个会话流的第一次轨道,我应该叫

I'm writing a C# wrapper around libspotfiy, and have a problem with the track playing. From what I can tell, when I want to start streaming a track for the first time in a session, I should call

sp_session_player_load(sessionHandle, trackHandle)
sp_session_player_play(sessionHandle, true);

这是我在做什么,并能正常工作。当我要玩别的问题开始。与轨道还在打,我是什么意思做玩一个新的?我应该叫

This is what I'm doing, and it works fine. The problem start when I want to play something else. With a track still playing, what am I meant to do to play a new one? Should I call

sp_session_player_play(sessionHandle, false);
sp_session_player_unload(sessionHandle);

在然后调用了新一轮的加载/玩?我问,因为我这样做的时候,我经常看到我的程序挂起当我打电话卸载,或致电与假参数玩。我使用的是get_audio_buffer_stats回调。我有到位适当的线程syncronisation,因此,如果不正确地I'mu唱API我不知道?

Before then calling a new round of load/play? I ask because when I do this, I often see my program hang when I call the unload, or call play with an argument of false. I'm using the get_audio_buffer_stats callback. I've got appropriate thread syncronisation in place, so I'm wondering if I'mu sing the api incorrectly?

推荐答案

这正是官方的Mac和iOS库做什么,并能正常工作:

This is exactly what the official Mac and iOS library does, and it works fine:

当打的第一次:

sp_session_player_load(sessionHandle, trackHandle)
sp_session_player_play(sessionHandle, true);

当再次播放:

sp_session_player_play(sessionHandle, false);
sp_session_player_unload(sessionHandle);
sp_session_player_load(sessionHandle, trackHandle)
sp_session_player_play(sessionHandle, true);

有几件事情你可以检查,但:

There are a couple of things you can check, though:


  • 最常见的挂我所看到的是,由于该方案是如何实现 notify_main_thread 回调。当你得到这一点,你必须安排在非阻塞的方式在主线程中调用,以便 sp_session_process_events 。也就是说,你的 notify_main_thread 实施前应 sp_session_process_events 返回被称为另一个线程上。

  • The most common hang I've seen is due to how the program implements the notify_main_thread callback. When you get this, you must schedule a call so sp_session_process_events on the main thread in a non-blocking way. I.e., your notify_main_thread implementation should return before sp_session_process_events is called on the other thread.

试着拿出你的 get_audio_buffer_stats 的实施。这台Mac / iOS的库没有实现这个在所有 - 它不是必需的。

Try taking out your get_audio_buffer_stats implementation. This Mac/iOS library doesn't implement this at all - it isn't required.

如果这ISN ŧ不够,请尽量让挂起的堆栈跟踪。如果你发现它在调试器,击中暂停往往是不够好。

If this isn't enough, please try to get a stack trace of the hang. If you catch it in the debugger, hitting pause is often good enough.

这篇关于Libspotify打的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆