All Classes Namespaces Functions Variables Enumerations Properties Pages
soundplayer.h
1 /*
2 
3 Pencil2D - Traditional Animation Software
4 Copyright (C) 2012-2020 Matthew Chiawen Chang
5 
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; version 2 of the License.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 */
16 
17 #ifndef SOUNDPLAYER_H
18 #define SOUNDPLAYER_H
19 
20 #include <memory>
21 #include <QObject>
22 #include "pencilerror.h"
23 #include "keyframe.h"
24 
25 class SoundClip;
26 class QMediaPlayer;
27 
29 {
30  Q_OBJECT
31 public:
32  SoundPlayer();
33  ~SoundPlayer() override;
34 
35  void init( SoundClip* );
36  void onKeyFrameDestroy( KeyFrame* ) override;
37  bool isValid();
38 
39  void play();
40  void pause();
41  void stop();
42 
43  int64_t duration();
44  SoundClip* clip() { return mSoundClip; }
45 
46  void setMediaPlayerPosition( qint64 pos );
47 
48 signals:
49  void corruptedSoundFile( SoundClip* );
50  void durationChanged( SoundPlayer*, int64_t duration );
51 
52 private:
53  void makeConnections();
54 
55  SoundClip* mSoundClip = nullptr;
56  QMediaPlayer* mMediaPlayer = nullptr;
57 };
58 
59 #endif // SOUNDPLAYER_H
Q_OBJECTQ_OBJECT