~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to noatun/noatun/library/player.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef PLAYER_H
 
2
#define PLAYER_H
 
3
 
 
4
#include <qobject.h>
 
5
#include <qtimer.h>
 
6
#include <kurl.h>
 
7
#include <noatunplaylist.h>
 
8
 
 
9
class Engine;
 
10
class Playlist;
 
11
class KLibrary;
 
12
 
 
13
/**
 
14
 * This class has slots for all the common media player buttons
 
15
 * The slots are called, and it queries the Playlist for the appropriate
 
16
 * file.
 
17
 **/
 
18
class Player : public QObject
 
19
{
 
20
Q_OBJECT
 
21
friend class Effects;
 
22
friend class PlaylistItem;
 
23
 
 
24
public:
 
25
        enum LoopType { None=0, Song, Playlist };
 
26
        
 
27
public:
 
28
        Player(QObject *parent=0);
 
29
        ~Player();
 
30
 
 
31
        /**
 
32
         * returns a string with the time that can
 
33
         * be used in the UI:
 
34
         * CC:CC/LL:LL (mm:ss)
 
35
         **/
 
36
        QString lengthString(int _position=-1);
 
37
        /**
 
38
         * returns the LoopType enum
 
39
         **/
 
40
        int loopStyle() const { return mLoopStyle; }
 
41
        /**
 
42
         * the volume from 0-100
 
43
         * use volume() instead
 
44
         **/
 
45
        int volume() const;
 
46
        /**
 
47
         * the position in milliseconds
 
48
         **/
 
49
        int getTime() const { return position; }
 
50
        /**
 
51
         * the track-length in milliseconds
 
52
         **/
 
53
        int getLength();
 
54
        /**
 
55
         * true if we're playing
 
56
         **/
 
57
        bool isPlaying();
 
58
        /**
 
59
         * true if paused
 
60
         **/
 
61
        bool isPaused();
 
62
        /**
 
63
         * true if stopped
 
64
         **/
 
65
        bool isStopped();
 
66
 
 
67
        /**
 
68
         * get the current playlist
 
69
         * this may be null
 
70
         * And this may not be necessarily an item allocated
 
71
         * by playlist()
 
72
         **/
 
73
        PlaylistItem *current() const { return mCurrent;}
 
74
 
 
75
        /**
 
76
         * load the @param file, clear the playlist if @param purg is set
 
77
         * and if autoplay is set, play the item.
 
78
         **/
 
79
        void openFile(const KURL &file, bool purge=true, bool autoplay=false);
 
80
        
 
81
        Engine *engine() const { return mEngine; }
 
82
        
 
83
public slots:
 
84
        /**
 
85
         * show or hide the playlist
 
86
         **/
 
87
        void toggleListView();
 
88
        /**
 
89
         * force the playing/paused/stopped/playlist shown signals to
 
90
         * be sent out
 
91
         **/
 
92
        void handleButtons();
 
93
        /**
 
94
         * remove current from playlist
 
95
         **/
 
96
        void removeCurrent();
 
97
        
 
98
        /**
 
99
         * go back a track
 
100
         **/
 
101
        void back();
 
102
        /**
 
103
         * stop playing
 
104
         **/
 
105
        void stop();
 
106
        /**
 
107
         * start playing
 
108
         **/
 
109
        void play();
 
110
        /**
 
111
         * start playing, or pause if we're currently playing
 
112
         **/
 
113
        void playpause();
 
114
        /**
 
115
         * go forward a track
 
116
         **/
 
117
        void fastForward(bool allowLoop);
 
118
        /**
 
119
         * same as fastForward(true)
 
120
         **/
 
121
        void fastForward() { fastForward(true); }
 
122
        
 
123
        /**
 
124
         * skip to the position, unit is milliseconds
 
125
         **/
 
126
        void skipTo(int msec);
 
127
        void loop();
 
128
        void loop(int i);
 
129
 
 
130
        void newCurrent();
 
131
        void playCurrent();
 
132
        void setVolume(int);
 
133
 
 
134
        void toggleInterfaces();
 
135
        void showInterfaces();
 
136
        void hideInterfaces();
 
137
 
 
138
private slots:
 
139
        void posTimeout();
 
140
 
 
141
signals:
 
142
        /**
 
143
         * Tells you to update the seekbar and volume
 
144
         **/
 
145
        void timeout();
 
146
 
 
147
        /**
 
148
         * Tells you to hide
 
149
         */
 
150
        void hideYourself();
 
151
 
 
152
        /**
 
153
         * Tells you to show again
 
154
         */
 
155
        void showYourself();
 
156
 
 
157
        void stopped();
 
158
        void playing();
 
159
        void paused();
 
160
        void loopTypeChange(int t);
 
161
        void playlistShown();
 
162
        void playlistHidden();
 
163
 
 
164
        /**
 
165
         * called at the same time as newSong, but
 
166
         * maybe easier to work with
 
167
         **/
 
168
        void newSongLen(int mins, int sec);
 
169
 
 
170
        /**
 
171
         * when a new song is currently playing
 
172
         **/
 
173
        void newSong();
 
174
 
 
175
        /**
 
176
         * Called when a new song is about to be played, but
 
177
         * hasn't started.  player->current() is the
 
178
         * next song
 
179
         **/
 
180
        void changed();
 
181
        
 
182
        void volumeChanged(int);
 
183
 
 
184
private:
 
185
        Engine *mEngine;
 
186
        QTimer filePos;
 
187
        int position;
 
188
        int mLoopStyle;
 
189
        bool firstTimeout;
 
190
        PlaylistItem *mCurrent;
 
191
        bool mDeleteMe;
 
192
        bool showingInterfaces;
 
193
};
 
194
 
 
195
#endif
 
196