dan@367
|
1 /*
|
dan@367
|
2 iTunes connection for
|
dan@367
|
3 Sonic Visualiser
|
dan@367
|
4 An audio file viewer and annotation editor.
|
dan@367
|
5 Centre for Digital Music, Queen Mary, University of London.
|
dan@367
|
6 This file copyright 2010 Dan Stowell and QMUL.
|
dan@367
|
7
|
dan@367
|
8 This program is free software; you can redistribute it and/or
|
dan@367
|
9 modify it under the terms of the GNU General Public License as
|
dan@367
|
10 published by the Free Software Foundation; either version 2 of the
|
dan@367
|
11 License, or (at your option) any later version. See the file
|
dan@367
|
12 COPYING included with this distribution for more information.
|
dan@367
|
13 */
|
dan@367
|
14
|
dan@380
|
15 #ifndef _SVITUNES_H_
|
dan@380
|
16 #define _SVITUNES_H_
|
dan@380
|
17
|
dan@367
|
18 #include <QString>
|
dan@367
|
19 #include <QStringList>
|
dan@367
|
20
|
dan@381
|
21 //#import <Foundation/Foundation.h>
|
dan@367
|
22
|
dan@381
|
23 /**
|
dan@381
|
24 * Class to handle communication with a running iTunes program on the system.
|
dan@381
|
25 * Only implemented for Mac at present, since using applescript communication.
|
dan@381
|
26 */
|
dan@381
|
27 class ITunesSVRemote : QObject
|
dan@381
|
28 {
|
dan@381
|
29 Q_OBJECT
|
dan@381
|
30
|
dan@381
|
31 public:
|
dan@381
|
32
|
dan@383
|
33 ITunesSVRemote() :
|
dan@383
|
34 m_playerState(STATE_UNKNOWN),
|
dan@383
|
35 m_playerPos(0)
|
dan@383
|
36 { }
|
dan@383
|
37 virtual ~ITunesSVRemote() { }
|
dan@381
|
38
|
dan@381
|
39 // Returns a list containing [posixpath, genre]
|
dan@381
|
40 QStringList getNowPlaying();
|
dan@383
|
41
|
dan@383
|
42 // Queries iTunes about player state and stores results locally
|
dan@383
|
43 void updatePlayerState();
|
dan@381
|
44
|
dan@383
|
45 // Whether the app is running. Only correct if updatePlayerState() recently invoked.
|
dan@383
|
46 bool isRunning();
|
dan@383
|
47
|
dan@383
|
48 // Whether the app is playing back. Only correct if updatePlayerState() recently invoked.
|
dan@383
|
49 bool isPlaying();
|
dan@383
|
50
|
dan@383
|
51 // Playback position in seconds. Only correct if updatePlayerState() recently invoked.
|
dan@383
|
52 unsigned int playerPos();
|
dan@381
|
53
|
dan@383
|
54 protected:
|
dan@383
|
55
|
dan@383
|
56 enum {
|
dan@383
|
57 STATE_UNKNOWN, // before ever querying
|
dan@383
|
58 STATE_CLOSED, // application not running
|
dan@383
|
59 // The rest correspond to states reported by iTunes itself:
|
dan@383
|
60 STATE_STOPPED,
|
dan@383
|
61 STATE_PLAYING,
|
dan@383
|
62 STATE_PAUSED,
|
dan@383
|
63 STATE_FASTFORWARDING,
|
dan@383
|
64 STATE_REWINDING
|
dan@383
|
65 };
|
dan@383
|
66
|
dan@383
|
67 // itunes has a set of states: {playing, stopped, ...}.
|
dan@383
|
68 // we also use "unknown" before checking,
|
dan@383
|
69 // and "closed" if iTunes isn't running.
|
dan@383
|
70 int m_playerState;
|
dan@383
|
71 unsigned int m_playerPos; // itunes only tells us seconds
|
dan@383
|
72
|
dan@381
|
73 };
|
dan@367
|
74
|
dan@380
|
75 #endif
|