~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kpresenter/kpresenter_sound_player.cc

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
2
 
/* This file is part of the KDE project
3
 
 
4
 
base code from kaudioplayer.h, kaudioplayer.cpp
5
 
Copyright (C) 2000 Stefan Westerfeld
6
 
stefan@space.twc.de
7
 
 
8
 
and konq_sound.h konq_sound.cc
9
 
Copyright (c) 2001 Malte Starostik <malte@kde.org>
10
 
 
11
 
This file's authors :
12
 
Copyright (C) 2001 Toshitaka Fujioka <fujioka@kde.org>
13
 
 
14
 
This library is free software; you can redistribute it and/or
15
 
modify it under the terms of the GNU Library General Public
16
 
License as published by the Free Software Foundation; either
17
 
version 2 of the License, or (at your option) any later version.
18
 
 
19
 
This library is distributed in the hope that it will be useful,
20
 
but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22
 
Library General Public License for more details.
23
 
 
24
 
You should have received a copy of the GNU Library General Public License
25
 
along with this library; see the file COPYING.LIB.  If not, write to
26
 
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27
 
Boston, MA 02111-1307, USA.
28
 
*/
29
 
 
30
 
#include <config.h>
31
 
 
32
 
#ifndef WITHOUT_ARTS
33
 
#include <kartsdispatcher.h>
34
 
#include <kplayobjectfactory.h>
35
 
#include <soundserver.h>
36
 
#endif
37
 
 
38
 
#include <kdebug.h>
39
 
 
40
 
#include "kpresenter_sound_player.h"
41
 
 
42
 
using namespace std;
43
 
 
44
 
class KPresenterSoundPlayerPrivate {
45
 
public:
46
 
    QString fileName;
47
 
 
48
 
    KPresenterSoundPlayerPrivate( QString fileName ) : fileName( fileName ) {};
49
 
 
50
 
#ifndef WITHOUT_ARTS
51
 
    KArtsDispatcher m_dispatche;
52
 
    Arts::SoundServerV2 m_soundServer;
53
 
    KPlayObjectFactory *m_factory;
54
 
    KPlayObject        *m_player;
55
 
#endif
56
 
};
57
 
 
58
 
KPresenterSoundPlayer::KPresenterSoundPlayer( const QString &fileName, QObject *parent, const char *name )
59
 
    : QObject( parent, name )
60
 
{
61
 
    d = new KPresenterSoundPlayerPrivate( fileName );
62
 
 
63
 
#ifndef WITHOUT_ARTS
64
 
    d->m_soundServer = Arts::Reference( "global:Arts_SoundServerV2" );
65
 
    d->m_factory = new KPlayObjectFactory( d->m_soundServer );
66
 
    d->m_player = 0;
67
 
#endif
68
 
}
69
 
 
70
 
KPresenterSoundPlayer::~KPresenterSoundPlayer()
71
 
{
72
 
#ifndef WITHOUT_ARTS
73
 
    delete d->m_player;
74
 
    delete d->m_factory;
75
 
#endif
76
 
    delete d;
77
 
}
78
 
 
79
 
void KPresenterSoundPlayer::play( const QString &fileName )
80
 
{
81
 
    KPresenterSoundPlayer sp( fileName );
82
 
    sp.play();
83
 
}
84
 
 
85
 
void KPresenterSoundPlayer::stop()
86
 
{
87
 
#ifndef WITHOUT_ARTS
88
 
    delete d->m_player;
89
 
    d->m_player = 0;
90
 
#endif
91
 
}
92
 
 
93
 
void KPresenterSoundPlayer::play()
94
 
{
95
 
#ifndef WITHOUT_ARTS
96
 
    if ( d->m_soundServer.isNull() )
97
 
        return;
98
 
 
99
 
    delete d->m_player;
100
 
 
101
 
    d->m_player = d->m_factory->createPlayObject( d->fileName, true );
102
 
    if ( d->m_player ) {
103
 
        if ( d->m_player->object().isNull() )
104
 
            stop();
105
 
        else
106
 
            d->m_player->play();
107
 
    }
108
 
#endif
109
 
}
110
 
 
111
 
#include "kpresenter_sound_player.moc"