您好我正在开发使用Deezer Android SDK的应用程序。我终于成功打了30秒。我的应用程序中的样本使用基本播放器而不是TrackPlayer。
首先,我尝试使用TrackPlayer并调用方法:
TrackPlayer.playTrack(trackid);
但是这个玩家只会产生异常:
InvalidStreamTokenException
过了一会儿,我找到了API调用:
new DefaultPlayerFactory(...).createPlayer();
player.init(trackid, stream_or_sample_uri);
player.play();
所以现在我尝试播放完整的标题,但即使我创建了一个临时的新高级帐户,流令牌只会产生奇怪的错误...... (状态从RELEASED更改为INITIALIZING不允许)即便是我如何检查当前用户的状态也不清楚......
我在页面上找到了一些网址:
http://api.deezer.com/options/ - >参数:streaming = true
http://api.deezer.com/user/me - >参数:status = 2(Premium +)/ 0(Free)
但是我还没有在android SDK中找到一个函数。也许它不见了?
任何支持都会很棒!
提前致谢
编辑:
请求代码:
public void login() {
// Check if a session was stored and request login if not
if(!m_SessionStore.restore(m_DeezerConnect, m_Activity.getApplication())) {
String[] permissions = new String[]{
Permissions.BASIC_ACCESS,
Permissions.MANAGE_LIBRARY,
Permissions.LISTENING_HISTORY,
Permissions.OFFLINE_ACCESS,
};
DeezerDialogListener ddl = new DeezerDialogListener();
m_DeezerConnect.authorize(m_Activity, permissions, ddl);
} else {
notifyLoginSuccess();
loadUserPlaylists();
}
}
private class DeezerDialogListener implements DialogListener {
@Override
public void onComplete(Bundle bundle) {
m_SessionStore.save(m_DeezerConnect, m_Activity.getApplication());
notifyLoginSuccess();
loadUserPlaylists();
}
@Override
public void onCancel() {
notifyLoginError();
}
@Override
public void onException(Exception e) {
notifyLoginError();
}
}
private void loadUserPlaylists() {
try {
// First try
//m_DeezerPlayer = new TrackPlayer(m_Activity.getApplication(), m_DeezerConnect, new WifiAndMobileNetworkStateChecker());
m_DeezerPlayer = new DefaultPlayerFactory(m_Activity.getApplication(), m_DeezerConnect, new WifiAndMobileNetworkStateChecker()).createPlayer();
m_DeezerPlayer.addOnPlayerErrorListener(this);
m_DeezerPlayer.addOnPlayerProgressListener(this);
m_DeezerPlayer.addOnPlayerStateChangeListener(this);
} catch (Exception e) {
e.printStackTrace();
}
AlbumsListener al = new AlbumsListener();
DeezerRequest ar = DeezerRequestFactory.requestCurrentUserAlbums();
ar.setId("ar");
m_DeezerConnect.requestAsync(ar, al);
...
}
答案 0 :(得分:1)
InvalidTokenException 是我们在模拟器中使用Android SDK时遇到的问题。 它已在SDK版本v0.10.19中修复,并且在上面可用:Android SDK