playermanager.h 3.75 KB
Newer Older
1
2
3
4
/***************************************************************************
    begin                : Sat Feb 14 2004
    copyright            : (C) 2004 by Scott Wheeler
    email                : wheeler@kde.org
5
6
7
8
9
10

    copyright            : (C) 2007 by Matthias Kretz
    email                : kretz@kde.org

    copyright            : (C) 2008 by Michael Pyne
    email                : michael.pyne@kdemail.net
11
12
13
14
15
16
17
18
19
20
21
22
23
24
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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

25
#include <QObject>
26

27
#include "filehandle.h"
28

29
#include <phononnamespace.h>
30
#include <Phonon/Path>
31

32
class KSelectAction;
33
class SliderAction;
34
class StatusLabel;
35
class PlaylistInterface;
36
class QPixmap;
37

38
39
40
41
namespace Phonon
{
    class AudioOutput;
    class MediaObject;
42
    class VolumeFaderEffect;
43
44
}

45
46
47
48
49
/**
 * This class serves as a proxy to the Player interface and handles managing
 * the actions from the top-level mainwindow.
 */

50
class PlayerManager : public QObject
51
52
53
54
55
56
57
58
59
60
{
    Q_OBJECT

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

public:
    static PlayerManager *instance();

61
62
63
    bool playing() const;
    bool paused() const;
    float volume() const;
64
    int status() const;
Scott Wheeler's avatar
Scott Wheeler committed
65
66
    int totalTime() const;
    int currentTime() const;
67
    //int position() const;
68

69
70
    QStringList trackProperties();
    QString trackProperty(const QString &property) const;
Michael Pyne's avatar
Michael Pyne committed
71
    QPixmap trackCover(const QString &size) const;
72

73
    FileHandle playingFile() const;
74
75
    QString playingString() const;

76
77
    KSelectAction* outputDeviceSelectAction();

78
79
    void setPlaylistInterface(PlaylistInterface *interface);
    void setStatusLabel(StatusLabel *label);
80

Michael Pyne's avatar
Michael Pyne committed
81
82
    QString randomPlayMode() const;

83
public slots:
84

Scott Wheeler's avatar
Scott Wheeler committed
85
    void play(const FileHandle &file);
86
    void play(const QString &file);
Scott Wheeler's avatar
Scott Wheeler committed
87
    void play();
88
89
90
    void pause();
    void stop();
    void setVolume(float volume = 1.0);
Scott Wheeler's avatar
Scott Wheeler committed
91
    void seek(int seekTime);
92
    //void seekPosition(int position);
93
94
95
    void seekForward();
    void seekBack();
    void playPause();
96
97
    void forward();
    void back();
98
99
100
    void volumeUp();
    void volumeDown();
    void mute();
101

Michael Pyne's avatar
Michael Pyne committed
102
103
    void setRandomPlayMode(const QString &randomMode);

104
105
106
107
108
signals:
    void signalPlay();
    void signalPause();
    void signalStop();

109
110
private:
    void setup();
111
    void crossfadeToFile(const FileHandle &newFile);
112
    void stopCrossfade();
113

114
private slots:
115
    void slotNeedNextUrl();
116
    void slotFinished();
117
    void slotLength(qint64);
118
    void slotTick(qint64);
119
    void slotStateChanged(Phonon::State, Phonon::State);
120
121
122
    void slotUpdateSliders();
    /// Updates the GUI to reflect stopped playback if we're stopped at this point.
    void slotUpdateGuiIfStopped();
123
124

private:
125
    FileHandle m_file;
126
    SliderAction *m_sliderAction;
127
128
    PlaylistInterface *m_playlistInterface;
    StatusLabel *m_statusLabel;
129
    bool m_muted;
130
    bool m_setup;
131
132

    static const int m_pollInterval = 800;
133

134
135
136
137
138
    int m_curOutputPath; ///< Either 0 or 1 depending on which output path is in use.
    Phonon::AudioOutput *m_output[2];
    Phonon::Path m_audioPath[2];
    Phonon::MediaObject *m_media[2];
    Phonon::VolumeFaderEffect *m_fader[2];
139
140
141
};

#endif
142
143

// vim: set et sw=4 tw=0 sta: