Qt 4.8
Signals | Public Functions | Private Slots | Private Functions | Properties | List of all members
AVMediaObject Class Reference

#include <avmediaobject.h>

Inheritance diagram for AVMediaObject:
QObject

Signals

void aboutToFinish ()
 
void bufferStatus (int)
 
void currentSourceChanged (const MediaSource &)
 
void finished ()
 
void hasVideoChanged (bool)
 
void metaDataChanged (const QMultiMap< QString, QString > &)
 
void prefinishMarkReached (qint32)
 
void seekableChanged (bool)
 
void stateChanged (Phonon::State newstate, Phonon::State oldstate)
 
void tick (qint64 time)
 
void totalTimeChanged (qint64 length)
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

 AVMediaObject (QObject *parent)
 
qint64 currentTime () const
 
QString errorString () const
 
Phonon::ErrorType errorType () const
 
void handlePlayerFinished ()
 
bool hasVideo () const
 
bool isSeekable () const
 
void pause ()
 
void play ()
 
qint32 prefinishMark () const
 
void seek (qint64 milliseconds)
 
void setAudioOutput (AVAudioOutput *audioOutput)
 
void setNextSource (const Phonon::MediaSource &source)
 
void setPrefinishMark (qint32 newPrefinishMark)
 
void setSource (const Phonon::MediaSource &source)
 
void setTickInterval (qint32 newTickInterval)
 
void setTransitionTime (qint32)
 
Phonon::MediaSource source () const
 
Phonon::State state () const
 
void stop ()
 
qint32 tickInterval () const
 
qint64 totalTime () const
 
qint32 transitionTime () const
 
 ~AVMediaObject ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Private Slots

void setVolume (qreal newVolume)
 

Private Functions

void changeState (Phonon::State state)
 
bool checkPlayer () const
 

Properties

AVMediaObjectPrivated
 
QString m_errorString
 
Phonon::ErrorType m_errorType
 
Phonon::MediaSource m_mediaSource
 
AVAudioOutputm_output
 
Phonon::State m_state
 
qint32 m_tickInterval
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 54 of file avmediaobject.h.

Constructors and Destructors

◆ AVMediaObject()

AVMediaObject::AVMediaObject ( QObject parent)

Definition at line 94 of file avmediaobject.mm.

95  : QObject(parent),
96  m_tickInterval(0),
97  m_state(Phonon::LoadingState),
99  m_output(0),
100  d(new AVMediaObjectPrivate(this))
101 {
102 }
AVAudioOutput * m_output
qint32 m_tickInterval
AVMediaObjectPrivate * d
Phonon::State m_state
Phonon::ErrorType m_errorType
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753

◆ ~AVMediaObject()

AVMediaObject::~AVMediaObject ( )

Definition at line 104 of file avmediaobject.mm.

105 {
106  if (m_state == Phonon::PlayingState)
107  stop();
108  [d->player release];
109  delete d;
110 }
AVMediaObjectPrivate * d
Phonon::State m_state
AVAudioPlayer * player

Functions

◆ aboutToFinish

void AVMediaObject::aboutToFinish ( )
signal

Referenced by handlePlayerFinished().

◆ bufferStatus

void AVMediaObject::bufferStatus ( int  )
signal

◆ changeState()

void AVMediaObject::changeState ( Phonon::State  state)
private

Definition at line 112 of file avmediaobject.mm.

Referenced by handlePlayerFinished(), pause(), play(), setSource(), and stop().

113 {
114  if (m_state == state)
115  return;
116  Phonon::State oldState = m_state;
117  m_state = state;
118  emit stateChanged(m_state, oldState);
119 }
Phonon::State m_state
void stateChanged(Phonon::State newstate, Phonon::State oldstate)
#define emit
Definition: qobjectdefs.h:76
Phonon::State state() const
State
Definition: qaudio.h:59

◆ checkPlayer()

bool AVMediaObject::checkPlayer ( ) const
private

Definition at line 121 of file avmediaobject.mm.

Referenced by currentTime(), pause(), play(), seek(), stop(), and totalTime().

122 {
123  if (!d->player) {
124  m_errorType = Phonon::NormalError;
125  m_errorString = tr("Media source has not been set.");
126  return false;
127  }
128  return true;
129 }
QString m_errorString
AVMediaObjectPrivate * d
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
Phonon::ErrorType m_errorType
AVAudioPlayer * player

◆ currentSourceChanged

void AVMediaObject::currentSourceChanged ( const MediaSource &  )
signal

Referenced by setSource().

◆ currentTime()

qint64 AVMediaObject::currentTime ( ) const

Definition at line 188 of file avmediaobject.mm.

189 {
190  if (!checkPlayer())
191  return 0;
192  return (qint64)(d->player.currentTime * 1000);
193 }
AVMediaObjectPrivate * d
bool checkPlayer() const
__int64 qint64
Definition: qglobal.h:942
AVAudioPlayer * player

◆ errorString()

