summaryrefslogtreecommitdiffstats
path: root/tdecore/kaudioplayer.h
blob: 6e011e2465fd70d54e4fdf9e0b8097949fb6bc1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
    /*

    Copyright (C) 2000 Stefan Westerfeld
                       stefan@space.twc.de

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.
  
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.
   
    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.

    */

#ifndef __KAUDIOPLAYER_H__
#define __KAUDIOPLAYER_H__

#include <tqobject.h>
#include "tdelibs_export.h"

class KAudioPlayerPrivate;
/**
 * This class provides one-shot-and-forget audio playing. You will never
 * know if what you wanted to play really got played.
 *
 * It doesn't require linking any special libraries, as it operates over
 * DCOP. In the current implementation, it only indirectly communicates
 * with the aRts soundserver, using knotify as DCOP -> MCOP bridge.
 *
 * Due to that fact, if you need "fast" response times, more control or
 * feedback, use the MCOP interfaces rather than this.
 *
 * An example of using this class is:
 *
 * \code
 *   KAudioPlayer::play("/var/share/foo.wav");
 * \endcode
 *
 * If you want to use signals & slots, you can do something like:
 *
 * \code
 *   KAudioPlayer player("/var/share/foo.wav");
 *   connect(&button, TQT_SIGNAL(clicked()), &player, TQT_SLOT(play()));
 * \endcode
 *
 */
//REVISED: hausmann
class TDECORE_EXPORT KAudioPlayer : public TQObject {
TQ_OBJECT
public:
	/**
	 * Constructor.
	 *
	 * @param filename Absolute path to the filename of the sound file to play
	 * @param parent A parent TQObject for this KAudioPlayer
	 * @param name An internal name for this KAudioPlayer
	 */
	KAudioPlayer( const TQString& filename,
			TQObject* parent = 0, const char* name = 0 );

	/**
	 * Destructor.
	 */
	~KAudioPlayer();

	/**
	 * Static play function.
	 *
	 * @param filename Absolute path to the filename of the sound file to play.
	 *                if not absolute, goes off TDEDIR/share/sounds/ (preferred)
	 */
	static void play(const TQString &filename);

public slots:
	/**
	 * Play function as slot.
	 *
	 * Plays the soundfile given to the constructor.
	 */
	void play();
private:
	KAudioPlayerPrivate *d;
};

#endif // __KAUDIOPLAYER_H__