Files
bar/include/components/mediaPlayer.hpp

61 lines
1.7 KiB
C++

#pragma once
#include "components/button/iconButton.hpp"
#include "connection/dbus/mpris.hpp"
#include "gtkmm/box.h"
#include "gtkmm/label.h"
#include "gtkmm/overlay.h"
#include "gtkmm/picture.h"
#include "gtkmm/scale.h"
#include "gtkmm/scrolledwindow.h"
class MediaPlayer : public Gtk::Box {
public:
explicit MediaPlayer(std::shared_ptr<MprisController> controller);
private:
std::shared_ptr<MprisController> mprisController;
int64_t currentPositionUs = 0;
int64_t totalLengthUs = 0;
sigc::connection seekTimerConnection;
bool suppressSeekSignal = false;
std::string currentTrackId;
MprisController::PlaybackStatus playbackStatus = MprisController::PlaybackStatus::Stopped;
bool canSeek = true;
void setCurrentPosition(int64_t position_us);
void setTotalLength(int64_t length_us);
void resetSeekTimer(int64_t start_position_us);
bool onSeekTick();
void schedulePauseAfterSeek();
void setCanSeek(bool can_seek);
// image as background, artist, title
Gtk::Overlay topContainer;
Gtk::Picture backgroundImage;
Gtk::Box infoContainer;
Gtk::Label artistLabel;
Gtk::Label titleLabel;
//
Gtk::Box seekBarContainer;
Gtk::Label currentTimeLabel;
Gtk::Scale seekBar;
Gtk::Label totalTimeLabel;
// playback controls
Gtk::Box bottomContainer;
std::unique_ptr<IconButton> previousButton;
std::unique_ptr<IconButton> playPauseButton;
std::unique_ptr<IconButton> nextButton;
Gtk::ScrolledWindow imageWrapper;
void onSpotifyMprisUpdated(const MprisPlayer2Message &message);
void onRunningStateChanged(MprisController::PlaybackStatus status);
void onPlay();
void onPause();
void onStop();
};