annotate osx/svitunes.h @ 385:a555be0ad78f macness

move ITunesSVRemote ctor and dtor into impl file
author Dan Stowell <dan.stowell@eecs.qmul.ac.uk>
date Mon, 18 Oct 2010 15:32:35 +0100
parents be237d380f5f
children 268478a184a3
rev   line source
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@385 33 ITunesSVRemote();
dan@385 34 ~ITunesSVRemote();
dan@381 35
dan@381 36 // Returns a list containing [posixpath, genre]
dan@381 37 QStringList getNowPlaying();
dan@383 38
dan@384 39 // When importing a fresh track we don't want the old cached playback position.
dan@384 40 // We can't simply update player position every time, since it only gets reported if playing.
dan@384 41 void resetPlayerState();
dan@384 42
dan@383 43 // Queries iTunes about player state and stores results locally
dan@383 44 void updatePlayerState();
dan@381 45
dan@383 46 // Whether the app is running. Only correct if updatePlayerState() recently invoked.
dan@383 47 bool isRunning();
dan@383 48
dan@383 49 // Whether the app is playing back. Only correct if updatePlayerState() recently invoked.
dan@383 50 bool isPlaying();
dan@383 51
dan@383 52 // Playback position in seconds. Only correct if updatePlayerState() recently invoked.
dan@383 53 unsigned int playerPos();
dan@381 54
dan@383 55 protected:
dan@383 56
dan@383 57 enum {
dan@383 58 STATE_UNKNOWN, // before ever querying
dan@383 59 STATE_CLOSED, // application not running
dan@383 60 // The rest correspond to states reported by iTunes itself:
dan@383 61 STATE_STOPPED,
dan@383 62 STATE_PLAYING,
dan@383 63 STATE_PAUSED,
dan@383 64 STATE_FASTFORWARDING,
dan@383 65 STATE_REWINDING
dan@383 66 };
dan@383 67
dan@383 68 // itunes has a set of states: {playing, stopped, ...}.
dan@383 69 // we also use "unknown" before checking,
dan@383 70 // and "closed" if iTunes isn't running.
dan@383 71 int m_playerState;
dan@383 72 unsigned int m_playerPos; // itunes only tells us seconds
dan@383 73
dan@381 74 };
dan@367 75
dan@380 76 #endif