2
* This file is part of the KDE libraries
3
* Copyright (C) 2006 Germain Garand <germain@ebooksfrance.org>
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
#include "ecma/kjs_dom.h"
24
#include "ecma/kjs_binding.h"
25
#include <kjs/object.h>
27
#include <phonon/phononnamespace.h>
29
#include "misc/loader.h"
39
class AudioConstructorImp : public ObjectImp {
41
AudioConstructorImp(ExecState *exec, DOM::DocumentImpl* d);
42
virtual bool implementsConstruct() const;
43
virtual ObjectImp* construct(ExecState *exec, const List &args);
45
SharedPtr<DOM::DocumentImpl> doc;
48
////////////////////// Audio Object ////////////////////////
50
class JSEventListener;
53
class Audio : public DOMObject, private khtml::CachedObjectClient {
55
Audio(ExecState *, DOM::DocumentImpl* d, const QString& url);
58
bool getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot);
59
ValueImp *getValueProperty(ExecState *exec, int token) const;
60
virtual void put(ExecState *exec, const Identifier &propertyName, ValueImp *value, int attr = None);
61
void putValueProperty(ExecState *exec, int token, ValueImp *value, int /*attr*/);
62
virtual bool toBoolean(ExecState *) const { return true; }
63
virtual const ClassInfo* classInfo() const { return &info; }
64
static const ClassInfo info;
65
enum { Onload, Onerror, Loop, Play, Stop };
72
friend class AudioProtoFunc;
73
friend class AudioQObject;
75
// from CachedObjectClient
76
virtual void notifyFinished(khtml::CachedObject *);
77
virtual void error(int err, const QString &text);
82
QPointer<DOM::DocumentImpl> m_doc;
83
khtml::CachedSound* m_cs;
87
JSEventListener *m_onLoadListener;
88
JSEventListener *m_onErrorListener;
91
// Needs a separate class as QObjects confuse the hell out of
92
// KJS's garbage collector
93
class AudioQObject: public QObject {
96
AudioQObject(Audio* jObj);
97
virtual ~AudioQObject();
99
void setSound( const QByteArray& s ) { m_sound = s; }
107
void nextIteration();
110
void slotStateChanged(Phonon::State newstate, Phonon::State oldstate);
118
Phonon::ByteStream* m_media;
123
static Phonon::AudioPath* s_audioPath;
124
static Phonon::AudioOutput* s_audioOutput;