question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How audio playback works and some limitations

See original GitHub issue

First let me thank you for the project. Having fun reading the excellent code.

Took me a while do understand how Spotify playback was made possible:

this.audio = new Audio(song.track.preview_url);

A new Audio instance (Web Audio API) receives a preview_url (which only has 30s of the song):

The app does not use the new Web Playback SDK which would enable a full playback experience.

I also couldn’t find a refresh_token workflow in the code. Without background refreshing of the token the page would have to be reloaded from time to time (interrupting the experience).

If a developer is considering using this project to start another (like I am) I believe more details on the README.md would facilitate a more informed decision.

I’m I understanding correctly how the audio playback works?

Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Pau1fitzcommented, Dec 11, 2017

You are correct. It uses the Web Audio API. This is all handled in the App.js file in this method.

The Spotify API offers 3 authorization flows. In the past I have used the Authorization Code flow but for this project I opted for the Implicit Grant flow . There is a detailed explanation on each of the authorization workflows here. Spotify also provides examples of each one on their github account.

In this application, if the initial request was unauthorized the application will request another token from the API. See code here, line 25 in particular. You only have to give the application access to your Spotify account the first time you use it. At that point a cookie is stored on your machine. If you delete this cookie then you will need to authorize the application again, which would interrupt the experience.

I didn’t use the new Web Playback SDK. I had not actually seen this before. Looks like it would definitely be worth implementing. Firstly, I need to get a premium account 😟

0reactions
nukeopcommented, Jan 16, 2018

I’m not sure if there’s a way to make it work with Electron, which is the use case I’m interested in.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Digital audio - Wikipedia
Digital audio is a representation of sound recorded in, or converted into, digital form. ... For playback, a digital-to-analog converter (DAC) performs the...
Read more >
Fix sound or audio problems in Windows - Microsoft Support
On the Playback tab, select and hold (or right-click) the Default Device, and then select Properties. Select the Advanced tab and uncheck either...
Read more >
Troubleshoot audio and video issues on your computer or ...
macOS: From the Apple menu, select System Preferences > Sound > Input. Select the microphone you wish to use.
Read more >
Audio in the Browser: Horrors and Joys - Learning - Source
But HTML5 audio has many limitations. HTML5 audio is like a stereo—you can put audio in it, and you can stop, skip around,...
Read more >
Fixing Audio Playback Issues with Davinci Resolve - YouTube
In this video we look at the two most common audio play issues in Davinci Resolve, no audio playback at all, and out...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found