kpresenter
KPrSoundPlayer.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <config.h>
00031
00032 #ifndef WITHOUT_ARTS
00033 #include <kartsdispatcher.h>
00034 #include <kplayobjectfactory.h>
00035 #include <soundserver.h>
00036 #endif
00037
00038 #include <kdebug.h>
00039
00040 #include "KPrSoundPlayer.h"
00041
00042 using namespace std;
00043
00044 class KPresenterSoundPlayerPrivate {
00045 public:
00046 QString fileName;
00047
00048 KPresenterSoundPlayerPrivate( QString fileName ) : fileName( fileName ) {};
00049
00050 #ifndef WITHOUT_ARTS
00051 KArtsDispatcher m_dispatche;
00052 Arts::SoundServerV2 m_soundServer;
00053 KPlayObjectFactory *m_factory;
00054 KPlayObject *m_player;
00055 #endif
00056 };
00057
00058 KPrSoundPlayer::KPrSoundPlayer( const QString &fileName, QObject *parent, const char *name )
00059 : QObject( parent, name )
00060 {
00061 d = new KPresenterSoundPlayerPrivate( fileName );
00062
00063 #ifndef WITHOUT_ARTS
00064 d->m_soundServer = Arts::Reference( "global:Arts_SoundServerV2" );
00065 d->m_factory = new KPlayObjectFactory( d->m_soundServer );
00066 d->m_player = 0;
00067 #endif
00068 }
00069
00070 KPrSoundPlayer::~KPrSoundPlayer()
00071 {
00072 #ifndef WITHOUT_ARTS
00073 delete d->m_player;
00074 delete d->m_factory;
00075 #endif
00076 delete d;
00077 }
00078
00079 void KPrSoundPlayer::play( const QString &fileName )
00080 {
00081 KPrSoundPlayer sp( fileName );
00082 sp.play();
00083 }
00084
00085 void KPrSoundPlayer::stop()
00086 {
00087 #ifndef WITHOUT_ARTS
00088 delete d->m_player;
00089 d->m_player = 0;
00090 #endif
00091 }
00092
00093 void KPrSoundPlayer::play()
00094 {
00095 #ifndef WITHOUT_ARTS
00096 if ( d->m_soundServer.isNull() )
00097 return;
00098
00099 delete d->m_player;
00100
00101 d->m_player = d->m_factory->createPlayObject( d->fileName, true );
00102 if ( d->m_player ) {
00103 if ( d->m_player->object().isNull() )
00104 stop();
00105 else
00106 d->m_player->play();
00107 }
00108 #endif
00109 }
00110
00111 #include "KPrSoundPlayer.moc"
|