playermanager.h 2.66 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

21
#include "filehandle.h"
22

23
class QTimer;
24
class KSelectAction;
25
class SliderAction;
26
class StatusLabel;
27
class PlaylistInterface;
28
class Player;
29

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

35
class PlayerManager : public QObject
36 37 38 39 40 41 42 43 44 45
{
    Q_OBJECT

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

public:
    static PlayerManager *instance();

46 47 48 49 50 51
    bool playing() const;
    bool paused() const;
    float volume() const;
    long totalTime() const;
    long currentTime() const;
    int position() const;
52

53 54
    void setPlaylistInterface(PlaylistInterface *interface);
    void setStatusLabel(StatusLabel *label);
55

56 57
    static KSelectAction *playerSelectAction(QObject *parent);

58
public slots:
59

60
    void play(const FileHandle &file = FileHandle::null());
61 62 63 64 65
    void pause();
    void stop();
    void setVolume(float volume = 1.0);
    void seek(long seekTime);
    void seekPosition(int position);
66 67 68
    void seekForward();
    void seekBack();
    void playPause();
69 70
    void forward();
    void back();
71 72 73
    void volumeUp();
    void volumeDown();
    void mute();
74

75
private:
76
    Player *player() const;
77
    void setup();
78 79 80

private slots:
    void slotPollPlay();
81 82
    void slotUpdateTime(int position);
    void slotSetOutput(int system);
83
    void slotSetVolume(int volume); // TODO: make private
84 85

private:
86 87 88
    static PlayerManager *m_instance;

    SliderAction *m_sliderAction;
89 90
    PlaylistInterface *m_playlistInterface;
    StatusLabel *m_statusLabel;
91
    Player *m_player;
92 93
    QTimer *m_timer;
    bool m_noSeek;
94
    bool m_muted;
95 96

    static const int m_pollInterval = 800;
97 98 99
};

#endif