Prevent song playing on URI link click

2019-08-19 06:19发布

I'm working on a Spotify app where I'd like for users to be able to click on track names and be linked to the track page, just like in other Spotify apps. I'd like to prevent the song from beginning playback, though.

SoundDrop seems to do this. You can click on a track name and the song doesn't interrupt playback by SoundDrop.

I'm not sure how to implement this alternative behavior. Any ideas?

标签: spotify
1条回答
爷、活的狠高调
2楼-- · 2019-08-19 07:21

The Apps API uses standard JavaScript stuff, so if you attach a handler to the track link and use e.preventDefault(), that should prevent Spotify playing the track and you can then do your own custom handling.

More discussion on e.preventDefault() is here: event.preventDefault() vs. return false

查看更多
登录 后发表回答