~ubuntu-branches/ubuntu/wily/kid3/wily-proposed

« back to all changes in this revision

Viewing changes to src/core/model/audioplayer.h

  • Committer: Package Import Robot
  • Author(s): Ana Beatriz Guerrero Lopez, Patrick Matthäi, Ana Beatriz Guerrero Lopez
  • Date: 2011-11-13 16:34:13 UTC
  • mfrom: (1.1.13) (2.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20111113163413-5y0anlc4dqf511uh
Tags: 2.0.1-1
* New upstream release.

[ Patrick Matthäi ]
* Adjust build system.
* Add build dependency xsltproc.

[ Ana Beatriz Guerrero Lopez ]
* Some more adjustments to the build system taken from upstream's deb/
* directory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * \file audioplayer.h
 
3
 * Audio player.
 
4
 *
 
5
 * \b Project: Kid3
 
6
 * \author Urs Fleisch
 
7
 * \date 03-Aug-2011
 
8
 *
 
9
 * Copyright (C) 2011  Urs Fleisch
 
10
 *
 
11
 * This file is part of Kid3.
 
12
 *
 
13
 * Kid3 is free software; you can redistribute it and/or modify
 
14
 * it under the terms of the GNU General Public License as published by
 
15
 * the Free Software Foundation; either version 2 of the License, or
 
16
 * (at your option) any later version.
 
17
 *
 
18
 * Kid3 is distributed in the hope that it will be useful,
 
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
21
 * GNU General Public License for more details.
 
22
 *
 
23
 * You should have received a copy of the GNU General Public License
 
24
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
25
 */
 
26
 
 
27
#ifndef AUDIOPLAYER_H
 
28
#define AUDIOPLAYER_H
 
29
 
 
30
#include <QObject>
 
31
#include "config.h"
 
32
 
 
33
#ifdef HAVE_PHONON
 
34
 
 
35
#include <QStringList>
 
36
 
 
37
namespace Phonon {
 
38
  class AudioOutput;
 
39
  class MediaObject;
 
40
}
 
41
 
 
42
/**
 
43
 * Audio player toolbar.
 
44
 */
 
45
class AudioPlayer : public QObject {
 
46
  Q_OBJECT
 
47
 
 
48
public:
 
49
  /**
 
50
   * Constructor.
 
51
   *
 
52
   * @param parent parent object
 
53
   */
 
54
  explicit AudioPlayer(QObject* parent);
 
55
 
 
56
  /**
 
57
   * Destructor.
 
58
   */
 
59
  virtual ~AudioPlayer();
 
60
 
 
61
  /**
 
62
   * Set files to be played.
 
63
   *
 
64
   * @param files  paths to files
 
65
   * @param fileNr index of file to play (default 0)
 
66
   */
 
67
  void setFiles(const QStringList& files, int fileNr = 0);
 
68
 
 
69
  /**
 
70
   * Play a track from the files.
 
71
   *
 
72
   * @param fileNr index in list of files set with setFiles()
 
73
   */
 
74
  void playTrack(int fileNr);
 
75
 
 
76
  /**
 
77
   * Access to media object.
 
78
   * @return media object.
 
79
   */
 
80
  Phonon::MediaObject* mediaObject() { return m_mediaObject; }
 
81
 
 
82
  /**
 
83
   * Access to audio output.
 
84
   * @return audio output.
 
85
   */
 
86
  Phonon::AudioOutput* audioOutput() { return m_audioOutput; }
 
87
 
 
88
signals:
 
89
  /**
 
90
   * Emitted when the current track is changed.
 
91
   * @param filePath path of currently played audio file
 
92
   * @param hasPrevious true if a previous track is available
 
93
   * @param hasNext true if a next track is available
 
94
   */
 
95
  void trackChanged(const QString& filePath, bool hasPrevious, bool hasNext);
 
96
 
 
97
public slots:
 
98
  /**
 
99
   * Toggle between play and pause.
 
100
   */
 
101
  void playOrPause();
 
102
 
 
103
  /**
 
104
   * Stop playback.
 
105
   */
 
106
  void stop();
 
107
 
 
108
  /**
 
109
   * Select previous track.
 
110
   */
 
111
  void previous();
 
112
 
 
113
  /**
 
114
   * Select next track.
 
115
   */
 
116
  void next();
 
117
 
 
118
private slots:
 
119
  /**
 
120
   * Update display and button state when the current source is changed.
 
121
   */
 
122
  void currentSourceChanged();
 
123
 
 
124
  /**
 
125
   * Queue next track when the current track is about to finish.
 
126
   */
 
127
  void aboutToFinish();
 
128
 
 
129
private:
 
130
  /**
 
131
   * Select a track from the files and optionally start playing it.
 
132
   *
 
133
   * @param fileNr index in list of files set with setFiles()
 
134
   * @param play   true to play track
 
135
   */
 
136
  void selectTrack(int fileNr, bool play);
 
137
 
 
138
  Phonon::MediaObject* m_mediaObject;
 
139
  Phonon::AudioOutput* m_audioOutput;
 
140
 
 
141
  QStringList m_files;
 
142
  int m_fileNr;
 
143
};
 
144
#else // HAVE_PHONON
 
145
 
 
146
// Just to suppress moc "No relevant classes found" warning.
 
147
class AudioPlayer : public QObject {
 
148
Q_OBJECT
 
149
};
 
150
 
 
151
#endif // HAVE_PHONON
 
152
 
 
153
#endif // AUDIOPLAYER_H