#ifndef PLAYER_H #define PLAYER_H #include #include #include #include #include #include #include "Utils.h" #include "MercuryManager.h" #include "TrackReference.h" #include "Session.h" #include "SpotifyTrack.h" #include "AudioSink.h" #include #include "BellTask.h" class Player : public bell::Task { private: std::shared_ptr manager; SpotifyTrack *currentTrack = nullptr; SpotifyTrack *nextTrack = nullptr; std::shared_ptr audioSink; std::mutex loadTrackMutex; WrappedMutex nextTrackMutex; WrappedMutex currentTrackMutex; void runTask(); public: Player(std::shared_ptr manager, std::shared_ptr audioSink); std::function endOfFileCallback; int volume = 255; uint32_t logVolume; bool needFlush = false; std::atomic isRunning = false; trackChangedCallback trackChanged; std::mutex runningMutex; void setVolume(uint32_t volume); void handleLoad(std::shared_ptr track, std::function &trackLoadedCallback, uint32_t position_ms, bool isPaused); void pause(); void cancelCurrentTrack(); void seekMs(size_t positionMs); void feedPCM(uint8_t *data, size_t len); void play(); void stop(); }; #endif