Spotify - 从 URI 空数据获取曲目

发布于 2025-01-05 10:09:55 字数 387 浏览 2 评论 0原文

我正在开发一个 Spotify 应用程序,并且在通过 models.Track.fromURI('uri'); 检索的曲目中获取空数据如果我尝试访问曲目上的任何标准数据(例如track.album) 我得到了对该变量的空引用。我似乎唯一能够访问的是track.uri。奇怪的是,将曲目输出到控制台显示所有数据都存在。

这种情况只发生在两次,第一次调用 models.Track.fromURI 当应用程序加载时(重新加载应用程序可以解决问题)。当对从搜索检索到的轨道执行相同操作时(这是已弃用的 sp.core.search,因此这可能是这里的问题)。

这似乎是一个奇怪的错误,但我不能确定。

感谢您的帮助!

I'm developing a Spotify app and am getting null data in tracks I'm retrieving through models.Track.fromURI('uri'); If I try to access any standard data on the track (eg track.album) I get a null reference to the variable. The only thing I seem to be able to access is track.uri. Oddly, outputting the track to the console shows all data is present.

This only happens on two occasions, my first calls of models.Track.fromURI when the app loads (reloading the app fixes the problem). And when doing the same on tracks retrieved from a search (this is the deprecated sp.core.search, so that may be the issue here).

It would appear to be an odd bug, but I can't be sure.

Thanks for the help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

辞慾 2025-01-12 10:09:55

确保在访问元数据之前等待曲目加载。

models.Track.fromURI('uri', function (track) {
    // Track has loaded!
});

Make sure you're waiting until the track has loaded before accessing metadata.

models.Track.fromURI('uri', function (track) {
    // Track has loaded!
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文