我怎样才能知道,如果一首歌曲已经结束或者下一个按钮被点击与Spotify的API? [英] How can I tell if a song has ended or the next button was clicked with the spotify API?

查看:427
本文介绍了我怎样才能知道,如果一首歌曲已经结束或者下一个按钮被点击与Spotify的API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Spotify的API来开发用于在OSX桌面应用程序的Spotify的应用程序。我一直在打我的头撞在墙上试图找出如何判断一首歌曲已经结束,并触发另一首曲目进行播放。

I'm using the spotify API to develop an app for the desktop spotify application on OSX. I've been beating my head against the wall trying to figure out how to tell if a song has ended and trigger another track to play.

下面是我的事件监听器code:

Here's my event listener code:

models.player.observe(models.EVENT.CHANGE, function(event) {
    console.debug(event);
    if(event.data.playstate == false){
        $('.wholikes').remove();
        getTrack();
    }               
});

我想我需要在看Event.data中,但是当我检查检查它具有相同的特性,无论是观察什么样的变化。类型设置为'playerStateChanged',这是不具体。我期待在一首歌结束时或下一个按钮为pressed触发一个新的轨道,而不是当用户改变洗涤器乐曲的不同部分。有任何想法吗??我已经彻底检查文档并不能找到这个任何地方。

I guess I need to be looking at event.data, but when i check the inspector it has the same properties no matter what change it is observing. The type is set to 'playerStateChanged' which is not specific. I'm looking to trigger a new track at the end of a song or when the next button is pressed, but not when a user changes the scrubber to a different part of the song. Any ideas?? I've check the documentation thoroughly and can't find this anywhere.

推荐答案

当你观察火灾的情况下,检查Player对象的跟踪属性( models.player.track )。当跟踪变化,你会发现这个改变到下一首曲目,如果有一个或。在这一点上,你就可以开始下一首曲目。

When the event you're observing fires, check the player object's track property (models.player.track). When the track changes, you should find this changed to the next track if there is one, or null. At this point, you can start the next track.

这篇关于我怎样才能知道,如果一首歌曲已经结束或者下一个按钮被点击与Spotify的API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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