Pencil2D  ff90c0872e88be3bf81c548cd60f01983012ec49
Pencil2D is an animation software for both bitmap and vector graphics. It is free, multi-platform, and open source.
 All Classes Functions
soundplayer.h
1 /*
2 
3 Pencil - Traditional Animation Software
4 Copyright (C) 2012-2017 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 
28 class SoundPlayer : public QObject, public KeyFrameEventListener
29 {
30  Q_OBJECT
31 public:
32  SoundPlayer();
33  ~SoundPlayer();
34 
35  void init( SoundClip* );
36  void onKeyFrameDestroy( KeyFrame* ) override;
37  bool isValid();
38 
39  void play();
40  void stop();
41 
42  int64_t duration();
43  SoundClip* clip() { return mSoundClip; }
44 
45  void setMediaPlayerPosition( qint64 pos );
46 
47 Q_SIGNALS:
48  void corruptedSoundFile( SoundClip* );
49  void durationChanged( SoundPlayer*, int64_t duration );
50 
51 private:
52  void makeConnections();
53 
54  SoundClip* mSoundClip = nullptr;
55  QMediaPlayer* mMediaPlayer = nullptr;
56 };
57 
58 #endif // SOUNDPLAYER_H