QString AVMediaObject::errorString ( ) const

Definition at line 200 of file avmediaobject.mm.

201 {
202  return m_errorString;
203 }
QString m_errorString

◆ errorType()

Phonon::ErrorType AVMediaObject::errorType ( ) const

Definition at line 205 of file avmediaobject.mm.

206 {
207  return m_errorType;
208 }
Phonon::ErrorType m_errorType

◆ finished

void AVMediaObject::finished ( )
signal

Referenced by handlePlayerFinished().

◆ handlePlayerFinished()

void AVMediaObject::handlePlayerFinished ( )

Definition at line 292 of file avmediaobject.mm.

293 {
296  emit finished();
297 }
void changeState(Phonon::State state)
#define emit
Definition: qobjectdefs.h:76
void aboutToFinish()

◆ hasVideo()

bool AVMediaObject::hasVideo ( ) const

Definition at line 178 of file avmediaobject.mm.

179 {
180  return false;
181 }

◆ hasVideoChanged

void AVMediaObject::hasVideoChanged ( bool  )
signal

◆ isSeekable()

bool AVMediaObject::isSeekable ( ) const

Definition at line 183 of file avmediaobject.mm.

184 {
185  return true;
186 }

◆ metaDataChanged

void AVMediaObject::metaDataChanged ( const QMultiMap< QString, QString > &  )
signal

◆ pause()

void AVMediaObject::pause ( )

Definition at line 143 of file avmediaobject.mm.

144 {
145  if (!checkPlayer())
146  return;
147  [d->player pause];
148  changeState(Phonon::PausedState);
149 }
AVMediaObjectPrivate * d
void changeState(Phonon::State state)
bool checkPlayer() const
AVAudioPlayer * player

◆ play()

void AVMediaObject::play ( )

Definition at line 131 of file avmediaobject.mm.

132 {
133  if (!checkPlayer())
134  return;
135  if (![d->player play]) {
136  m_errorType = Phonon::NormalError;
137  m_errorString = tr("Failed to play media source.");
138  return;
139  }
140  changeState(Phonon::PlayingState);
141 }
QString m_errorString
AVMediaObjectPrivate * d
void changeState(Phonon::State state)
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
bool checkPlayer() const
Phonon::ErrorType m_errorType
AVAudioPlayer * player

◆ prefinishMark()

qint32 AVMediaObject::prefinishMark ( ) const

Definition at line 251 of file avmediaobject.mm.

252 {
253  // not implemented
254  return 0;
255 }

◆ prefinishMarkReached

void AVMediaObject::prefinishMarkReached ( qint32  )
signal

◆ seek()

void AVMediaObject::seek ( qint64  milliseconds)

Definition at line 160 of file avmediaobject.mm.

161 {
162  if (!checkPlayer())
163  return;
164  d->player.currentTime = milliseconds/1000.;
165 }
AVMediaObjectPrivate * d
bool checkPlayer() const
AVAudioPlayer * player

◆ seekableChanged

void AVMediaObject::seekableChanged ( bool  )
signal

◆ setAudioOutput()

void AVMediaObject::setAudioOutput ( AVAudioOutput audioOutput)

Definition at line 273 of file avmediaobject.mm.

Referenced by AVBackend::connectNodes(), and AVBackend::disconnectNodes().

274 {
275  if (m_output) {
276  disconnect(m_output, SIGNAL(volumeChanged(qreal)), this, SLOT(setVolume(qreal)));
277  }
278  m_output = audioOutput;
279  if (m_output) {
280  connect(m_output, SIGNAL(volumeChanged(qreal)), this, SLOT(setVolume(qreal)));
282  }
283 }
AVAudioOutput * m_output
double qreal
Definition: qglobal.h:1193
void setVolume(qreal newVolume)
#define SLOT(a)
Definition: qobjectdefs.h:226
#define SIGNAL(a)
Definition: qobjectdefs.h:227
qreal volume() const
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895

◆ setNextSource()

void AVMediaObject::setNextSource ( const Phonon::MediaSource &  source)

Definition at line 246 of file avmediaobject.mm.

247 {
248  setSource(source);
249 }
void setSource(const Phonon::MediaSource &source)
Phonon::MediaSource source() const

◆ setPrefinishMark()

void AVMediaObject::setPrefinishMark ( qint32  newPrefinishMark)

Definition at line 257 of file avmediaobject.mm.

258 {
259  // not implemented
260 }

◆ setSource()

void AVMediaObject::setSource ( const Phonon::MediaSource &  source)

Definition at line 222 of file avmediaobject.mm.

Referenced by setNextSource().

