关于 javascript:Spotify App Preview API 访问 model.player 属性 | 珊瑚贝

Spotify App Preview API Access model.player properties


我一直在使用最新的 spotify 预览 api,但在访问播放器属性时遇到问题。
我正在尝试播放当前曲目。这是我下面的测试片段。

1
2
3
4
5
6
7
8
require([
   ‘$api/models’,
   ‘$api/search#Search’,
   ‘$views/image#Image’
], function(models,s, Image) {
      ‘use strict’;
       console.log(models.player.track)
});

但是我在 console.log 中没有定义
它看到我只能访问这些方法。请查看链接以供参考
http://developer.spotify.com/technologies/apps/docs/preview/api/api-models-player.html


找到了

所以在你可以访问播放器属性之前你必须调用加载方法

1
2
3
4
5
6
7
8
9
10
11
12
require([
   ‘$api/models’,
   ‘$api/search#Search’,
   ‘$views/image#Image’
], function(models,s, Image) {
     ‘use strict’;

     models.player.load(‘track’).done(function(prop) {
           console.log(prop.track.name);
      });

});


来源:https://www.codenong.com/16071836/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_8804.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?