finhsing CSpot integration

This commit is contained in:
Philippe G
2021-12-24 21:56:42 -08:00
parent e2bcb041e9
commit 7f894f1635
11 changed files with 102 additions and 89 deletions

View File

@@ -182,6 +182,7 @@ void SpircController::handleFrame(std::vector<uint8_t> &data) {
}
void SpircController::loadTrack(uint32_t position_ms, bool isPaused) {
sendEvent(CSpotEventType::LOAD, (int) position_ms);
state->setPlaybackState(PlaybackState::Loading);
std::function<void()> loadedLambda = [=]() {
// Loading finished, notify that playback started
@@ -216,6 +217,7 @@ void SpircController::setEventHandler(cspotEventHandler callback) {
info.artist = track.artist;
info.imageUrl = track.imageUrl;
info.name = track.name;
info.duration = track.duration;
this->sendEvent(CSpotEventType::TRACK_INFO, info);
});

View File

@@ -99,12 +99,13 @@ void SpotifyTrack::trackInformationCallback(std::unique_ptr<MercuryResponse> res
if (trackInfoReceived != nullptr)
{
CSPOT_LOG(info, "Calling %d", trackInfo.album.value().cover_group.value().image.size());
TrackInfo simpleTrackInfo = {
.name = trackInfo.name.value(),
.album = trackInfo.album.value().name.value(),
.artist = trackInfo.artist[0].name.value(),
.imageUrl = "https://i.scdn.co/image/" + bytesToHexString(trackInfo.album.value().cover_group.value().image[0].file_id.value())
.imageUrl = "https://i.scdn.co/image/" + bytesToHexString(trackInfo.album.value().cover_group.value().image[0].file_id.value()),
.duration = trackInfo.duration.value(),
};
trackInfoReceived(simpleTrackInfo);