Browse Source

Updated JSON PlaybackAPI documentation

reviewable/pr190/r8
Samuel Attard 6 years ago
parent
commit
b9a1ff84ea
  1. 35
      docs/PlaybackAPI.md
  2. 1
      src/main/features/core/lyrics.js

35
docs/PlaybackAPI.md

@ -13,29 +13,41 @@ current playback information. The file is JSON-formatted and located at
The file contains a single JSON object with the following attributes:
- **playing**: (bool) Whether or not the player is current playing. This is false when the player is closed.
- **song**: (object) A song object in the format below.
- **time**: (object) A time object in the format below.
- **songLyrics**: (string) The full lyrics of the current song, or null if we could not find the lyrics
##### Song Object
All attributes are null if no song is playing. If a song is paused the variables are set correctly.
All attributes are `null` if no song is playing. If a song is paused the variables are set correctly.
- **title**: (string) Title of the song
- **artist**: (string) Artist of the song
- **album**: (string) Album of the song
- **albumArt**: (string) URL that points the Album Art
#### Time Object
All attributes are `0` of no song is playing. If a song is paused the variables are set correctly.
- **current**: (number) Number of milliseconds into the song we are
- **total**: (number) Total length of the song in milliseconds
### Example
```js
// playing
// Playing
{
"playing": true,
"song": {
"title": "Shut Up and Dance",
"artist": "WALK THE MOON",
"album": "Talking Is Hard",
"albumArt": "https://lh5.ggpht.com/ePx57Lao09SN2MGsN11s1axY9cLFj3B35D-y4HvKjkl2Qi4y6vq9bHkv3tZwXVXZmj60kkUFbA=s90-c-e100"
}
"title": "Trumpets",
"artist": "Jason Derulo",
"album": "Tattoos",
"albumArt": "https://lh6.ggpht.com/J9gNObbLJ_R71OHy-F6ENINYlnjf6Hjx_dw4RV0GLSTH1zrDEFSeRcW_Kf2fTws0swmOXwot=s90-c-e100"
},
"time": {
"current": 4908,
"total": 217000
},
"songLyrics": "Lyrics here :)"
}
// Not Playing
// Not Playing (Stopped)
{
"playing": false,
"song": {
@ -43,6 +55,11 @@ All attributes are null if no song is playing. If a song is paused the variable
"artist": null,
"album": null,
"albumArt": null
}
},
"time": {
"current": 0,
"total": 0
},
"songLyrics": null
}
```

1
src/main/features/core/lyrics.js

@ -10,6 +10,7 @@ PlaybackAPI.on('change:song', (song) => {
let lyrics = (/('|")lyricbox('|")>.+<\/script>(.+)<!--/g.exec(html)[3]);
lyrics = lyrics.replace(/<br \/>/gi, '\n');
lyrics = decoder.decode(lyrics);
PlaybackAPI.setPlaybackSongLyrics(lyrics);
})
.catch(() => {
console.log('Lyrics parsing failed'); // eslint-disable-line

Loading…
Cancel
Save