223 {
224  if (d->player) {
225  stop();
226  [d->player release];
227  d->player = 0;
228  }
230  NSString *urlString = [NSString stringWithCString:source.url().toEncoded().constData()
231  encoding:NSASCIIStringEncoding];
232  NSURL *url = [NSURL URLWithString:urlString];
233  d->player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:NULL];
234  if (!d->player) {
235  m_errorString = tr("Failed to create player for '%1'").arg(source.url().toString());
236  changeState(Phonon::ErrorState);
237  return;
238  }
239  d->player.delegate = d->delegate;
240  [d->player prepareToPlay];
243  emit totalTimeChanged((qint64)(d->player.duration * 1000));
244 }
QString m_errorString
Phonon::MediaSource m_mediaSource
#define error(msg)
AVMediaObjectPrivate * d
void changeState(Phonon::State state)
AudioPlayerDelegate * delegate
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
void currentSourceChanged(const MediaSource &)
void totalTimeChanged(qint64 length)
#define emit
Definition: qobjectdefs.h:76
__int64 qint64
Definition: qglobal.h:942
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
AVAudioPlayer * player
Phonon::MediaSource source() const

◆ setTickInterval()

void AVMediaObject::setTickInterval ( qint32  newTickInterval)

Definition at line 172 of file avmediaobject.mm.

173 {
174  m_tickInterval = newTickInterval;
175  //TODO
176 }
qint32 m_tickInterval

◆ setTransitionTime()

void AVMediaObject::setTransitionTime ( qint32  )

Definition at line 268 of file avmediaobject.mm.

269 {
270  // not implemented
271 }

◆ setVolume

void AVMediaObject::setVolume ( qreal  newVolume)
privateslot

Definition at line 285 of file avmediaobject.mm.

Referenced by setAudioOutput().

286 {
287  if (!d->player) // do nothing, will be set when player is created
288  return;
289  [d->player setVolume:qMin((float)1.0, (float)newVolume)];
290 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
void setVolume(qreal newVolume)
AVMediaObjectPrivate * d
AVAudioPlayer * player

◆ source()

Phonon::MediaSource AVMediaObject::source ( ) const

Definition at line 217 of file avmediaobject.mm.

Referenced by setSource().

218 {
219  return m_mediaSource;
220 }
Phonon::MediaSource m_mediaSource

◆ state()

Phonon::State AVMediaObject::state ( ) const

Definition at line 195 of file avmediaobject.mm.

Referenced by changeState().

196 {
197  return m_state;
198 }
Phonon::State m_state

◆ stateChanged

void AVMediaObject::stateChanged ( Phonon::State  newstate,
Phonon::State  oldstate 
)
signal

Referenced by changeState().

◆ stop()

void AVMediaObject::stop ( )

Definition at line 151 of file avmediaobject.mm.

Referenced by setSource(), and ~AVMediaObject().

152 {
153  if (!checkPlayer())
154  return;
155  [d->player stop];
156  d->player.currentTime = 0;
158 }
AVMediaObjectPrivate * d
void changeState(Phonon::State state)
bool checkPlayer() const
AVAudioPlayer * player

◆ tick

void AVMediaObject::tick ( qint64  time)
signal

◆ tickInterval()

qint32 AVMediaObject::tickInterval ( ) const

Definition at line 167 of file avmediaobject.mm.

168 {
169  return m_tickInterval;
170 }
qint32 m_tickInterval

◆ totalTime()

qint64 AVMediaObject::totalTime ( ) const

Definition at line 210 of file avmediaobject.mm.

211 {
212  if (!checkPlayer())
213  return 0;
214  return d->player.duration;
215 }
AVMediaObjectPrivate * d
bool checkPlayer() const
AVAudioPlayer * player

◆ totalTimeChanged

void AVMediaObject::totalTimeChanged ( qint64  length)
signal

Referenced by setSource().

◆ transitionTime()

qint32 AVMediaObject::transitionTime ( ) const

Definition at line 262 of file avmediaobject.mm.

263 {
264  // not implemented
265  return 0;
266 }

Properties

◆ d

AVMediaObjectPrivate* AVMediaObject::d
private

◆ m_errorString

QString AVMediaObject::m_errorString
mutableprivate

Definition at line 113 of file avmediaobject.h.

Referenced by checkPlayer(), errorString(), play(), and setSource().

◆ m_errorType

Phonon::ErrorType AVMediaObject::m_errorType
mutableprivate

Definition at line 114 of file avmediaobject.h.

Referenced by checkPlayer(), errorType(), and play().

◆ m_mediaSource

Phonon::MediaSource AVMediaObject::m_mediaSource
private

Definition at line 115 of file avmediaobject.h.

Referenced by setSource(), and source().

◆ m_output

AVAudioOutput* AVMediaObject::m_output
private

Definition at line 117 of file avmediaobject.h.

Referenced by setAudioOutput().

◆ m_state

Phonon::State AVMediaObject::m_state
private

Definition at line 112 of file avmediaobject.h.

Referenced by changeState(), state(), and ~AVMediaObject().

◆ m_tickInterval

qint32 AVMediaObject::m_tickInterval
private

Definition at line 111 of file avmediaobject.h.

Referenced by setTickInterval(), and tickInterval().


The documentation for this class was generated from the following files: