Deezer只返回预览 - 没有流。使用Android SDK

时间:2014-04-08 02:37:30

标签: deezer

我尝试使用Deezer Android API播放音乐,遵循SDK的示例代码。我只获得了30s的预览,而不是流。以下是返回输出的片段:

{"id":"72306644","readable":true,"title":"Aura","link":"http:\/\/www.deezer.com\/track\/72306644","duration":236,"track_position":1,"disk_number":1,"rank":426293,"preview":"http:\/\/cdn-preview-e.deezer.com\/stream\/e0c84057c93e3cad84317d768413c0e3-0.mp3","stream":false,"artist"
{"id":"75491","name":"Lady GaGa","type":"artist"},"type":"track"}

身份验证成功。我使用高级+帐户登录。我做错了什么或错过了一步吗?

现在似乎正在返回流 - 也许只需要时间将帐户升级到premium +。然而,它并没有播放流。没有播放音乐。

它非常接近SDK中的示例代码并基于在线文档: 首先创建播放器:

deezerConnect = new DeezerConnectImpl( parentActivity, APP_ID );
try {
   player = new DefaultPlayerFactory( parentActivity.getApplication(), 
   deezerConnect, new WifiOnlyNetworkStateChecker() ).createPlayer();
} catch (Exception e) {
   handleError( e );
}

然后拨打电话获取曲目......

private void searchTracks(Album album) {
   long albumId = album.getId();
   Bundle bundle = new Bundle();
   bundle.putString( "nb_items", "30");
   DeezerRequest request = new DeezerRequest( "album/"+albumId+"/tracks", bundle );
   request.setId( String.valueOf( albumId ) );
   deezerConnect.requestAsync( request, trackHandler );
}

然后在trackHandler中解析结果并使用gson创建一个跟踪对象后,它会尝试播放该轨道:

private void playTrack( Track track ) {
   if( player.getPlayerState() != PlayerState.STARTED ) {
      player.stop();
   }//if
   Log.d(TAGNAME, "Init track:" + track.getId() +":"+ deezerConnect.getAccessToken() +":"+   
   track.getStream() );

   if( track.hasStream() ) {
      player.init( track.getId(), track.getStream());
   } else {
      Log.d( TAGNAME,"Playing track preview:" + track.getId() );
      player.init( track.getId(), track.getPreview() );
   }//else

   player.setPlayerProgressInterval(1000);
   player.play();
}

如果有帮助,以下是响应输出的一些片段:

响应:{"数据":[{" ID":" 17519569""可读":真,"标题":" Dirty Paws"," link":" http://www.deezer.com/track/17519569"," duration& #34; 278" track_position":1," disk_number":1,"秩":399040,"预览":&# 34; HTTP://cdn-preview-d.deezer.com/stream/def7161be8ee42ecb20036a136ad0cf6-2.mp3","流":" ....这里有一长串十六进制数字......","艺术家":{" id":" 1581786","名称":"怪物和男人","键入":"艺术家"},"键入":"跟踪& #34;}

0 个答案:

没有答案