playermanager.h 2.85 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/***************************************************************************
                          playermanager.h
                             -------------------
    begin                : Sat Feb 14 2004
    copyright            : (C) 2004 by Scott Wheeler
    email                : wheeler@kde.org
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef PLAYERMANAGER_H
#define PLAYERMANAGER_H

Scott Wheeler's avatar
Scott Wheeler committed
21
#include "player.h"
22
#include "filehandle.h"
Scott Wheeler's avatar
Scott Wheeler committed
23
#include "jukIface.h"
24

25
class QTimer;
26
class KSelectAction;
27
class SliderAction;
28
class StatusLabel;
29
class PlaylistInterface;
30

31 32 33 34 35
/**
 * This class serves as a proxy to the Player interface and handles managing
 * the actions from the top-level mainwindow.
 */

Scott Wheeler's avatar
Scott Wheeler committed
36
class PlayerManager : public Player, public PlayerIface
37 38 39 40 41 42 43 44 45 46
{
    Q_OBJECT

protected:
    PlayerManager();
    virtual ~PlayerManager();

public:
    static PlayerManager *instance();

47 48 49
    bool playing() const;
    bool paused() const;
    float volume() const;
Scott Wheeler's avatar
Scott Wheeler committed
50 51
    int totalTime() const;
    int currentTime() const;
52
    int position() const;
53

54
    FileHandle playingFile() const;
55 56
    QString playingString() const;

57 58
    void setPlaylistInterface(PlaylistInterface *interface);
    void setStatusLabel(StatusLabel *label);
59

60 61
    static KSelectAction *playerSelectAction(QObject *parent);

62
public slots:
63

Scott Wheeler's avatar
Scott Wheeler committed
64 65
    void play(const FileHandle &file);
    void play();
66 67 68
    void pause();
    void stop();
    void setVolume(float volume = 1.0);
Scott Wheeler's avatar
Scott Wheeler committed
69
    void seek(int seekTime);
70
    void seekPosition(int position);
71 72 73
    void seekForward();
    void seekBack();
    void playPause();
74 75
    void forward();
    void back();
76 77 78
    void volumeUp();
    void volumeDown();
    void mute();
79

80 81 82 83 84
signals:
    void signalPlay();
    void signalPause();
    void signalStop();

85
private:
86
    Player *player() const;
87
    void setup();
88 89 90

private slots:
    void slotPollPlay();
91 92
    void slotUpdateTime(int position);
    void slotSetOutput(int system);
93
    void slotSetVolume(int volume);
94 95

private:
96 97
    static PlayerManager *m_instance;

98
    FileHandle m_file;
99
    SliderAction *m_sliderAction;
100 101
    PlaylistInterface *m_playlistInterface;
    StatusLabel *m_statusLabel;
102
    Player *m_player;
103 104
    QTimer *m_timer;
    bool m_noSeek;
105
    bool m_muted;
106 107

    static const int m_pollInterval = 800;
108 109 110
};

#endif