MythTV  master
musiccommon.h
Go to the documentation of this file.
1 #ifndef MUSICCOMMON_H_
2 #define MUSICCOMMON_H_
3 
4 // qt
5 #include <QKeyEvent>
6 #include <QObject>
7 
8 // mythtv
13 
14 // mythmusic
15 #include "musicplayer.h"
16 #include "playlist.h"
17 
18 class Output;
19 class Decoder;
20 class QTimer;
21 class MythUIProgressBar;
22 class MythUIImage;
23 class MythUIText;
24 class MythUIStateType;
25 class MythUIButton;
26 class MythUIVideo;
27 class MythUIButton;
28 class MythUICheckBox;
29 class MythMenu;
30 
31 enum MusicView : std::uint8_t
32 {
45 };
46 
48 
50 {
51  Q_OBJECT
52 
53  protected:
54 
55  MusicCommon(MythScreenStack *parent, MythScreenType *parentScreen,
56  const QString &name);
57  ~MusicCommon(void) override;
58 
59  bool CreateCommon(void);
60 
61  void switchView(MusicView view);
62 
63  void customEvent(QEvent *event) override; // MythUIType
64  bool keyPressEvent(QKeyEvent *e) override; // MythScreenType
65 
66  void ShowMenu(void) override; // MythScreenType
67 
68  protected slots:
69  void viewExited(void);
70 
71  static void play(void);
72  void stop(void);
73  static void pause(void);
74  void previous(void);
75  void next(void);
76  void seekforward(void);
77  void seekback(void);
78  void seek(std::chrono::seconds pos);
79  void stopAll(void);
80  static void changeRating(bool increase);
81 
82  void searchButtonList(void);
83  MythMenu* createMainMenu(void);
84  MythMenu* createSubMenu(void);
85  MythMenu* createPlaylistMenu(void);
86  MythMenu* createPlayerMenu(void);
87  MythMenu* createQuickPlaylistsMenu(void);
88  MythMenu* createRepeatMenu(void);
89  MythMenu* createShuffleMenu(void);
90  MythMenu* createVisualizerMenu(void);
91  MythMenu* createPlaylistOptionsMenu(void);
92 
93  void playlistItemClicked(MythUIButtonListItem *item);
94  static void playlistItemVisible(MythUIButtonListItem *item);
95 
96  void fromCD(void);
97  void allTracks(void);
98  void byArtist(void);
99  void byAlbum(void);
100  void byGenre(void);
101  void byYear(void);
102  void byTitle(void);
103  void doUpdatePlaylist(void);
104 
105  protected:
106  void showExitMenu(void);
107  void showPlaylistOptionsMenu(bool addMainMenu = false);
108 
109  protected:
110  void init(bool startPlayback = true);
111  static QString getTimeString(std::chrono::seconds exTime, std::chrono::seconds maxTime);
112  void updateProgressBar(void);
113  static void setTrackOnLCD(MusicMetadata *mdata);
114  static void editTrackInfo(MusicMetadata *mdata);
115  void updateTrackInfo(MusicMetadata *mdata);
116  static void showTrackInfo(MusicMetadata *mdata);
117  void updateUIPlaylist(void);
118  void updatePlaylistStats(void);
119  void updateUIPlayedList(void); // for streaming
120  void updateRepeatMode(void);
121  void updateShuffleMode(bool updateUIList = false);
122 
123  void changeVolume(bool up) const;
124  void changeSpeed(bool up);
125  void toggleMute(void) const;
126  static void toggleUpmix(void);
127  static void showVolume(void);
128  void updateVolume(void);
129  static void showSpeed(bool show);
130 
131  void startVisualizer(void);
132  void stopVisualizer(void);
133  void cycleVisualizer(void);
134  void switchVisualizer(const QString &visual);
135  void switchVisualizer(int visual);
136 
137  static void playFirstTrack();
138  bool restorePosition(int trackID);
139 
140  MythScreenType *m_parentScreen {nullptr};
141  MusicView m_currentView {};
142 
143  // visualiser stuff
144  MainVisual *m_mainvisual {nullptr};
145  bool m_fullscreenBlank {false};
146  bool m_cycleVisualizer {false};
147  bool m_randomVisualizer {false};
148 
149  QStringList m_visualModes;
150  unsigned int m_currentVisual {0};
151 
152  bool m_moveTrackMode {false};
153  bool m_movingTrack {false};
154 
155  bool m_controlVolume {true};
156 
157  int m_currentTrack {0};
158  std::chrono::seconds m_currentTime {0s};
159  std::chrono::seconds m_maxTime {0s};
160 
161  uint m_playlistTrackCount {0};
162  std::chrono::seconds m_playlistPlayedTime {0s};
163  std::chrono::seconds m_playlistMaxTime {0s};
164 
165  // for quick playlists
166  PlaylistOptions m_playlistOptions {PL_REPLACE, PL_CURRENT};
167  QString m_whereClause;
168 
169  // for adding tracks from playlist editor
170  QList<int> m_songList;
171 
172  // UI widgets
173  MythUIText *m_timeText {nullptr};
174  MythUIText *m_infoText {nullptr};
175  MythUIText *m_visualText {nullptr};
176  MythUIText *m_noTracksText {nullptr};
177 
178  MythUIStateType *m_shuffleState {nullptr};
179  MythUIStateType *m_repeatState {nullptr};
180 
181  MythUIStateType *m_movingTracksState {nullptr};
182 
183  MythUIStateType *m_ratingState {nullptr};
184 
185  MythUIProgressBar *m_trackProgress {nullptr};
186  MythUIText *m_trackProgressText {nullptr};
187  MythUIText *m_trackSpeedText {nullptr};
188  MythUIStateType *m_trackState {nullptr};
189 
190  MythUIStateType *m_muteState {nullptr};
191  MythUIText *m_volumeText {nullptr};
192 
193  MythUIProgressBar *m_playlistProgress {nullptr};
194 
195  MythUIButton *m_prevButton {nullptr};
196  MythUIButton *m_rewButton {nullptr};
197  MythUIButton *m_pauseButton {nullptr};
198  MythUIButton *m_playButton {nullptr};
199  MythUIButton *m_stopButton {nullptr};
200  MythUIButton *m_ffButton {nullptr};
201  MythUIButton *m_nextButton {nullptr};
202 
203  MythUIImage *m_coverartImage {nullptr};
204 
205  MythUIButtonList *m_currentPlaylist {nullptr};
206  MythUIButtonList *m_playedTracksList {nullptr};
207 
208  MythUIVideo *m_visualizerVideo {nullptr};
209 };
210 
212 {
213  Q_OBJECT
214  public:
215  MythMusicVolumeDialog(MythScreenStack *parent, const char *name)
216  : MythScreenType(parent, name, false) {}
217  ~MythMusicVolumeDialog(void) override;
218 
219  bool Create(void) override; // MythScreenType
220  bool keyPressEvent(QKeyEvent *event) override; // MythScreenType
221 
222  protected:
223  void increaseVolume(void);
224  void decreaseVolume(void);
225  void toggleMute(void);
226 
227  void updateDisplay(void);
228 
229  QTimer *m_displayTimer {nullptr};
230  MythUIText *m_messageText {nullptr};
231  MythUIText *m_volText {nullptr};
232  MythUIStateType *m_muteState {nullptr};
233  MythUIProgressBar *m_volProgress {nullptr};
234 };
235 
237 {
238  Q_OBJECT
239  public:
240  TrackInfoDialog(MythScreenStack *parent, MusicMetadata *mdata, const char *name)
241  : MythScreenType(parent, name, false),
242  m_metadata(mdata) {}
243  ~TrackInfoDialog(void) override = default;
244 
245  bool Create(void) override; // MythScreenType
246  bool keyPressEvent(QKeyEvent *event) override; // MythScreenType
247 
248  protected:
249  MusicMetadata *m_metadata {nullptr};
250 };
251 
252 #endif
MythMusicVolumeDialog
Definition: musiccommon.h:211
MythUIImage
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:97
MV_PLAYLIST
@ MV_PLAYLIST
Definition: musiccommon.h:33
MusicCommon::m_whereClause
QString m_whereClause
Definition: musiccommon.h:167
false
VERBOSE_PREAMBLE false
Definition: verbosedefs.h:89
MV_PLAYLISTEDITORTREE
@ MV_PLAYLISTEDITORTREE
Definition: musiccommon.h:35
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(MusicView)
MusicCommon::m_songList
QList< int > m_songList
Definition: musiccommon.h:170
TrackInfoDialog
Definition: musiccommon.h:236
MythScreenStack
Definition: mythscreenstack.h:16
MythScreenType::Create
virtual bool Create(void)
Definition: mythscreentype.cpp:263
MythUIType::customEvent
void customEvent(QEvent *event) override
Definition: mythuitype.cpp:1003
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
show
static void show(uint8_t *buf, int length)
Definition: ringbuffer.cpp:341
MusicMetadata
Definition: musicmetadata.h:81
MV_TRACKINFO
@ MV_TRACKINFO
Definition: musiccommon.h:41
MV_PLAYLISTEDITORGALLERY
@ MV_PLAYLISTEDITORGALLERY
Definition: musiccommon.h:36
PL_CURRENT
@ PL_CURRENT
Definition: playlist.h:34
startPlayback
static void startPlayback(void)
Definition: mythfrontend.cpp:601
MusicCommon::m_visualModes
QStringList m_visualModes
Definition: musiccommon.h:149
MythUIButtonListItem
Definition: mythuibuttonlist.h:41
mythpluginexport.h
Decoder
Definition: decoder.h:70
MV_ALBUMINFO
@ MV_ALBUMINFO
Definition: musiccommon.h:40
MV_RADIO
@ MV_RADIO
Definition: musiccommon.h:42
MV_ARTISTINFO
@ MV_ARTISTINFO
Definition: musiccommon.h:39
MythUIProgressBar
Progress bar widget.
Definition: mythuiprogressbar.h:12
PlaylistOptions
Definition: playlist.h:37
MythUIButton
A single button widget.
Definition: mythuibutton.h:21
MythUICheckBox
A checkbox widget supporting three check states - on,off,half and two conditions - selected and unsel...
Definition: mythuicheckbox.h:15
MV_LYRICS
@ MV_LYRICS
Definition: musiccommon.h:34
MusicView
MusicView
Definition: musiccommon.h:31
MythMusicVolumeDialog::MythMusicVolumeDialog
MythMusicVolumeDialog(MythScreenStack *parent, const char *name)
Definition: musiccommon.h:215
MainVisual
Definition: mainvisual.h:34
MythMenu
Definition: mythdialogbox.h:99
MythUIText
All purpose text widget, displays a text string.
Definition: mythuitext.h:28
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:401
TrackInfoDialog::TrackInfoDialog
TrackInfoDialog(MythScreenStack *parent, MusicMetadata *mdata, const char *name)
Definition: musiccommon.h:240
MythUIVideo
Video widget, displays raw image data.
Definition: mythuivideo.h:14
audiooutput.h
MPLUGIN_PUBLIC
#define MPLUGIN_PUBLIC
Definition: mythpluginexport.h:9
MythScreenType::ShowMenu
virtual void ShowMenu(void)
Definition: mythscreentype.cpp:390
PL_REPLACE
@ PL_REPLACE
Definition: playlist.h:24
MV_SEARCH
@ MV_SEARCH
Definition: musiccommon.h:38
MV_VISUALIZER
@ MV_VISUALIZER
Definition: musiccommon.h:37
playlist.h
MythUIButtonList
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
Definition: mythuibuttonlist.h:191
MV_MINIPLAYER
@ MV_MINIPLAYER
Definition: musiccommon.h:43
musicmetadata.h
MythUIStateType
This widget is used for grouping other widgets for display when a particular named state is called....
Definition: mythuistatetype.h:22
mythscreentype.h
MusicCommon
Definition: musiccommon.h:49
uint
unsigned int uint
Definition: freesurround.h:24
MV_VISUALIZERINFO
@ MV_VISUALIZERINFO
Definition: musiccommon.h:44
musicplayer.h