Miam-Player  0.8.0
A nice music player
mediaplayer.h
Go to the documentation of this file.
1 #ifndef MEDIAPLAYER_H
2 #define MEDIAPLAYER_H
3 
4 #include <QMediaPlayer>
5 #include "mediaplaylist.h"
6 #include "miamcore_global.h"
7 
9 class IMediaPlayer;
10 
12 namespace QtAV {
13  class AVPlayer;
14 }
15 
22 class MIAMCORE_LIBRARY MediaPlayer : public QObject
23 {
24  Q_OBJECT
25 private:
26  MediaPlaylist *_playlist;
27  QMediaPlayer::State _state;
28 
29  QtAV::AVPlayer *_localPlayer;
30  IMediaPlayer *_remotePlayer;
31 
32  QMap<QString, IMediaPlayer*> _remotePlayers;
33  bool _stopAfterCurrent;
34 
35 public:
36  explicit MediaPlayer(QObject *parent = nullptr);
37 
38  void addRemotePlayer(IMediaPlayer *remotePlayer);
39 
40  QString currentTrack() const;
41 
43  qint64 duration();
44 
45  inline bool isStopAfterCurrent() const { return _stopAfterCurrent; }
46  inline void setStopAfterCurrent(bool b) { _stopAfterCurrent = b; }
47 
48  inline MediaPlaylist * playlist() { return _playlist; }
49 
50  void seek(qreal pos);
51 
53  void setMute(bool b) const;
54 
55  inline void setPlaylist(MediaPlaylist *playlist) { _playlist = playlist; }
56 
57  void setState(QMediaPlayer::State state);
58 
59  void setVolume(qreal v);
60 
61  inline QMediaPlayer::State state() const { return _state; }
62 
64  void playMediaContent(const QMediaContent &mc);
65 
66  qreal volume() const;
67 
68  QtAV::AVPlayer *localPlayer() const;
69 
70 private:
72  float position() const;
73 
74 public slots:
76  void pause();
77 
79  void play();
80 
82  void seekBackward();
83 
85  void seekForward();
86 
88  void skipBackward();
89 
91  void skipForward();
92 
94  void stop();
95 
96  inline void stopAfterCurrent(bool b) { _stopAfterCurrent = b; }
97 
99  void toggleMute() const;
100 
102  void togglePlayback();
103 
104 private:
105  void resume();
106 
107 signals:
108  void currentMediaChanged(const QString &uri);
109  void mediaStatusChanged(QMediaPlayer::MediaStatus);
110  void positionChanged(qint64 pos, qint64 duration);
111  void stateChanged(QMediaPlayer::State);
112  void volumeChanged(qreal v);
113 };
114 
115 #endif // MEDIAPLAYER_H
void setStopAfterCurrent(bool b)
Definition: mediaplayer.h:46
void stopAfterCurrent(bool b)
Definition: mediaplayer.h:96
IMediaPlayer class is a pure virtual class implemented by plugins.
Definition: imediaplayer.h:14
void setPlaylist(MediaPlaylist *playlist)
Definition: mediaplayer.h:55
bool isStopAfterCurrent() const
Definition: mediaplayer.h:45
The MediaPlaylist class has been created to have a custom Random mode.
Definition: mediaplaylist.h:16
QMediaPlayer::State state() const
Definition: mediaplayer.h:61
The AVPlayer class Preload:
Definition: AVPlayer.h:62
AudioOutput ao; ao.setAudioFormat(fmt); ao.open(); while (has_data) { data = read_data(ao->bufferSize...
Definition: AudioDecoder.h:31
MediaStatus
Definition: QtAV_Global.h:83
#define MIAMCORE_LIBRARY
Definition: miamcore_global.h:11
MediaPlaylist * playlist()
Definition: mediaplayer.h:48
The MediaPlayer class is a central class which controls local and remote sources. ...
Definition: mediaplayer.h:22