1 /*
2  *  Copyright (c) 2015 Jouni Pentikäinen <joupent@gmail.com>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef KIS_ANIMATION_PLAYER_H
20 #define KIS_ANIMATION_PLAYER_H
21 
22 #include <QScopedPointer>
23 #include <QObject>
24 
25 #include "kritaui_export.h"
26 
27 
28 class KisCanvas2;
29 
30 class KRITAUI_EXPORT KisAnimationPlayer : public QObject
31 {
32     Q_OBJECT
33 
34 public:
35     KisAnimationPlayer(KisCanvas2 *canvas);
36     ~KisAnimationPlayer() override;
37 
38     void play();
39     void stop();
40     void displayFrame(int time);
41 
42     bool isPlaying();
43     int currentTime();
44 
45     qreal playbackSpeed();
46 
47     void forcedStopOnExit();
48 
49     qreal effectiveFps() const;
50     qreal realFps() const;
51     qreal framesDroppedPortion() const;
52 
53 Q_SIGNALS:
54     void sigFrameChanged();
55     void sigPlaybackStarted();
56     void sigPlaybackStopped();
57     void sigPlaybackStatisticsUpdated();
58     void sigFullClipRangeChanged();
59 
60 public Q_SLOTS:
61     void slotUpdate();
62     void slotCancelPlayback();
63     void slotCancelPlaybackSafe();
64     void slotUpdatePlaybackSpeed(double value);
65     void slotUpdatePlaybackTimer();
66     void slotUpdateDropFramesMode();
67 
68 private Q_SLOTS:
69     void slotSyncScrubbingAudio(int msecTime);
70     void slotTryStopScrubbingAudio();
71     void slotUpdateAudioChunkLength();
72     void slotAudioChannelChanged();
73     void slotAudioVolumeChanged();
74     void slotOnAudioError(const QString &fileName, const QString &message);
75 
76 
77 
78 
79 private:
80     void connectCancelSignals();
81     void disconnectCancelSignals();
82     void uploadFrame(int time, bool forceSyncAudio);
83 
84 private:
85     struct Private;
86     QScopedPointer<Private> m_d;
87 };
88 
89 
90 #endif
91