Restructure the source code a little.
Change-Id: I995b0fb33bdda7f01bf6266c1c50a1b17eba6760 Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
6ee1977d60
commit
502d3c8eb3
27
src/multimedia/playback/playback.pri
Normal file
27
src/multimedia/playback/playback.pri
Normal file
@@ -0,0 +1,27 @@
|
||||
INCLUDEPATH += playback
|
||||
|
||||
PUBLIC_HEADERS += \
|
||||
playback/qaudioendpointselector.h \
|
||||
playback/qlocalmediaplaylistprovider.h \
|
||||
playback/qmediacontent.h \
|
||||
playback/qmediaplayer.h \
|
||||
playback/qmediaplaylist.h \
|
||||
playback/qmediaplaylistioplugin.h \
|
||||
playback/qmediaplaylistnavigator.h \
|
||||
playback/qmediaplaylistprovider.h \
|
||||
playback/qmediaresource.h
|
||||
|
||||
PRIVATE_HEADERS += \
|
||||
playback/qmediaplaylist_p.h \
|
||||
playback/qmediaplaylistprovider_p.h
|
||||
|
||||
SOURCES += \
|
||||
playback/qaudioendpointselector.cpp \
|
||||
playback/qlocalmediaplaylistprovider.cpp \
|
||||
playback/qmediacontent.cpp \
|
||||
playback/qmediaplayer.cpp \
|
||||
playback/qmediaplaylist.cpp \
|
||||
playback/qmediaplaylistioplugin.cpp \
|
||||
playback/qmediaplaylistnavigator.cpp \
|
||||
playback/qmediaplaylistprovider.cpp \
|
||||
playback/qmediaresource.cpp
|
||||
140
src/multimedia/playback/qaudioendpointselector.cpp
Normal file
140
src/multimedia/playback/qaudioendpointselector.cpp
Normal file
@@ -0,0 +1,140 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qaudioendpointselector.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QAudioEndpointSelector
|
||||
|
||||
\brief The QAudioEndpointSelector class provides an audio endpoint selector media control.
|
||||
\inmodule QtMultimedia
|
||||
\ingroup multimedia
|
||||
\since 1.0
|
||||
|
||||
The QAudioEndpointSelector class provides descriptions of the audio
|
||||
endpoints available on a system and allows one to be selected as the audio
|
||||
of a media service.
|
||||
|
||||
The interface name of QAudioEndpointSelector is \c com.nokia.Qt.QAudioEndpointSelector/1.0 as
|
||||
defined in QAudioEndpointSelector_iid.
|
||||
|
||||
\sa QMediaService::requestControl()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\macro QAudioEndpointSelector_iid
|
||||
|
||||
\c com.nokia.Qt.QAudioEndpointSelector/1.0
|
||||
|
||||
Defines the interface name of the QAudioEndpointSelector class.
|
||||
|
||||
\relates QAudioEndpointSelector
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a new audio endpoint selector with the given \a parent.
|
||||
*/
|
||||
QAudioEndpointSelector::QAudioEndpointSelector(QObject *parent)
|
||||
:QMediaControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys an audio endpoint selector.
|
||||
*/
|
||||
QAudioEndpointSelector::~QAudioEndpointSelector()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QList<QString> QAudioEndpointSelector::availableEndpoints() const
|
||||
|
||||
Returns a list of the names of the available audio endpoints.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QAudioEndpointSelector::endpointDescription(const QString& name) const
|
||||
|
||||
Returns the description of the endpoint \a name.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QAudioEndpointSelector::defaultEndpoint() const
|
||||
|
||||
Returns the name of the default audio endpoint.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QAudioEndpointSelector::activeEndpoint() const
|
||||
|
||||
Returns the name of the currently selected audio endpoint.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QAudioEndpointSelector::setActiveEndpoint(const QString& name)
|
||||
|
||||
Set the active audio endpoint to \a name.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QAudioEndpointSelector::activeEndpointChanged(const QString& name)
|
||||
|
||||
Signals that the audio endpoint has changed to \a name.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QAudioEndpointSelector::availableEndpointsChanged()
|
||||
|
||||
Signals that list of available endpoints has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
#include "moc_qaudioendpointselector.cpp"
|
||||
QT_END_NAMESPACE
|
||||
|
||||
86
src/multimedia/playback/qaudioendpointselector.h
Normal file
86
src/multimedia/playback/qaudioendpointselector.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QAUDIOENDPOINTSELECTOR_H
|
||||
#define QAUDIOENDPOINTSELECTOR_H
|
||||
|
||||
#include <qaudio.h>
|
||||
#include <qmediacontrol.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
|
||||
class Q_MULTIMEDIA_EXPORT QAudioEndpointSelector : public QMediaControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
virtual ~QAudioEndpointSelector();
|
||||
|
||||
virtual QList<QString> availableEndpoints() const = 0;
|
||||
virtual QString endpointDescription(const QString& name) const = 0;
|
||||
virtual QString defaultEndpoint() const = 0;
|
||||
virtual QString activeEndpoint() const = 0;
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void setActiveEndpoint(const QString& name) = 0;
|
||||
|
||||
Q_SIGNALS:
|
||||
void activeEndpointChanged(const QString& name);
|
||||
void availableEndpointsChanged();
|
||||
|
||||
protected:
|
||||
QAudioEndpointSelector(QObject *parent = 0);
|
||||
};
|
||||
|
||||
#define QAudioEndpointSelector_iid "com.nokia.Qt.QAudioEndpointSelector/1.0"
|
||||
Q_MEDIA_DECLARE_CONTROL(QAudioEndpointSelector, QAudioEndpointSelector_iid)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
|
||||
#endif // QAUDIOENDPOINTSELECTOR_H
|
||||
194
src/multimedia/playback/qlocalmediaplaylistprovider.cpp
Normal file
194
src/multimedia/playback/qlocalmediaplaylistprovider.cpp
Normal file
@@ -0,0 +1,194 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qlocalmediaplaylistprovider.h"
|
||||
#include "qmediaplaylistprovider_p.h"
|
||||
#include "qmediacontent.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QLocalMediaPlaylistProviderPrivate: public QMediaPlaylistProviderPrivate
|
||||
{
|
||||
public:
|
||||
QList<QMediaContent> resources;
|
||||
};
|
||||
|
||||
QLocalMediaPlaylistProvider::QLocalMediaPlaylistProvider(QObject *parent)
|
||||
:QMediaPlaylistProvider(*new QLocalMediaPlaylistProviderPrivate, parent)
|
||||
{
|
||||
}
|
||||
|
||||
QLocalMediaPlaylistProvider::~QLocalMediaPlaylistProvider()
|
||||
{
|
||||
}
|
||||
|
||||
bool QLocalMediaPlaylistProvider::isReadOnly() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int QLocalMediaPlaylistProvider::mediaCount() const
|
||||
{
|
||||
return d_func()->resources.size();
|
||||
}
|
||||
|
||||
QMediaContent QLocalMediaPlaylistProvider::media(int pos) const
|
||||
{
|
||||
return d_func()->resources.value(pos);
|
||||
}
|
||||
|
||||
bool QLocalMediaPlaylistProvider::addMedia(const QMediaContent &content)
|
||||
{
|
||||
Q_D(QLocalMediaPlaylistProvider);
|
||||
|
||||
int pos = d->resources.count();
|
||||
|
||||
emit mediaAboutToBeInserted(pos, pos);
|
||||
d->resources.append(content);
|
||||
emit mediaInserted(pos, pos);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QLocalMediaPlaylistProvider::addMedia(const QList<QMediaContent> &items)
|
||||
{
|
||||
Q_D(QLocalMediaPlaylistProvider);
|
||||
|
||||
if (items.isEmpty())
|
||||
return true;
|
||||
|
||||
int pos = d->resources.count();
|
||||
int end = pos+items.count()-1;
|
||||
|
||||
emit mediaAboutToBeInserted(pos, end);
|
||||
d->resources.append(items);
|
||||
emit mediaInserted(pos, end);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool QLocalMediaPlaylistProvider::insertMedia(int pos, const QMediaContent &content)
|
||||
{
|
||||
Q_D(QLocalMediaPlaylistProvider);
|
||||
|
||||
emit mediaAboutToBeInserted(pos, pos);
|
||||
d->resources.insert(pos, content);
|
||||
emit mediaInserted(pos,pos);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QLocalMediaPlaylistProvider::insertMedia(int pos, const QList<QMediaContent> &items)
|
||||
{
|
||||
Q_D(QLocalMediaPlaylistProvider);
|
||||
|
||||
if (items.isEmpty())
|
||||
return true;
|
||||
|
||||
const int last = pos+items.count()-1;
|
||||
|
||||
emit mediaAboutToBeInserted(pos, last);
|
||||
for (int i=0; i<items.count(); i++)
|
||||
d->resources.insert(pos+i, items.at(i));
|
||||
emit mediaInserted(pos, last);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QLocalMediaPlaylistProvider::removeMedia(int fromPos, int toPos)
|
||||
{
|
||||
Q_D(QLocalMediaPlaylistProvider);
|
||||
|
||||
Q_ASSERT(fromPos >= 0);
|
||||
Q_ASSERT(fromPos <= toPos);
|
||||
Q_ASSERT(toPos < mediaCount());
|
||||
|
||||
emit mediaAboutToBeRemoved(fromPos, toPos);
|
||||
d->resources.erase(d->resources.begin()+fromPos, d->resources.begin()+toPos+1);
|
||||
emit mediaRemoved(fromPos, toPos);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QLocalMediaPlaylistProvider::removeMedia(int pos)
|
||||
{
|
||||
Q_D(QLocalMediaPlaylistProvider);
|
||||
|
||||
emit mediaAboutToBeRemoved(pos, pos);
|
||||
d->resources.removeAt(pos);
|
||||
emit mediaRemoved(pos, pos);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QLocalMediaPlaylistProvider::clear()
|
||||
{
|
||||
Q_D(QLocalMediaPlaylistProvider);
|
||||
if (!d->resources.isEmpty()) {
|
||||
int lastPos = mediaCount()-1;
|
||||
emit mediaAboutToBeRemoved(0, lastPos);
|
||||
d->resources.clear();
|
||||
emit mediaRemoved(0, lastPos);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QLocalMediaPlaylistProvider::shuffle()
|
||||
{
|
||||
Q_D(QLocalMediaPlaylistProvider);
|
||||
if (!d->resources.isEmpty()) {
|
||||
QList<QMediaContent> resources;
|
||||
|
||||
while (!d->resources.isEmpty()) {
|
||||
resources.append(d->resources.takeAt(qrand() % d->resources.size()));
|
||||
}
|
||||
|
||||
d->resources = resources;
|
||||
emit mediaChanged(0, mediaCount()-1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include "moc_qlocalmediaplaylistprovider.cpp"
|
||||
QT_END_NAMESPACE
|
||||
|
||||
87
src/multimedia/playback/qlocalmediaplaylistprovider.h
Normal file
87
src/multimedia/playback/qlocalmediaplaylistprovider.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QLOCALMEDIAPAYLISTPROVIDER_H
|
||||
#define QLOCALMEDIAPAYLISTPROVIDER_H
|
||||
|
||||
#include "qmediaplaylistprovider.h"
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
|
||||
class QLocalMediaPlaylistProviderPrivate;
|
||||
class Q_MULTIMEDIA_EXPORT QLocalMediaPlaylistProvider : public QMediaPlaylistProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QLocalMediaPlaylistProvider(QObject *parent=0);
|
||||
virtual ~QLocalMediaPlaylistProvider();
|
||||
|
||||
virtual int mediaCount() const;
|
||||
virtual QMediaContent media(int pos) const;
|
||||
|
||||
virtual bool isReadOnly() const;
|
||||
|
||||
virtual bool addMedia(const QMediaContent &content);
|
||||
virtual bool addMedia(const QList<QMediaContent> &items);
|
||||
virtual bool insertMedia(int pos, const QMediaContent &content);
|
||||
virtual bool insertMedia(int pos, const QList<QMediaContent> &items);
|
||||
virtual bool removeMedia(int pos);
|
||||
virtual bool removeMedia(int start, int end);
|
||||
virtual bool clear();
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void shuffle();
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QLocalMediaPlaylistProvider)
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
|
||||
#endif // QLOCALMEDIAPAYLISTSOURCE_H
|
||||
266
src/multimedia/playback/qmediacontent.cpp
Normal file
266
src/multimedia/playback/qmediacontent.cpp
Normal file
@@ -0,0 +1,266 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qurl.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
|
||||
#include "qmediacontent.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace
|
||||
{
|
||||
class QMediaContentPrivateRegisterMetaTypes
|
||||
{
|
||||
public:
|
||||
QMediaContentPrivateRegisterMetaTypes()
|
||||
{
|
||||
qRegisterMetaType<QMediaContent>();
|
||||
}
|
||||
} _registerMetaTypes;
|
||||
}
|
||||
|
||||
|
||||
class QMediaContentPrivate : public QSharedData
|
||||
{
|
||||
public:
|
||||
QMediaContentPrivate() {}
|
||||
QMediaContentPrivate(const QMediaResourceList &r):
|
||||
resources(r) {}
|
||||
|
||||
QMediaContentPrivate(const QMediaContentPrivate &other):
|
||||
QSharedData(other),
|
||||
resources(other.resources)
|
||||
{}
|
||||
|
||||
bool operator ==(const QMediaContentPrivate &other) const
|
||||
{
|
||||
return resources == other.resources;
|
||||
}
|
||||
|
||||
QMediaResourceList resources;
|
||||
private:
|
||||
QMediaContentPrivate& operator=(const QMediaContentPrivate &other);
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
\class QMediaContent
|
||||
|
||||
\brief The QMediaContent class provides access to the resources relating to a media content.
|
||||
|
||||
\inmodule QtMultimedia
|
||||
\ingroup multimedia
|
||||
\since 1.0
|
||||
|
||||
QMediaContent is used within the multimedia framework as the logical handle
|
||||
to media content. A QMediaContent object is composed of one or more
|
||||
\l {QMediaResource}s where each resource provides the URL and format
|
||||
information of a different encoding of the content.
|
||||
|
||||
A non-null QMediaContent will always have a primary or canonical reference to
|
||||
the content available through the canonicalUrl() or canonicalResource()
|
||||
methods, any additional resources are optional.
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
Constructs a null QMediaContent.
|
||||
*/
|
||||
|
||||
QMediaContent::QMediaContent()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a media content with \a url providing a reference to the content.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QMediaContent::QMediaContent(const QUrl &url):
|
||||
d(new QMediaContentPrivate)
|
||||
{
|
||||
d->resources << QMediaResource(url);
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a media content with \a request providing a reference to the content.
|
||||
|
||||
This constructor can be used to reference media content via network protocols such as HTTP.
|
||||
This may include additional information required to obtain the resource, such as Cookies or HTTP headers.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QMediaContent::QMediaContent(const QNetworkRequest &request):
|
||||
d(new QMediaContentPrivate)
|
||||
{
|
||||
d->resources << QMediaResource(request);
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a media content with \a resource providing a reference to the content.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QMediaContent::QMediaContent(const QMediaResource &resource):
|
||||
d(new QMediaContentPrivate)
|
||||
{
|
||||
d->resources << resource;
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a media content with \a resources providing a reference to the content.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QMediaContent::QMediaContent(const QMediaResourceList &resources):
|
||||
d(new QMediaContentPrivate(resources))
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a copy of the media content \a other.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QMediaContent::QMediaContent(const QMediaContent &other):
|
||||
d(other.d)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the media content object.
|
||||
*/
|
||||
|
||||
QMediaContent::~QMediaContent()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Assigns the value of \a other to this media content.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QMediaContent& QMediaContent::operator=(const QMediaContent &other)
|
||||
{
|
||||
d = other.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns true if \a other is equivalent to this media content; false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
bool QMediaContent::operator==(const QMediaContent &other) const
|
||||
{
|
||||
return (d.constData() == 0 && other.d.constData() == 0) ||
|
||||
(d.constData() != 0 && other.d.constData() != 0 &&
|
||||
*d.constData() == *other.d.constData());
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns true if \a other is not equivalent to this media content; false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
bool QMediaContent::operator!=(const QMediaContent &other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns true if this media content is null (uninitialized); false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
bool QMediaContent::isNull() const
|
||||
{
|
||||
return d.constData() == 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a QUrl that represents that canonical resource for this media content.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QUrl QMediaContent::canonicalUrl() const
|
||||
{
|
||||
return canonicalResource().url();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a QNetworkRequest that represents that canonical resource for this media content.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QNetworkRequest QMediaContent::canonicalRequest() const
|
||||
{
|
||||
return canonicalResource().request();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a QMediaResource that represents that canonical resource for this media content.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QMediaResource QMediaContent::canonicalResource() const
|
||||
{
|
||||
return d.constData() != 0
|
||||
? d->resources.value(0)
|
||||
: QMediaResource();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a list of alternative resources for this media content. The first item in this list
|
||||
is always the canonical resource.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QMediaResourceList QMediaContent::resources() const
|
||||
{
|
||||
return d.constData() != 0
|
||||
? d->resources
|
||||
: QMediaResourceList();
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
95
src/multimedia/playback/qmediacontent.h
Normal file
95
src/multimedia/playback/qmediacontent.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMEDIACONTENT_H
|
||||
#define QMEDIACONTENT_H
|
||||
|
||||
#include <QtCore/qmetatype.h>
|
||||
#include <QtCore/qshareddata.h>
|
||||
|
||||
#include "qmediaresource.h"
|
||||
|
||||
#include <qtmultimediadefs.h>
|
||||
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
|
||||
class QMediaContentPrivate;
|
||||
class Q_MULTIMEDIA_EXPORT QMediaContent
|
||||
{
|
||||
public:
|
||||
QMediaContent();
|
||||
QMediaContent(const QUrl &contentUrl);
|
||||
QMediaContent(const QNetworkRequest &contentRequest);
|
||||
QMediaContent(const QMediaResource &contentResource);
|
||||
QMediaContent(const QMediaResourceList &resources);
|
||||
QMediaContent(const QMediaContent &other);
|
||||
~QMediaContent();
|
||||
|
||||
QMediaContent& operator=(const QMediaContent &other);
|
||||
|
||||
bool operator==(const QMediaContent &other) const;
|
||||
bool operator!=(const QMediaContent &other) const;
|
||||
|
||||
bool isNull() const;
|
||||
|
||||
QUrl canonicalUrl() const;
|
||||
QNetworkRequest canonicalRequest() const;
|
||||
QMediaResource canonicalResource() const;
|
||||
|
||||
QMediaResourceList resources() const;
|
||||
|
||||
private:
|
||||
QSharedDataPointer<QMediaContentPrivate> d;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(QMediaContent)
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QMEDIACONTENT_H
|
||||
1139
src/multimedia/playback/qmediaplayer.cpp
Normal file
1139
src/multimedia/playback/qmediaplayer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
227
src/multimedia/playback/qmediaplayer.h
Normal file
227
src/multimedia/playback/qmediaplayer.h
Normal file
@@ -0,0 +1,227 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMEDIAPLAYER_H
|
||||
#define QMEDIAPLAYER_H
|
||||
|
||||
|
||||
#include "qmediaserviceprovider.h"
|
||||
#include "qmediaobject.h"
|
||||
#include "qmediacontent.h"
|
||||
#include "qmediaenumdebug.h"
|
||||
|
||||
#include <QtNetwork/qnetworkconfiguration.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
|
||||
class QAbstractVideoSurface;
|
||||
class QMediaPlaylist;
|
||||
class QVideoWidget;
|
||||
class QGraphicsVideoItem;
|
||||
|
||||
class QMediaPlayerPrivate;
|
||||
class Q_MULTIMEDIA_EXPORT QMediaPlayer : public QMediaObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QMediaContent media READ media WRITE setMedia NOTIFY mediaChanged)
|
||||
Q_PROPERTY(QMediaPlaylist * playlist READ playlist WRITE setPlaylist)
|
||||
Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged)
|
||||
Q_PROPERTY(qint64 position READ position WRITE setPosition NOTIFY positionChanged)
|
||||
Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged)
|
||||
Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
|
||||
Q_PROPERTY(int bufferStatus READ bufferStatus NOTIFY bufferStatusChanged)
|
||||
Q_PROPERTY(bool audioAvailable READ isAudioAvailable NOTIFY audioAvailableChanged)
|
||||
Q_PROPERTY(bool videoAvailable READ isVideoAvailable NOTIFY videoAvailableChanged)
|
||||
Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged)
|
||||
Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged)
|
||||
Q_PROPERTY(State state READ state NOTIFY stateChanged)
|
||||
Q_PROPERTY(MediaStatus mediaStatus READ mediaStatus NOTIFY mediaStatusChanged)
|
||||
Q_PROPERTY(QString error READ errorString)
|
||||
Q_ENUMS(State)
|
||||
Q_ENUMS(MediaStatus)
|
||||
Q_ENUMS(Error)
|
||||
|
||||
public:
|
||||
enum State
|
||||
{
|
||||
StoppedState,
|
||||
PlayingState,
|
||||
PausedState
|
||||
};
|
||||
|
||||
enum MediaStatus
|
||||
{
|
||||
UnknownMediaStatus,
|
||||
NoMedia,
|
||||
LoadingMedia,
|
||||
LoadedMedia,
|
||||
StalledMedia,
|
||||
BufferingMedia,
|
||||
BufferedMedia,
|
||||
EndOfMedia,
|
||||
InvalidMedia
|
||||
};
|
||||
|
||||
enum Flag
|
||||
{
|
||||
LowLatency = 0x01,
|
||||
StreamPlayback = 0x02,
|
||||
VideoSurface = 0x04
|
||||
};
|
||||
Q_DECLARE_FLAGS(Flags, Flag)
|
||||
|
||||
enum Error
|
||||
{
|
||||
NoError,
|
||||
ResourceError,
|
||||
FormatError,
|
||||
NetworkError,
|
||||
AccessDeniedError,
|
||||
ServiceMissingError
|
||||
};
|
||||
|
||||
QMediaPlayer(QObject *parent = 0, Flags flags = 0, QMediaServiceProvider *provider = QMediaServiceProvider::defaultServiceProvider());
|
||||
~QMediaPlayer();
|
||||
|
||||
static QtMultimedia::SupportEstimate hasSupport(const QString &mimeType,
|
||||
const QStringList& codecs = QStringList(),
|
||||
Flags flags = 0);
|
||||
static QStringList supportedMimeTypes(Flags flags = 0);
|
||||
|
||||
void setVideoOutput(QVideoWidget *);
|
||||
void setVideoOutput(QGraphicsVideoItem *);
|
||||
void setVideoOutput(QAbstractVideoSurface *surface);
|
||||
|
||||
QMediaContent media() const;
|
||||
const QIODevice *mediaStream() const;
|
||||
QMediaPlaylist *playlist() const;
|
||||
|
||||
State state() const;
|
||||
MediaStatus mediaStatus() const;
|
||||
|
||||
qint64 duration() const;
|
||||
qint64 position() const;
|
||||
|
||||
int volume() const;
|
||||
bool isMuted() const;
|
||||
bool isAudioAvailable() const;
|
||||
bool isVideoAvailable() const;
|
||||
|
||||
int bufferStatus() const;
|
||||
|
||||
bool isSeekable() const;
|
||||
qreal playbackRate() const;
|
||||
|
||||
Error error() const;
|
||||
QString errorString() const;
|
||||
|
||||
QNetworkConfiguration currentNetworkConfiguration() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void play();
|
||||
void pause();
|
||||
void stop();
|
||||
|
||||
void setPosition(qint64 position);
|
||||
void setVolume(int volume);
|
||||
void setMuted(bool muted);
|
||||
|
||||
void setPlaybackRate(qreal rate);
|
||||
|
||||
void setMedia(const QMediaContent &media, QIODevice *stream = 0);
|
||||
void setPlaylist(QMediaPlaylist *playlist);
|
||||
|
||||
void setNetworkConfigurations(const QList<QNetworkConfiguration> &configurations);
|
||||
|
||||
Q_SIGNALS:
|
||||
void mediaChanged(const QMediaContent &media);
|
||||
|
||||
void stateChanged(QMediaPlayer::State newState);
|
||||
void mediaStatusChanged(QMediaPlayer::MediaStatus status);
|
||||
|
||||
void durationChanged(qint64 duration);
|
||||
void positionChanged(qint64 position);
|
||||
|
||||
void volumeChanged(int volume);
|
||||
void mutedChanged(bool muted);
|
||||
void audioAvailableChanged(bool available);
|
||||
void videoAvailableChanged(bool videoAvailable);
|
||||
|
||||
void bufferStatusChanged(int percentFilled);
|
||||
|
||||
void seekableChanged(bool seekable);
|
||||
void playbackRateChanged(qreal rate);
|
||||
|
||||
void error(QMediaPlayer::Error error);
|
||||
|
||||
void networkConfigurationChanged(const QNetworkConfiguration &configuration);
|
||||
public:
|
||||
virtual bool bind(QObject *);
|
||||
virtual void unbind(QObject *);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QMediaPlayer)
|
||||
Q_DECLARE_PRIVATE(QMediaPlayer)
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_stateChanged(QMediaPlayer::State))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_error(int, const QString &))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_updateMedia(const QMediaContent&))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_playlistDestroyed())
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(QMediaPlayer::State)
|
||||
Q_DECLARE_METATYPE(QMediaPlayer::MediaStatus)
|
||||
Q_DECLARE_METATYPE(QMediaPlayer::Error)
|
||||
|
||||
Q_MEDIA_ENUM_DEBUG(QMediaPlayer, State)
|
||||
Q_MEDIA_ENUM_DEBUG(QMediaPlayer, MediaStatus)
|
||||
Q_MEDIA_ENUM_DEBUG(QMediaPlayer, Error)
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QMEDIAPLAYER_H
|
||||
769
src/multimedia/playback/qmediaplaylist.cpp
Normal file
769
src/multimedia/playback/qmediaplaylist.cpp
Normal file
@@ -0,0 +1,769 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmediaplaylist.h"
|
||||
#include "qmediaplaylist_p.h"
|
||||
#include "qmediaplaylistprovider.h"
|
||||
#include "qlocalmediaplaylistprovider.h"
|
||||
#include "qmediaplaylistioplugin.h"
|
||||
#include "qmediaservice.h"
|
||||
#include "qmediaplaylistcontrol.h"
|
||||
#include "qmediaplayercontrol.h"
|
||||
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qfile.h>
|
||||
#include <QtCore/qurl.h>
|
||||
#include <QtCore/qcoreevent.h>
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
|
||||
#include "qmediapluginloader_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, playlistIOLoader,
|
||||
(QMediaPlaylistIOInterface_iid, QLatin1String("playlistformats"), Qt::CaseInsensitive))
|
||||
|
||||
namespace
|
||||
{
|
||||
class QMediaPlaylistPrivateRegisterMetaTypes
|
||||
{
|
||||
public:
|
||||
QMediaPlaylistPrivateRegisterMetaTypes()
|
||||
{
|
||||
qRegisterMetaType<QMediaPlaylist::Error>();
|
||||
qRegisterMetaType<QMediaPlaylist::PlaybackMode>();
|
||||
}
|
||||
} _registerMetaTypes;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\class QMediaPlaylist
|
||||
\inmodule QtMultimedia
|
||||
\ingroup multimedia
|
||||
\since 1.0
|
||||
|
||||
|
||||
\brief The QMediaPlaylist class provides a list of media content to play.
|
||||
|
||||
QMediaPlaylist is intended to be used with other media objects,
|
||||
like QMediaPlayer or QMediaImageViewer.
|
||||
|
||||
QMediaPlaylist allows to access the service intrinsic playlist functionality
|
||||
if available, otherwise it provides the the local memory playlist implementation.
|
||||
|
||||
\snippet doc/src/snippets/multimedia-snippets/media.cpp Movie playlist
|
||||
|
||||
Depending on playlist source implementation, most of the playlist mutating
|
||||
operations can be asynchronous.
|
||||
|
||||
\sa QMediaContent
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\enum QMediaPlaylist::PlaybackMode
|
||||
|
||||
The QMediaPlaylist::PlaybackMode describes the order items in playlist are played.
|
||||
|
||||
\value CurrentItemOnce The current item is played only once.
|
||||
|
||||
\value CurrentItemInLoop The current item is played repeatedly in a loop.
|
||||
|
||||
\value Sequential Playback starts from the current and moves through each successive item until the last is reached and then stops.
|
||||
The next item is a null item when the last one is currently playing.
|
||||
|
||||
\value Loop Playback restarts at the first item after the last has finished playing.
|
||||
|
||||
\value Random Play items in random order.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
Create a new playlist object for with the given \a parent.
|
||||
*/
|
||||
|
||||
QMediaPlaylist::QMediaPlaylist(QObject *parent)
|
||||
: QObject(parent)
|
||||
, d_ptr(new QMediaPlaylistPrivate)
|
||||
{
|
||||
Q_D(QMediaPlaylist);
|
||||
|
||||
d->q_ptr = this;
|
||||
d->localPlaylistControl = new QLocalMediaPlaylistControl(this);
|
||||
|
||||
setMediaObject(0);
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the playlist.
|
||||
*/
|
||||
|
||||
QMediaPlaylist::~QMediaPlaylist()
|
||||
{
|
||||
Q_D(QMediaPlaylist);
|
||||
|
||||
if (d->mediaObject)
|
||||
d->mediaObject->unbind(this);
|
||||
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the QMediaObject instance that this QMediaPlaylist is bound too,
|
||||
or 0 otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
QMediaObject *QMediaPlaylist::mediaObject() const
|
||||
{
|
||||
return d_func()->mediaObject;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
If \a mediaObject is null or doesn't have an intrinsic playlist,
|
||||
internal local memory playlist source will be created.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylist::setMediaObject(QMediaObject *mediaObject)
|
||||
{
|
||||
Q_D(QMediaPlaylist);
|
||||
|
||||
if (mediaObject && mediaObject == d->mediaObject)
|
||||
return true;
|
||||
|
||||
QMediaService *service = mediaObject
|
||||
? mediaObject->service() : 0;
|
||||
|
||||
QMediaPlaylistControl *newControl = 0;
|
||||
|
||||
if (service)
|
||||
newControl = qobject_cast<QMediaPlaylistControl*>(service->requestControl(QMediaPlaylistControl_iid));
|
||||
|
||||
if (!newControl)
|
||||
newControl = d->localPlaylistControl;
|
||||
|
||||
if (d->control != newControl) {
|
||||
int oldSize = 0;
|
||||
if (d->control) {
|
||||
QMediaPlaylistProvider *playlist = d->control->playlistProvider();
|
||||
oldSize = playlist->mediaCount();
|
||||
disconnect(playlist, SIGNAL(loadFailed(QMediaPlaylist::Error,QString)),
|
||||
this, SLOT(_q_loadFailed(QMediaPlaylist::Error,QString)));
|
||||
|
||||
disconnect(playlist, SIGNAL(mediaChanged(int,int)), this, SIGNAL(mediaChanged(int,int)));
|
||||
disconnect(playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SIGNAL(mediaAboutToBeInserted(int,int)));
|
||||
disconnect(playlist, SIGNAL(mediaInserted(int,int)), this, SIGNAL(mediaInserted(int,int)));
|
||||
disconnect(playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SIGNAL(mediaAboutToBeRemoved(int,int)));
|
||||
disconnect(playlist, SIGNAL(mediaRemoved(int,int)), this, SIGNAL(mediaRemoved(int,int)));
|
||||
|
||||
disconnect(playlist, SIGNAL(loaded()), this, SIGNAL(loaded()));
|
||||
|
||||
disconnect(d->control, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)),
|
||||
this, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)));
|
||||
disconnect(d->control, SIGNAL(currentIndexChanged(int)),
|
||||
this, SIGNAL(currentIndexChanged(int)));
|
||||
disconnect(d->control, SIGNAL(currentMediaChanged(QMediaContent)),
|
||||
this, SIGNAL(currentMediaChanged(QMediaContent)));
|
||||
|
||||
if (d->mediaObject)
|
||||
d->mediaObject->service()->releaseControl(d->control);
|
||||
}
|
||||
|
||||
d->control = newControl;
|
||||
QMediaPlaylistProvider *playlist = d->control->playlistProvider();
|
||||
connect(playlist, SIGNAL(loadFailed(QMediaPlaylist::Error,QString)),
|
||||
this, SLOT(_q_loadFailed(QMediaPlaylist::Error,QString)));
|
||||
|
||||
connect(playlist, SIGNAL(mediaChanged(int,int)), this, SIGNAL(mediaChanged(int,int)));
|
||||
connect(playlist, SIGNAL(mediaAboutToBeInserted(int,int)), this, SIGNAL(mediaAboutToBeInserted(int,int)));
|
||||
connect(playlist, SIGNAL(mediaInserted(int,int)), this, SIGNAL(mediaInserted(int,int)));
|
||||
connect(playlist, SIGNAL(mediaAboutToBeRemoved(int,int)), this, SIGNAL(mediaAboutToBeRemoved(int,int)));
|
||||
connect(playlist, SIGNAL(mediaRemoved(int,int)), this, SIGNAL(mediaRemoved(int,int)));
|
||||
|
||||
connect(playlist, SIGNAL(loaded()), this, SIGNAL(loaded()));
|
||||
|
||||
connect(d->control, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)),
|
||||
this, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)));
|
||||
connect(d->control, SIGNAL(currentIndexChanged(int)),
|
||||
this, SIGNAL(currentIndexChanged(int)));
|
||||
connect(d->control, SIGNAL(currentMediaChanged(QMediaContent)),
|
||||
this, SIGNAL(currentMediaChanged(QMediaContent)));
|
||||
|
||||
if (oldSize)
|
||||
emit mediaRemoved(0, oldSize-1);
|
||||
|
||||
if (playlist->mediaCount()) {
|
||||
emit mediaAboutToBeInserted(0,playlist->mediaCount()-1);
|
||||
emit mediaInserted(0,playlist->mediaCount()-1);
|
||||
}
|
||||
}
|
||||
|
||||
d->mediaObject = mediaObject;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\property QMediaPlaylist::playbackMode
|
||||
|
||||
This property defines the order, items in playlist are played.
|
||||
|
||||
\since 1.0
|
||||
\sa QMediaPlaylist::PlaybackMode
|
||||
*/
|
||||
|
||||
QMediaPlaylist::PlaybackMode QMediaPlaylist::playbackMode() const
|
||||
{
|
||||
return d_func()->control->playbackMode();
|
||||
}
|
||||
|
||||
void QMediaPlaylist::setPlaybackMode(QMediaPlaylist::PlaybackMode mode)
|
||||
{
|
||||
Q_D(QMediaPlaylist);
|
||||
d->control->setPlaybackMode(mode);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns position of the current media content in the playlist.
|
||||
\since 1.0
|
||||
*/
|
||||
int QMediaPlaylist::currentIndex() const
|
||||
{
|
||||
return d_func()->control->currentIndex();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the current media content.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QMediaContent QMediaPlaylist::currentMedia() const
|
||||
{
|
||||
return d_func()->playlist()->media(currentIndex());
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the index of the item, which would be current after calling next()
|
||||
\a steps times.
|
||||
|
||||
Returned value depends on the size of playlist, current position
|
||||
and playback mode.
|
||||
|
||||
\since 1.0
|
||||
\sa QMediaPlaylist::playbackMode
|
||||
*/
|
||||
int QMediaPlaylist::nextIndex(int steps) const
|
||||
{
|
||||
return d_func()->control->nextIndex(steps);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the index of the item, which would be current after calling previous()
|
||||
\a steps times.
|
||||
|
||||
\since 1.0
|
||||
\sa QMediaPlaylist::playbackMode
|
||||
*/
|
||||
|
||||
int QMediaPlaylist::previousIndex(int steps) const
|
||||
{
|
||||
return d_func()->control->previousIndex(steps);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Returns the number of items in the playlist.
|
||||
|
||||
\since 1.0
|
||||
\sa isEmpty()
|
||||
*/
|
||||
int QMediaPlaylist::mediaCount() const
|
||||
{
|
||||
return d_func()->playlist()->mediaCount();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns true if the playlist contains no items; otherwise returns false.
|
||||
|
||||
\since 1.0
|
||||
\sa mediaCount()
|
||||
*/
|
||||
bool QMediaPlaylist::isEmpty() const
|
||||
{
|
||||
return mediaCount() == 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns true if the playlist can be modified; otherwise returns false.
|
||||
|
||||
\since 1.0
|
||||
\sa mediaCount()
|
||||
*/
|
||||
bool QMediaPlaylist::isReadOnly() const
|
||||
{
|
||||
return d_func()->playlist()->isReadOnly();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the media content at \a index in the playlist.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QMediaContent QMediaPlaylist::media(int index) const
|
||||
{
|
||||
return d_func()->playlist()->media(index);
|
||||
}
|
||||
|
||||
/*!
|
||||
Append the media \a content to the playlist.
|
||||
|
||||
Returns true if the operation is successful, otherwise return false.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylist::addMedia(const QMediaContent &content)
|
||||
{
|
||||
return d_func()->control->playlistProvider()->addMedia(content);
|
||||
}
|
||||
|
||||
/*!
|
||||
Append multiple media content \a items to the playlist.
|
||||
|
||||
Returns true if the operation is successful, otherwise return false.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylist::addMedia(const QList<QMediaContent> &items)
|
||||
{
|
||||
return d_func()->control->playlistProvider()->addMedia(items);
|
||||
}
|
||||
|
||||
/*!
|
||||
Insert the media \a content to the playlist at position \a pos.
|
||||
|
||||
Returns true if the operation is successful, otherwise false.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
bool QMediaPlaylist::insertMedia(int pos, const QMediaContent &content)
|
||||
{
|
||||
return d_func()->playlist()->insertMedia(pos, content);
|
||||
}
|
||||
|
||||
/*!
|
||||
Insert multiple media content \a items to the playlist at position \a pos.
|
||||
|
||||
Returns true if the operation is successful, otherwise false.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
bool QMediaPlaylist::insertMedia(int pos, const QList<QMediaContent> &items)
|
||||
{
|
||||
return d_func()->playlist()->insertMedia(pos, items);
|
||||
}
|
||||
|
||||
/*!
|
||||
Remove the item from the playlist at position \a pos.
|
||||
|
||||
Returns true if the operation is successful, otherwise return false.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylist::removeMedia(int pos)
|
||||
{
|
||||
Q_D(QMediaPlaylist);
|
||||
return d->playlist()->removeMedia(pos);
|
||||
}
|
||||
|
||||
/*!
|
||||
Remove items in the playlist from \a start to \a end inclusive.
|
||||
|
||||
Returns true if the operation is successful, otherwise return false.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylist::removeMedia(int start, int end)
|
||||
{
|
||||
Q_D(QMediaPlaylist);
|
||||
return d->playlist()->removeMedia(start, end);
|
||||
}
|
||||
|
||||
/*!
|
||||
Remove all the items from the playlist.
|
||||
|
||||
Returns true if the operation is successful, otherwise return false.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylist::clear()
|
||||
{
|
||||
Q_D(QMediaPlaylist);
|
||||
return d->playlist()->clear();
|
||||
}
|
||||
|
||||
bool QMediaPlaylistPrivate::readItems(QMediaPlaylistReader *reader)
|
||||
{
|
||||
while (!reader->atEnd())
|
||||
playlist()->addMedia(reader->readItem());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QMediaPlaylistPrivate::writeItems(QMediaPlaylistWriter *writer)
|
||||
{
|
||||
for (int i=0; i<playlist()->mediaCount(); i++) {
|
||||
if (!writer->writeItem(playlist()->media(i)))
|
||||
return false;
|
||||
}
|
||||
writer->close();
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
Load playlist from \a location. If \a format is specified, it is used,
|
||||
otherwise format is guessed from location name and data.
|
||||
|
||||
New items are appended to playlist.
|
||||
|
||||
QMediaPlaylist::loaded() signal is emitted if playlist was loaded successfully,
|
||||
otherwise the playlist emits loadFailed().
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaPlaylist::load(const QUrl &location, const char *format)
|
||||
{
|
||||
Q_D(QMediaPlaylist);
|
||||
|
||||
d->error = NoError;
|
||||
d->errorString.clear();
|
||||
|
||||
if (d->playlist()->load(location,format))
|
||||
return;
|
||||
|
||||
if (isReadOnly()) {
|
||||
d->error = AccessDeniedError;
|
||||
d->errorString = tr("Could not add items to read only playlist.");
|
||||
emit loadFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (QString const& key, playlistIOLoader()->keys()) {
|
||||
QMediaPlaylistIOInterface* plugin = qobject_cast<QMediaPlaylistIOInterface*>(playlistIOLoader()->instance(key));
|
||||
if (plugin && plugin->canRead(location,format)) {
|
||||
QMediaPlaylistReader *reader = plugin->createReader(location,QByteArray(format));
|
||||
if (reader && d->readItems(reader)) {
|
||||
delete reader;
|
||||
emit loaded();
|
||||
return;
|
||||
}
|
||||
delete reader;
|
||||
}
|
||||
}
|
||||
|
||||
d->error = FormatNotSupportedError;
|
||||
d->errorString = tr("Playlist format is not supported");
|
||||
emit loadFailed();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*!
|
||||
Load playlist from QIODevice \a device. If \a format is specified, it is used,
|
||||
otherwise format is guessed from device data.
|
||||
|
||||
New items are appended to playlist.
|
||||
|
||||
QMediaPlaylist::loaded() signal is emitted if playlist was loaded successfully,
|
||||
otherwise the playlist emits loadFailed().
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaPlaylist::load(QIODevice * device, const char *format)
|
||||
{
|
||||
Q_D(QMediaPlaylist);
|
||||
|
||||
d->error = NoError;
|
||||
d->errorString.clear();
|
||||
|
||||
if (d->playlist()->load(device,format))
|
||||
return;
|
||||
|
||||
if (isReadOnly()) {
|
||||
d->error = AccessDeniedError;
|
||||
d->errorString = tr("Could not add items to read only playlist.");
|
||||
emit loadFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (QString const& key, playlistIOLoader()->keys()) {
|
||||
QMediaPlaylistIOInterface* plugin = qobject_cast<QMediaPlaylistIOInterface*>(playlistIOLoader()->instance(key));
|
||||
if (plugin && plugin->canRead(device,format)) {
|
||||
QMediaPlaylistReader *reader = plugin->createReader(device,QByteArray(format));
|
||||
if (reader && d->readItems(reader)) {
|
||||
delete reader;
|
||||
emit loaded();
|
||||
return;
|
||||
}
|
||||
delete reader;
|
||||
}
|
||||
}
|
||||
|
||||
d->error = FormatNotSupportedError;
|
||||
d->errorString = tr("Playlist format is not supported");
|
||||
emit loadFailed();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*!
|
||||
Save playlist to \a location. If \a format is specified, it is used,
|
||||
otherwise format is guessed from location name.
|
||||
|
||||
Returns true if playlist was saved successfully, otherwise returns false.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylist::save(const QUrl &location, const char *format)
|
||||
{
|
||||
Q_D(QMediaPlaylist);
|
||||
|
||||
d->error = NoError;
|
||||
d->errorString.clear();
|
||||
|
||||
if (d->playlist()->save(location,format))
|
||||
return true;
|
||||
|
||||
QFile file(location.toLocalFile());
|
||||
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||
d->error = AccessDeniedError;
|
||||
d->errorString = tr("The file could not be accessed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return save(&file, format);
|
||||
}
|
||||
|
||||
/*!
|
||||
Save playlist to QIODevice \a device using format \a format.
|
||||
|
||||
Returns true if playlist was saved successfully, otherwise returns false.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylist::save(QIODevice * device, const char *format)
|
||||
{
|
||||
Q_D(QMediaPlaylist);
|
||||
|
||||
d->error = NoError;
|
||||
d->errorString.clear();
|
||||
|
||||
if (d->playlist()->save(device,format))
|
||||
return true;
|
||||
|
||||
foreach (QString const& key, playlistIOLoader()->keys()) {
|
||||
QMediaPlaylistIOInterface* plugin = qobject_cast<QMediaPlaylistIOInterface*>(playlistIOLoader()->instance(key));
|
||||
if (plugin && plugin->canWrite(device,format)) {
|
||||
QMediaPlaylistWriter *writer = plugin->createWriter(device,QByteArray(format));
|
||||
if (writer && d->writeItems(writer)) {
|
||||
delete writer;
|
||||
return true;
|
||||
}
|
||||
delete writer;
|
||||
}
|
||||
}
|
||||
|
||||
d->error = FormatNotSupportedError;
|
||||
d->errorString = tr("Playlist format is not supported.");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the last error condition.
|
||||
\since 1.0
|
||||
*/
|
||||
QMediaPlaylist::Error QMediaPlaylist::error() const
|
||||
{
|
||||
return d_func()->error;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the string describing the last error condition.
|
||||
\since 1.0
|
||||
*/
|
||||
QString QMediaPlaylist::errorString() const
|
||||
{
|
||||
return d_func()->errorString;
|
||||
}
|
||||
|
||||
/*!
|
||||
Shuffle items in the playlist.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaPlaylist::shuffle()
|
||||
{
|
||||
d_func()->playlist()->shuffle();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Advance to the next media content in playlist.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaPlaylist::next()
|
||||
{
|
||||
d_func()->control->next();
|
||||
}
|
||||
|
||||
/*!
|
||||
Return to the previous media content in playlist.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaPlaylist::previous()
|
||||
{
|
||||
d_func()->control->previous();
|
||||
}
|
||||
|
||||
/*!
|
||||
Activate media content from playlist at position \a playlistPosition.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
void QMediaPlaylist::setCurrentIndex(int playlistPosition)
|
||||
{
|
||||
d_func()->control->setCurrentIndex(playlistPosition);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QMediaPlaylist::mediaInserted(int start, int end)
|
||||
|
||||
This signal is emitted after media has been inserted into the playlist.
|
||||
The new items are those between \a start and \a end inclusive.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QMediaPlaylist::mediaRemoved(int start, int end)
|
||||
|
||||
This signal is emitted after media has been removed from the playlist.
|
||||
The removed items are those between \a start and \a end inclusive.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QMediaPlaylist::mediaChanged(int start, int end)
|
||||
|
||||
This signal is emitted after media has been changed in the playlist
|
||||
between \a start and \a end positions inclusive.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QMediaPlaylist::currentIndexChanged(int position)
|
||||
|
||||
Signal emitted when playlist position changed to \a position.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QMediaPlaylist::playbackModeChanged(QMediaPlaylist::PlaybackMode mode)
|
||||
|
||||
Signal emitted when playback mode changed to \a mode.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QMediaPlaylist::mediaAboutToBeInserted(int start, int end)
|
||||
|
||||
Signal emitted when items are to be inserted at \a start and ending at \a end.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QMediaPlaylist::mediaAboutToBeRemoved(int start, int end)
|
||||
|
||||
Signal emitted when item are to be deleted at \a start and ending at \a end.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QMediaPlaylist::currentMediaChanged(const QMediaContent &content)
|
||||
|
||||
Signal emitted when current media changes to \a content.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QMediaPlaylist::currentIndex
|
||||
\brief Current position.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QMediaPlaylist::currentMedia
|
||||
\brief Current media content.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylist::loaded()
|
||||
|
||||
Signal emitted when playlist finished loading.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylist::loadFailed()
|
||||
|
||||
Signal emitted if failed to load playlist.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QMediaPlaylist::Error
|
||||
|
||||
This enum describes the QMediaPlaylist error codes.
|
||||
|
||||
\value NoError No errors.
|
||||
\value FormatError Format error.
|
||||
\value FormatNotSupportedError Format not supported.
|
||||
\value NetworkError Network error.
|
||||
\value AccessDeniedError Access denied error.
|
||||
*/
|
||||
|
||||
#include "moc_qmediaplaylist.cpp"
|
||||
#include "moc_qmediaplaylist_p.cpp"
|
||||
QT_END_NAMESPACE
|
||||
|
||||
154
src/multimedia/playback/qmediaplaylist.h
Normal file
154
src/multimedia/playback/qmediaplaylist.h
Normal file
@@ -0,0 +1,154 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMEDIAPLAYLIST_H
|
||||
#define QMEDIAPLAYLIST_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
#include <qmediacontent.h>
|
||||
#include <qmediaobject.h>
|
||||
#include <qmediabindableinterface.h>
|
||||
#include <qmediaenumdebug.h>
|
||||
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
|
||||
class QMediaPlaylistProvider;
|
||||
|
||||
class QMediaPlaylistPrivate;
|
||||
class Q_MULTIMEDIA_EXPORT QMediaPlaylist : public QObject, public QMediaBindableInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaBindableInterface)
|
||||
Q_PROPERTY(QMediaPlaylist::PlaybackMode playbackMode READ playbackMode WRITE setPlaybackMode NOTIFY playbackModeChanged)
|
||||
Q_PROPERTY(QMediaContent currentMedia READ currentMedia NOTIFY currentMediaChanged)
|
||||
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
|
||||
Q_ENUMS(PlaybackMode Error)
|
||||
|
||||
public:
|
||||
enum PlaybackMode { CurrentItemOnce, CurrentItemInLoop, Sequential, Loop, Random };
|
||||
enum Error { NoError, FormatError, FormatNotSupportedError, NetworkError, AccessDeniedError };
|
||||
|
||||
QMediaPlaylist(QObject *parent = 0);
|
||||
virtual ~QMediaPlaylist();
|
||||
|
||||
QMediaObject *mediaObject() const;
|
||||
|
||||
PlaybackMode playbackMode() const;
|
||||
void setPlaybackMode(PlaybackMode mode);
|
||||
|
||||
int currentIndex() const;
|
||||
QMediaContent currentMedia() const;
|
||||
|
||||
int nextIndex(int steps = 1) const;
|
||||
int previousIndex(int steps = 1) const;
|
||||
|
||||
QMediaContent media(int index) const;
|
||||
|
||||
int mediaCount() const;
|
||||
bool isEmpty() const;
|
||||
bool isReadOnly() const;
|
||||
|
||||
bool addMedia(const QMediaContent &content);
|
||||
bool addMedia(const QList<QMediaContent> &items);
|
||||
bool insertMedia(int index, const QMediaContent &content);
|
||||
bool insertMedia(int index, const QList<QMediaContent> &items);
|
||||
bool removeMedia(int pos);
|
||||
bool removeMedia(int start, int end);
|
||||
bool clear();
|
||||
|
||||
void load(const QUrl &location, const char *format = 0);
|
||||
void load(QIODevice * device, const char *format = 0);
|
||||
|
||||
bool save(const QUrl &location, const char *format = 0);
|
||||
bool save(QIODevice * device, const char *format);
|
||||
|
||||
Error error() const;
|
||||
QString errorString() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void shuffle();
|
||||
|
||||
void next();
|
||||
void previous();
|
||||
|
||||
void setCurrentIndex(int index);
|
||||
|
||||
Q_SIGNALS:
|
||||
void currentIndexChanged(int index);
|
||||
void playbackModeChanged(QMediaPlaylist::PlaybackMode mode);
|
||||
void currentMediaChanged(const QMediaContent&);
|
||||
|
||||
void mediaAboutToBeInserted(int start, int end);
|
||||
void mediaInserted(int start, int end);
|
||||
void mediaAboutToBeRemoved(int start, int end);
|
||||
void mediaRemoved(int start, int end);
|
||||
void mediaChanged(int start, int end);
|
||||
|
||||
void loaded();
|
||||
void loadFailed();
|
||||
|
||||
protected:
|
||||
bool setMediaObject(QMediaObject *object);
|
||||
QMediaPlaylistPrivate *d_ptr;
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QMediaPlaylist)
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_loadFailed(QMediaPlaylist::Error, const QString &))
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(QMediaPlaylist::PlaybackMode)
|
||||
Q_DECLARE_METATYPE(QMediaPlaylist::Error)
|
||||
|
||||
Q_MEDIA_ENUM_DEBUG(QMediaPlaylist, PlaybackMode)
|
||||
Q_MEDIA_ENUM_DEBUG(QMediaPlaylist, Error)
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QMEDIAPLAYLIST_H
|
||||
177
src/multimedia/playback/qmediaplaylist_p.h
Normal file
177
src/multimedia/playback/qmediaplaylist_p.h
Normal file
@@ -0,0 +1,177 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMEDIAPLAYLIST_P_H
|
||||
#define QMEDIAPLAYLIST_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qmediaplaylist.h"
|
||||
#include "qmediaplaylistcontrol.h"
|
||||
#include "qmediaplayer.h"
|
||||
#include "qmediaplayercontrol.h"
|
||||
#include "qlocalmediaplaylistprovider.h"
|
||||
#include "qmediaobject_p.h"
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
#ifdef Q_MOC_RUN
|
||||
# pragma Q_MOC_EXPAND_MACROS
|
||||
#endif
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
|
||||
class QMediaPlaylistControl;
|
||||
class QMediaPlaylistProvider;
|
||||
class QMediaPlaylistReader;
|
||||
class QMediaPlaylistWriter;
|
||||
class QMediaPlayerControl;
|
||||
|
||||
class QMediaPlaylistPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QMediaPlaylist)
|
||||
public:
|
||||
QMediaPlaylistPrivate()
|
||||
:mediaObject(0),
|
||||
control(0),
|
||||
localPlaylistControl(0),
|
||||
error(QMediaPlaylist::NoError)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~QMediaPlaylistPrivate() {}
|
||||
|
||||
void _q_loadFailed(QMediaPlaylist::Error error, const QString &errorString)
|
||||
{
|
||||
this->error = error;
|
||||
this->errorString = errorString;
|
||||
|
||||
emit q_ptr->loadFailed();
|
||||
}
|
||||
|
||||
void _q_mediaObjectDeleted()
|
||||
{
|
||||
Q_Q(QMediaPlaylist);
|
||||
mediaObject = 0;
|
||||
if (control != localPlaylistControl)
|
||||
control = 0;
|
||||
q->setMediaObject(0);
|
||||
}
|
||||
|
||||
QMediaObject *mediaObject;
|
||||
|
||||
QMediaPlaylistControl *control;
|
||||
QMediaPlaylistProvider *playlist() const { return control->playlistProvider(); }
|
||||
|
||||
QMediaPlaylistControl *localPlaylistControl;
|
||||
|
||||
bool readItems(QMediaPlaylistReader *reader);
|
||||
bool writeItems(QMediaPlaylistWriter *writer);
|
||||
|
||||
QMediaPlaylist::Error error;
|
||||
QString errorString;
|
||||
|
||||
QMediaPlaylist *q_ptr;
|
||||
};
|
||||
|
||||
|
||||
class QLocalMediaPlaylistControl : public QMediaPlaylistControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QLocalMediaPlaylistControl(QObject *parent)
|
||||
:QMediaPlaylistControl(parent)
|
||||
{
|
||||
QMediaPlaylistProvider *playlist = new QLocalMediaPlaylistProvider(this);
|
||||
m_navigator = new QMediaPlaylistNavigator(playlist,this);
|
||||
m_navigator->setPlaybackMode(QMediaPlaylist::Sequential);
|
||||
|
||||
connect(m_navigator, SIGNAL(currentIndexChanged(int)), SIGNAL(currentIndexChanged(int)));
|
||||
connect(m_navigator, SIGNAL(activated(QMediaContent)), SIGNAL(currentMediaChanged(QMediaContent)));
|
||||
connect(m_navigator, SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)), SIGNAL(playbackModeChanged(QMediaPlaylist::PlaybackMode)));
|
||||
}
|
||||
|
||||
virtual ~QLocalMediaPlaylistControl() {};
|
||||
|
||||
QMediaPlaylistProvider* playlistProvider() const { return m_navigator->playlist(); }
|
||||
bool setPlaylistProvider(QMediaPlaylistProvider *mediaPlaylist)
|
||||
{
|
||||
m_navigator->setPlaylist(mediaPlaylist);
|
||||
emit playlistProviderChanged();
|
||||
return true;
|
||||
}
|
||||
|
||||
int currentIndex() const { return m_navigator->currentIndex(); }
|
||||
void setCurrentIndex(int position) { m_navigator->jump(position); }
|
||||
int nextIndex(int steps) const { return m_navigator->nextIndex(steps); }
|
||||
int previousIndex(int steps) const { return m_navigator->previousIndex(steps); }
|
||||
|
||||
void next() { m_navigator->next(); }
|
||||
void previous() { m_navigator->previous(); }
|
||||
|
||||
QMediaPlaylist::PlaybackMode playbackMode() const { return m_navigator->playbackMode(); }
|
||||
void setPlaybackMode(QMediaPlaylist::PlaybackMode mode) { m_navigator->setPlaybackMode(mode); }
|
||||
|
||||
private:
|
||||
QMediaPlaylistNavigator *m_navigator;
|
||||
};
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
|
||||
#endif // QMEDIAPLAYLIST_P_H
|
||||
204
src/multimedia/playback/qmediaplaylistioplugin.cpp
Normal file
204
src/multimedia/playback/qmediaplaylistioplugin.cpp
Normal file
@@ -0,0 +1,204 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmediaplaylistioplugin.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QMediaPlaylistReader
|
||||
|
||||
\brief The QMediaPlaylistReader class provides an interface for reading a playlist file.
|
||||
\inmodule QtMultimedia
|
||||
\since 1.0
|
||||
|
||||
\sa QMediaPlaylistIOPlugin
|
||||
*/
|
||||
|
||||
/*!
|
||||
Destroys a media playlist reader.
|
||||
*/
|
||||
QMediaPlaylistReader::~QMediaPlaylistReader()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylistReader::atEnd() const
|
||||
|
||||
Identifies if a playlist reader has reached the end of its input.
|
||||
|
||||
Returns true if the reader has reached the end; and false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylistReader::readItem()
|
||||
|
||||
Reads an item of media from a playlist file.
|
||||
|
||||
Returns the read media, or a null QMediaContent if no more media is available.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylistReader::close()
|
||||
|
||||
Closes a playlist reader's input device.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\class QMediaPlaylistWriter
|
||||
|
||||
\brief The QMediaPlaylistWriter class provides an interface for writing a playlist file.
|
||||
|
||||
\since 1.0
|
||||
\sa QMediaPlaylistIOPlugin
|
||||
*/
|
||||
|
||||
/*!
|
||||
Destroys a media playlist writer.
|
||||
*/
|
||||
QMediaPlaylistWriter::~QMediaPlaylistWriter()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylistWriter::writeItem(const QMediaContent &media)
|
||||
|
||||
Writes an item of \a media to a playlist file.
|
||||
|
||||
Returns true if the media was written successfully; and false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylistWriter::close()
|
||||
|
||||
Finalizes the writing of a playlist and closes the output device.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\class QMediaPlaylistIOPlugin
|
||||
\brief The QMediaPlaylistIOPlugin class provides an interface for media playlist I/O plug-ins.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a media playlist I/O plug-in with the given \a parent.
|
||||
*/
|
||||
QMediaPlaylistIOPlugin::QMediaPlaylistIOPlugin(QObject *parent)
|
||||
:QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys a media playlist I/O plug-in.
|
||||
*/
|
||||
QMediaPlaylistIOPlugin::~QMediaPlaylistIOPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylistIOPlugin::canRead(QIODevice *device, const QByteArray &format) const
|
||||
|
||||
Identifies if plug-in can read \a format data from an I/O \a device.
|
||||
|
||||
Returns true if the data can be read; and false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylistIOPlugin::canRead(const QUrl& location, const QByteArray &format) const
|
||||
|
||||
Identifies if a plug-in can read \a format data from a URL \a location.
|
||||
|
||||
Returns true if the data can be read; and false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylistIOPlugin::canWrite(QIODevice *device, const QByteArray &format) const
|
||||
|
||||
Identifies if a plug-in can write \a format data to an I/O \a device.
|
||||
|
||||
Returns true if the data can be written; and false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylistIOPlugin::keys() const
|
||||
|
||||
Returns a list of format keys supported by a plug-in.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylistIOPlugin::createReader(QIODevice *device, const QByteArray &format)
|
||||
|
||||
Returns a new QMediaPlaylistReader which reads \a format data from an I/O \a device.
|
||||
|
||||
If the device is invalid or the format is unsupported this will return a null pointer.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylistIOPlugin::createReader(const QUrl& location, const QByteArray &format)
|
||||
|
||||
Returns a new QMediaPlaylistReader which reads \a format data from a URL \a location.
|
||||
|
||||
If the location or the format is unsupported this will return a null pointer.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylistIOPlugin::createWriter(QIODevice *device, const QByteArray &format)
|
||||
|
||||
Returns a new QMediaPlaylistWriter which writes \a format data to an I/O \a device.
|
||||
|
||||
If the device is invalid or the format is unsupported this will return a null pointer.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
#include "moc_qmediaplaylistioplugin.cpp"
|
||||
QT_END_NAMESPACE
|
||||
|
||||
126
src/multimedia/playback/qmediaplaylistioplugin.h
Normal file
126
src/multimedia/playback/qmediaplaylistioplugin.h
Normal file
@@ -0,0 +1,126 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMEDIAPLAYLISTIOPLUGIN_H
|
||||
#define QMEDIAPLAYLISTIOPLUGIN_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qplugin.h>
|
||||
#include <QtCore/qfactoryinterface.h>
|
||||
|
||||
#include <qtmultimediadefs.h>
|
||||
|
||||
#include "qmediacontent.h"
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
class QString;
|
||||
class QUrl;
|
||||
class QByteArray;
|
||||
class QIODevice;
|
||||
class QStringList;
|
||||
|
||||
class Q_MULTIMEDIA_EXPORT QMediaPlaylistReader
|
||||
{
|
||||
public:
|
||||
virtual ~QMediaPlaylistReader();
|
||||
|
||||
virtual bool atEnd() const = 0;
|
||||
virtual QMediaContent readItem() = 0;
|
||||
virtual void close() = 0;
|
||||
};
|
||||
|
||||
class Q_MULTIMEDIA_EXPORT QMediaPlaylistWriter
|
||||
{
|
||||
public:
|
||||
virtual ~QMediaPlaylistWriter();
|
||||
|
||||
virtual bool writeItem(const QMediaContent &content) = 0;
|
||||
virtual void close() = 0;
|
||||
};
|
||||
|
||||
struct Q_MULTIMEDIA_EXPORT QMediaPlaylistIOInterface : public QFactoryInterface
|
||||
{
|
||||
virtual bool canRead(QIODevice *device, const QByteArray &format = QByteArray() ) const = 0;
|
||||
virtual bool canRead(const QUrl& location, const QByteArray &format = QByteArray()) const = 0;
|
||||
|
||||
virtual bool canWrite(QIODevice *device, const QByteArray &format) const = 0;
|
||||
|
||||
virtual QMediaPlaylistReader *createReader(QIODevice *device, const QByteArray &format = QByteArray()) = 0;
|
||||
virtual QMediaPlaylistReader *createReader(const QUrl& location, const QByteArray &format = QByteArray()) = 0;
|
||||
|
||||
virtual QMediaPlaylistWriter *createWriter(QIODevice *device, const QByteArray &format) = 0;
|
||||
};
|
||||
|
||||
#define QMediaPlaylistIOInterface_iid "com.nokia.Qt.QMediaPlaylistIOInterface"
|
||||
Q_DECLARE_INTERFACE(QMediaPlaylistIOInterface, QMediaPlaylistIOInterface_iid);
|
||||
|
||||
class Q_MULTIMEDIA_EXPORT QMediaPlaylistIOPlugin : public QObject, public QMediaPlaylistIOInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaPlaylistIOInterface:QFactoryInterface)
|
||||
public:
|
||||
explicit QMediaPlaylistIOPlugin(QObject *parent = 0);
|
||||
virtual ~QMediaPlaylistIOPlugin();
|
||||
|
||||
virtual bool canRead(QIODevice *device, const QByteArray &format = QByteArray() ) const = 0;
|
||||
virtual bool canRead(const QUrl& location, const QByteArray &format = QByteArray()) const = 0;
|
||||
|
||||
virtual bool canWrite(QIODevice *device, const QByteArray &format) const = 0;
|
||||
|
||||
virtual QStringList keys() const = 0;
|
||||
|
||||
virtual QMediaPlaylistReader *createReader(QIODevice *device, const QByteArray &format = QByteArray()) = 0;
|
||||
virtual QMediaPlaylistReader *createReader(const QUrl& location, const QByteArray &format = QByteArray()) = 0;
|
||||
|
||||
virtual QMediaPlaylistWriter *createWriter(QIODevice *device, const QByteArray &format) = 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
|
||||
#endif // QMEDIAPLAYLISTIOPLUGIN_H
|
||||
568
src/multimedia/playback/qmediaplaylistnavigator.cpp
Normal file
568
src/multimedia/playback/qmediaplaylistnavigator.cpp
Normal file
@@ -0,0 +1,568 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmediaplaylistnavigator.h"
|
||||
#include "qmediaplaylistprovider.h"
|
||||
#include "qmediaplaylist.h"
|
||||
#include "qmediaobject_p.h"
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QMediaPlaylistNullProvider : public QMediaPlaylistProvider
|
||||
{
|
||||
public:
|
||||
QMediaPlaylistNullProvider() :QMediaPlaylistProvider() {}
|
||||
virtual ~QMediaPlaylistNullProvider() {}
|
||||
virtual int mediaCount() const {return 0;}
|
||||
virtual QMediaContent media(int) const { return QMediaContent(); }
|
||||
};
|
||||
|
||||
Q_GLOBAL_STATIC(QMediaPlaylistNullProvider, _q_nullMediaPlaylist)
|
||||
|
||||
class QMediaPlaylistNavigatorPrivate
|
||||
{
|
||||
Q_DECLARE_NON_CONST_PUBLIC(QMediaPlaylistNavigator)
|
||||
public:
|
||||
QMediaPlaylistNavigatorPrivate()
|
||||
:playlist(0),
|
||||
currentPos(-1),
|
||||
lastValidPos(-1),
|
||||
playbackMode(QMediaPlaylist::Sequential),
|
||||
randomPositionsOffset(-1)
|
||||
{
|
||||
}
|
||||
|
||||
QMediaPlaylistProvider *playlist;
|
||||
int currentPos;
|
||||
int lastValidPos; //to be used with CurrentItemOnce playback mode
|
||||
QMediaPlaylist::PlaybackMode playbackMode;
|
||||
QMediaContent currentItem;
|
||||
|
||||
mutable QList<int> randomModePositions;
|
||||
mutable int randomPositionsOffset;
|
||||
|
||||
int nextItemPos(int steps = 1) const;
|
||||
int previousItemPos(int steps = 1) const;
|
||||
|
||||
void _q_mediaInserted(int start, int end);
|
||||
void _q_mediaRemoved(int start, int end);
|
||||
void _q_mediaChanged(int start, int end);
|
||||
|
||||
QMediaPlaylistNavigator *q_ptr;
|
||||
};
|
||||
|
||||
|
||||
int QMediaPlaylistNavigatorPrivate::nextItemPos(int steps) const
|
||||
{
|
||||
if (playlist->mediaCount() == 0)
|
||||
return -1;
|
||||
|
||||
if (steps == 0)
|
||||
return currentPos;
|
||||
|
||||
switch (playbackMode) {
|
||||
case QMediaPlaylist::CurrentItemOnce:
|
||||
return /*currentPos == -1 ? lastValidPos :*/ -1;
|
||||
case QMediaPlaylist::CurrentItemInLoop:
|
||||
return currentPos;
|
||||
case QMediaPlaylist::Sequential:
|
||||
{
|
||||
int nextPos = currentPos+steps;
|
||||
return nextPos < playlist->mediaCount() ? nextPos : -1;
|
||||
}
|
||||
case QMediaPlaylist::Loop:
|
||||
return (currentPos+steps) % playlist->mediaCount();
|
||||
case QMediaPlaylist::Random:
|
||||
{
|
||||
//TODO: limit the history size
|
||||
|
||||
if (randomPositionsOffset == -1) {
|
||||
randomModePositions.clear();
|
||||
randomModePositions.append(currentPos);
|
||||
randomPositionsOffset = 0;
|
||||
}
|
||||
|
||||
while (randomModePositions.size() < randomPositionsOffset+steps+1)
|
||||
randomModePositions.append(-1);
|
||||
int res = randomModePositions[randomPositionsOffset+steps];
|
||||
if (res<0 || res >= playlist->mediaCount()) {
|
||||
res = qrand() % playlist->mediaCount();
|
||||
randomModePositions[randomPositionsOffset+steps] = res;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int QMediaPlaylistNavigatorPrivate::previousItemPos(int steps) const
|
||||
{
|
||||
if (playlist->mediaCount() == 0)
|
||||
return -1;
|
||||
|
||||
if (steps == 0)
|
||||
return currentPos;
|
||||
|
||||
switch (playbackMode) {
|
||||
case QMediaPlaylist::CurrentItemOnce:
|
||||
return /*currentPos == -1 ? lastValidPos :*/ -1;
|
||||
case QMediaPlaylist::CurrentItemInLoop:
|
||||
return currentPos;
|
||||
case QMediaPlaylist::Sequential:
|
||||
{
|
||||
int prevPos = currentPos == -1 ? playlist->mediaCount() - steps : currentPos - steps;
|
||||
return prevPos>=0 ? prevPos : -1;
|
||||
}
|
||||
case QMediaPlaylist::Loop:
|
||||
{
|
||||
int prevPos = currentPos - steps;
|
||||
while (prevPos<0)
|
||||
prevPos += playlist->mediaCount();
|
||||
return prevPos;
|
||||
}
|
||||
case QMediaPlaylist::Random:
|
||||
{
|
||||
//TODO: limit the history size
|
||||
|
||||
if (randomPositionsOffset == -1) {
|
||||
randomModePositions.clear();
|
||||
randomModePositions.append(currentPos);
|
||||
randomPositionsOffset = 0;
|
||||
}
|
||||
|
||||
while (randomPositionsOffset-steps < 0) {
|
||||
randomModePositions.prepend(-1);
|
||||
randomPositionsOffset++;
|
||||
}
|
||||
|
||||
int res = randomModePositions[randomPositionsOffset-steps];
|
||||
if (res<0 || res >= playlist->mediaCount()) {
|
||||
res = qrand() % playlist->mediaCount();
|
||||
randomModePositions[randomPositionsOffset-steps] = res;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QMediaPlaylistNavigator
|
||||
|
||||
\brief The QMediaPlaylistNavigator class provides navigation for a media playlist.
|
||||
\inmodule QtMultimedia
|
||||
\ingroup multimedia
|
||||
\since 1.0
|
||||
|
||||
\sa QMediaPlaylist, QMediaPlaylistProvider
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
Constructs a media playlist navigator for a \a playlist.
|
||||
|
||||
The \a parent is passed to QObject.
|
||||
\since 1.0
|
||||
*/
|
||||
QMediaPlaylistNavigator::QMediaPlaylistNavigator(QMediaPlaylistProvider *playlist, QObject *parent)
|
||||
: QObject(parent)
|
||||
, d_ptr(new QMediaPlaylistNavigatorPrivate)
|
||||
{
|
||||
d_ptr->q_ptr = this;
|
||||
|
||||
setPlaylist(playlist ? playlist : _q_nullMediaPlaylist());
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys a media playlist navigator.
|
||||
*/
|
||||
|
||||
QMediaPlaylistNavigator::~QMediaPlaylistNavigator()
|
||||
{
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
|
||||
/*! \property QMediaPlaylistNavigator::playbackMode
|
||||
Contains the playback mode.
|
||||
\since 1.0
|
||||
*/
|
||||
QMediaPlaylist::PlaybackMode QMediaPlaylistNavigator::playbackMode() const
|
||||
{
|
||||
return d_func()->playbackMode;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the playback \a mode.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaPlaylistNavigator::setPlaybackMode(QMediaPlaylist::PlaybackMode mode)
|
||||
{
|
||||
Q_D(QMediaPlaylistNavigator);
|
||||
if (d->playbackMode == mode)
|
||||
return;
|
||||
|
||||
if (mode == QMediaPlaylist::Random) {
|
||||
d->randomPositionsOffset = 0;
|
||||
d->randomModePositions.append(d->currentPos);
|
||||
} else if (d->playbackMode == QMediaPlaylist::Random) {
|
||||
d->randomPositionsOffset = -1;
|
||||
d->randomModePositions.clear();
|
||||
}
|
||||
|
||||
d->playbackMode = mode;
|
||||
|
||||
emit playbackModeChanged(mode);
|
||||
emit surroundingItemsChanged();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the playlist being navigated.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
QMediaPlaylistProvider *QMediaPlaylistNavigator::playlist() const
|
||||
{
|
||||
return d_func()->playlist;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a playlist to navigate.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaPlaylistNavigator::setPlaylist(QMediaPlaylistProvider *playlist)
|
||||
{
|
||||
Q_D(QMediaPlaylistNavigator);
|
||||
|
||||
if (d->playlist == playlist)
|
||||
return;
|
||||
|
||||
if (d->playlist) {
|
||||
d->playlist->disconnect(this);
|
||||
}
|
||||
|
||||
if (playlist) {
|
||||
d->playlist = playlist;
|
||||
} else {
|
||||
//assign to shared readonly null playlist
|
||||
d->playlist = _q_nullMediaPlaylist();
|
||||
}
|
||||
|
||||
connect(d->playlist, SIGNAL(mediaInserted(int,int)), SLOT(_q_mediaInserted(int,int)));
|
||||
connect(d->playlist, SIGNAL(mediaRemoved(int,int)), SLOT(_q_mediaRemoved(int,int)));
|
||||
connect(d->playlist, SIGNAL(mediaChanged(int,int)), SLOT(_q_mediaChanged(int,int)));
|
||||
|
||||
d->randomPositionsOffset = -1;
|
||||
d->randomModePositions.clear();
|
||||
|
||||
if (d->currentPos != -1) {
|
||||
d->currentPos = -1;
|
||||
emit currentIndexChanged(-1);
|
||||
}
|
||||
|
||||
if (!d->currentItem.isNull()) {
|
||||
d->currentItem = QMediaContent();
|
||||
emit activated(d->currentItem); //stop playback
|
||||
}
|
||||
}
|
||||
|
||||
/*! \property QMediaPlaylistNavigator::currentItem
|
||||
|
||||
Contains the media at the current position in the playlist.
|
||||
|
||||
\since 1.0
|
||||
\sa currentIndex()
|
||||
*/
|
||||
|
||||
QMediaContent QMediaPlaylistNavigator::currentItem() const
|
||||
{
|
||||
return itemAt(d_func()->currentPos);
|
||||
}
|
||||
|
||||
/*! \fn QMediaContent QMediaPlaylistNavigator::nextItem(int steps) const
|
||||
|
||||
Returns the media that is \a steps positions ahead of the current
|
||||
position in the playlist.
|
||||
|
||||
\since 1.0
|
||||
\sa nextIndex()
|
||||
*/
|
||||
QMediaContent QMediaPlaylistNavigator::nextItem(int steps) const
|
||||
{
|
||||
return itemAt(nextIndex(steps));
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the media that is \a steps positions behind the current
|
||||
position in the playlist.
|
||||
|
||||
\since 1.0
|
||||
\sa previousIndex()
|
||||
*/
|
||||
QMediaContent QMediaPlaylistNavigator::previousItem(int steps) const
|
||||
{
|
||||
return itemAt(previousIndex(steps));
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the media at a \a position in the playlist.
|
||||
\since 1.0
|
||||
*/
|
||||
QMediaContent QMediaPlaylistNavigator::itemAt(int position) const
|
||||
{
|
||||
return d_func()->playlist->media(position);
|
||||
}
|
||||
|
||||
/*! \property QMediaPlaylistNavigator::currentIndex
|
||||
|
||||
Contains the position of the current media.
|
||||
|
||||
If no media is current, the property contains -1.
|
||||
|
||||
\since 1.0
|
||||
\sa nextIndex(), previousIndex()
|
||||
*/
|
||||
|
||||
int QMediaPlaylistNavigator::currentIndex() const
|
||||
{
|
||||
return d_func()->currentPos;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a position \a steps ahead of the current position
|
||||
accounting for the playbackMode().
|
||||
|
||||
If the position is beyond the end of the playlist, this value
|
||||
returned is -1.
|
||||
|
||||
\since 1.0
|
||||
\sa currentIndex(), previousIndex(), playbackMode()
|
||||
*/
|
||||
|
||||
int QMediaPlaylistNavigator::nextIndex(int steps) const
|
||||
{
|
||||
return d_func()->nextItemPos(steps);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Returns a position \a steps behind the current position accounting
|
||||
for the playbackMode().
|
||||
|
||||
If the position is prior to the beginning of the playlist this will
|
||||
return -1.
|
||||
|
||||
\since 1.0
|
||||
\sa currentIndex(), nextIndex(), playbackMode()
|
||||
*/
|
||||
int QMediaPlaylistNavigator::previousIndex(int steps) const
|
||||
{
|
||||
return d_func()->previousItemPos(steps);
|
||||
}
|
||||
|
||||
/*!
|
||||
Advances to the next item in the playlist.
|
||||
|
||||
\since 1.0
|
||||
\sa previous(), jump(), playbackMode()
|
||||
*/
|
||||
void QMediaPlaylistNavigator::next()
|
||||
{
|
||||
Q_D(QMediaPlaylistNavigator);
|
||||
|
||||
int nextPos = d->nextItemPos();
|
||||
|
||||
if ( playbackMode() == QMediaPlaylist::Random )
|
||||
d->randomPositionsOffset++;
|
||||
|
||||
jump(nextPos);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns to the previous item in the playlist,
|
||||
|
||||
\since 1.0
|
||||
\sa next(), jump(), playbackMode()
|
||||
*/
|
||||
void QMediaPlaylistNavigator::previous()
|
||||
{
|
||||
Q_D(QMediaPlaylistNavigator);
|
||||
|
||||
int prevPos = d->previousItemPos();
|
||||
if ( playbackMode() == QMediaPlaylist::Random )
|
||||
d->randomPositionsOffset--;
|
||||
|
||||
jump(prevPos);
|
||||
}
|
||||
|
||||
/*!
|
||||
Jumps to a new \a position in the playlist.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaPlaylistNavigator::jump(int position)
|
||||
{
|
||||
Q_D(QMediaPlaylistNavigator);
|
||||
|
||||
if (position<-1 || position>=d->playlist->mediaCount()) {
|
||||
qWarning() << "QMediaPlaylistNavigator: Jump outside playlist range";
|
||||
position = -1;
|
||||
}
|
||||
|
||||
if (position != -1)
|
||||
d->lastValidPos = position;
|
||||
|
||||
if (playbackMode() == QMediaPlaylist::Random) {
|
||||
if (d->randomModePositions[d->randomPositionsOffset] != position) {
|
||||
d->randomModePositions.clear();
|
||||
d->randomModePositions.append(position);
|
||||
d->randomPositionsOffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (position != -1)
|
||||
d->currentItem = d->playlist->media(position);
|
||||
else
|
||||
d->currentItem = QMediaContent();
|
||||
|
||||
if (position != d->currentPos) {
|
||||
d->currentPos = position;
|
||||
emit currentIndexChanged(d->currentPos);
|
||||
emit surroundingItemsChanged();
|
||||
}
|
||||
|
||||
emit activated(d->currentItem);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaPlaylistNavigatorPrivate::_q_mediaInserted(int start, int end)
|
||||
{
|
||||
Q_Q(QMediaPlaylistNavigator);
|
||||
|
||||
if (currentPos >= start) {
|
||||
currentPos = end-start+1;
|
||||
q->jump(currentPos);
|
||||
}
|
||||
|
||||
//TODO: check if they really changed
|
||||
emit q->surroundingItemsChanged();
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaPlaylistNavigatorPrivate::_q_mediaRemoved(int start, int end)
|
||||
{
|
||||
Q_Q(QMediaPlaylistNavigator);
|
||||
|
||||
if (currentPos > end) {
|
||||
currentPos = currentPos - end-start+1;
|
||||
q->jump(currentPos);
|
||||
} else if (currentPos >= start) {
|
||||
//current item was removed
|
||||
currentPos = qMin(start, playlist->mediaCount()-1);
|
||||
q->jump(currentPos);
|
||||
}
|
||||
|
||||
//TODO: check if they really changed
|
||||
emit q->surroundingItemsChanged();
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaPlaylistNavigatorPrivate::_q_mediaChanged(int start, int end)
|
||||
{
|
||||
Q_Q(QMediaPlaylistNavigator);
|
||||
|
||||
if (currentPos >= start && currentPos<=end) {
|
||||
QMediaContent src = playlist->media(currentPos);
|
||||
if (src != currentItem) {
|
||||
currentItem = src;
|
||||
emit q->activated(src);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: check if they really changed
|
||||
emit q->surroundingItemsChanged();
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylistNavigator::activated(const QMediaContent &media)
|
||||
|
||||
Signals that the current \a media has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylistNavigator::currentIndexChanged(int position)
|
||||
|
||||
Signals the \a position of the current media has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylistNavigator::playbackModeChanged(QMediaPlaylist::PlaybackMode mode)
|
||||
|
||||
Signals that the playback \a mode has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylistNavigator::surroundingItemsChanged()
|
||||
|
||||
Signals that media immediately surrounding the current position has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
#include "moc_qmediaplaylistnavigator.cpp"
|
||||
QT_END_NAMESPACE
|
||||
|
||||
115
src/multimedia/playback/qmediaplaylistnavigator.h
Normal file
115
src/multimedia/playback/qmediaplaylistnavigator.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMEDIAPLAYLISTNAVIGATOR_H
|
||||
#define QMEDIAPLAYLISTNAVIGATOR_H
|
||||
|
||||
#include "qmediaplaylistprovider.h"
|
||||
#include "qmediaplaylist.h"
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
|
||||
class QMediaPlaylistNavigatorPrivate;
|
||||
class Q_MULTIMEDIA_EXPORT QMediaPlaylistNavigator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QMediaPlaylist::PlaybackMode playbackMode READ playbackMode WRITE setPlaybackMode NOTIFY playbackModeChanged)
|
||||
Q_PROPERTY(int currentIndex READ currentIndex WRITE jump NOTIFY currentIndexChanged)
|
||||
Q_PROPERTY(QMediaContent currentItem READ currentItem)
|
||||
|
||||
public:
|
||||
QMediaPlaylistNavigator(QMediaPlaylistProvider *playlist, QObject *parent = 0);
|
||||
virtual ~QMediaPlaylistNavigator();
|
||||
|
||||
QMediaPlaylistProvider *playlist() const;
|
||||
void setPlaylist(QMediaPlaylistProvider *playlist);
|
||||
|
||||
QMediaPlaylist::PlaybackMode playbackMode() const;
|
||||
|
||||
QMediaContent currentItem() const;
|
||||
QMediaContent nextItem(int steps = 1) const;
|
||||
QMediaContent previousItem(int steps = 1) const;
|
||||
|
||||
QMediaContent itemAt(int position) const;
|
||||
|
||||
int currentIndex() const;
|
||||
int nextIndex(int steps = 1) const;
|
||||
int previousIndex(int steps = 1) const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void next();
|
||||
void previous();
|
||||
|
||||
void jump(int);
|
||||
|
||||
void setPlaybackMode(QMediaPlaylist::PlaybackMode mode);
|
||||
|
||||
Q_SIGNALS:
|
||||
void activated(const QMediaContent &content);
|
||||
void currentIndexChanged(int);
|
||||
void playbackModeChanged(QMediaPlaylist::PlaybackMode mode);
|
||||
|
||||
void surroundingItemsChanged();
|
||||
|
||||
protected:
|
||||
QMediaPlaylistNavigatorPrivate *d_ptr;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QMediaPlaylistNavigator)
|
||||
Q_DECLARE_PRIVATE(QMediaPlaylistNavigator)
|
||||
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_mediaInserted(int start, int end))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_mediaRemoved(int start, int end))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_mediaChanged(int start, int end))
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
|
||||
#endif // QMEDIAPLAYLISTNAVIGATOR_H
|
||||
329
src/multimedia/playback/qmediaplaylistprovider.cpp
Normal file
329
src/multimedia/playback/qmediaplaylistprovider.cpp
Normal file
@@ -0,0 +1,329 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmediaplaylistprovider.h"
|
||||
#include "qmediaplaylistprovider_p.h"
|
||||
|
||||
#include <QtCore/qurl.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QMediaPlaylistProvider
|
||||
|
||||
\brief The QMediaPlaylistProvider class provides an abstract list of media.
|
||||
\inmodule QtMultimedia
|
||||
\since 1.0
|
||||
|
||||
\sa QMediaPlaylist
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a playlist provider with the given \a parent.
|
||||
*/
|
||||
QMediaPlaylistProvider::QMediaPlaylistProvider(QObject *parent)
|
||||
:QObject(parent), d_ptr(new QMediaPlaylistProviderPrivate)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
QMediaPlaylistProvider::QMediaPlaylistProvider(QMediaPlaylistProviderPrivate &dd, QObject *parent)
|
||||
:QObject(parent), d_ptr(&dd)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys a playlist provider.
|
||||
*/
|
||||
QMediaPlaylistProvider::~QMediaPlaylistProvider()
|
||||
{
|
||||
delete d_ptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylistProvider::mediaCount() const;
|
||||
|
||||
Returns the size of playlist.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaPlaylistProvider::media(int index) const;
|
||||
|
||||
Returns the media at \a index in the playlist.
|
||||
|
||||
If the index is invalid this will return a null media content.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
Loads a playlist from from a URL \a location. If no playlist \a format is specified the loader
|
||||
will inspect the URL or probe the headers to guess the format.
|
||||
|
||||
New items are appended to playlist.
|
||||
|
||||
Returns true if the provider supports the format and loading from the locations URL protocol,
|
||||
otherwise this will return false.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylistProvider::load(const QUrl &location, const char *format)
|
||||
{
|
||||
Q_UNUSED(location);
|
||||
Q_UNUSED(format);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Loads a playlist from from an I/O \a device. If no playlist \a format is specified the loader
|
||||
will probe the headers to guess the format.
|
||||
|
||||
New items are appended to playlist.
|
||||
|
||||
Returns true if the provider supports the format and loading from an I/O device, otherwise this
|
||||
will return false.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylistProvider::load(QIODevice * device, const char *format)
|
||||
{
|
||||
Q_UNUSED(device);
|
||||
Q_UNUSED(format);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Saves the contents of a playlist to a URL \a location. If no playlist \a format is specified
|
||||
the writer will inspect the URL to guess the format.
|
||||
|
||||
Returns true if the playlist was saved successfully; and false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylistProvider::save(const QUrl &location, const char *format)
|
||||
{
|
||||
Q_UNUSED(location);
|
||||
Q_UNUSED(format);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Saves the contents of a playlist to an I/O \a device in the specified \a format.
|
||||
|
||||
Returns true if the playlist was saved successfully; and false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylistProvider::save(QIODevice * device, const char *format)
|
||||
{
|
||||
Q_UNUSED(device);
|
||||
Q_UNUSED(format);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns true if a playlist is read-only; otherwise returns false.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylistProvider::isReadOnly() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
Append \a media to a playlist.
|
||||
|
||||
Returns true if the media was appended; and false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylistProvider::addMedia(const QMediaContent &media)
|
||||
{
|
||||
Q_UNUSED(media);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Append multiple media \a items to a playlist.
|
||||
|
||||
Returns true if the media items were appended; and false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylistProvider::addMedia(const QList<QMediaContent> &items)
|
||||
{
|
||||
foreach(const QMediaContent &item, items) {
|
||||
if (!addMedia(item))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
Inserts \a media into a playlist at \a position.
|
||||
|
||||
Returns true if the media was inserted; and false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylistProvider::insertMedia(int position, const QMediaContent &media)
|
||||
{
|
||||
Q_UNUSED(position);
|
||||
Q_UNUSED(media);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Inserts multiple media \a items into a playlist at \a position.
|
||||
|
||||
Returns true if the media \a items were inserted; and false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylistProvider::insertMedia(int position, const QList<QMediaContent> &items)
|
||||
{
|
||||
for (int i=0; i<items.count(); i++) {
|
||||
if (!insertMedia(position+i,items.at(i)))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Removes the media at \a position from a playlist.
|
||||
|
||||
Returns true if the media was removed; and false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylistProvider::removeMedia(int position)
|
||||
{
|
||||
Q_UNUSED(position);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Removes the media between the given \a start and \a end positions from a playlist.
|
||||
|
||||
Returns true if the media was removed; and false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylistProvider::removeMedia(int start, int end)
|
||||
{
|
||||
for (int pos=start; pos<=end; pos++) {
|
||||
if (!removeMedia(pos))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
Removes all media from a playlist.
|
||||
|
||||
Returns true if the media was removed; and false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaPlaylistProvider::clear()
|
||||
{
|
||||
return removeMedia(0, mediaCount()-1);
|
||||
}
|
||||
|
||||
/*!
|
||||
Shuffles the contents of a playlist.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaPlaylistProvider::shuffle()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn void QMediaPlaylistProvider::mediaAboutToBeInserted(int start, int end);
|
||||
|
||||
Signals that new media is about to be inserted into a playlist between the \a start and \a end
|
||||
positions.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QMediaPlaylistProvider::mediaInserted(int start, int end);
|
||||
|
||||
Signals that new media has been inserted into a playlist between the \a start and \a end
|
||||
positions.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QMediaPlaylistProvider::mediaAboutToBeRemoved(int start, int end);
|
||||
|
||||
Signals that media is about to be removed from a playlist between the \a start and \a end
|
||||
positions.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QMediaPlaylistProvider::mediaRemoved(int start, int end);
|
||||
|
||||
Signals that media has been removed from a playlist between the \a start and \a end positions.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QMediaPlaylistProvider::mediaChanged(int start, int end);
|
||||
|
||||
Signals that media in playlist between the \a start and \a end positions inclusive has changed.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QMediaPlaylistProvider::loaded()
|
||||
|
||||
Signals that a load() finished successfully.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QMediaPlaylistProvider::loadFailed(QMediaPlaylist::Error error, const QString& errorMessage)
|
||||
|
||||
Signals that a load failed() due to an \a error. The \a errorMessage provides more information.
|
||||
\since 1.0
|
||||
*/
|
||||
|
||||
#include "moc_qmediaplaylistprovider.cpp"
|
||||
QT_END_NAMESPACE
|
||||
|
||||
115
src/multimedia/playback/qmediaplaylistprovider.h
Normal file
115
src/multimedia/playback/qmediaplaylistprovider.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMEDIAPLAYLISTPROVIDER_H
|
||||
#define QMEDIAPLAYLISTPROVIDER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "qmediacontent.h"
|
||||
#include "qmediaplaylist.h"
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
class QString;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QMediaPlaylistProviderPrivate;
|
||||
class Q_MULTIMEDIA_EXPORT QMediaPlaylistProvider : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QMediaPlaylistProvider(QObject *parent=0);
|
||||
virtual ~QMediaPlaylistProvider();
|
||||
|
||||
virtual bool load(const QUrl &location, const char *format = 0);
|
||||
virtual bool load(QIODevice * device, const char *format = 0);
|
||||
virtual bool save(const QUrl &location, const char *format = 0);
|
||||
virtual bool save(QIODevice * device, const char *format);
|
||||
|
||||
virtual int mediaCount() const = 0;
|
||||
virtual QMediaContent media(int index) const = 0;
|
||||
|
||||
virtual bool isReadOnly() const;
|
||||
|
||||
virtual bool addMedia(const QMediaContent &content);
|
||||
virtual bool addMedia(const QList<QMediaContent> &contentList);
|
||||
virtual bool insertMedia(int index, const QMediaContent &content);
|
||||
virtual bool insertMedia(int index, const QList<QMediaContent> &content);
|
||||
virtual bool removeMedia(int pos);
|
||||
virtual bool removeMedia(int start, int end);
|
||||
virtual bool clear();
|
||||
|
||||
public Q_SLOTS:
|
||||
virtual void shuffle();
|
||||
|
||||
Q_SIGNALS:
|
||||
void mediaAboutToBeInserted(int start, int end);
|
||||
void mediaInserted(int start, int end);
|
||||
|
||||
void mediaAboutToBeRemoved(int start, int end);
|
||||
void mediaRemoved(int start, int end);
|
||||
|
||||
void mediaChanged(int start, int end);
|
||||
|
||||
void loaded();
|
||||
void loadFailed(QMediaPlaylist::Error, const QString& errorMessage);
|
||||
|
||||
protected:
|
||||
QMediaPlaylistProviderPrivate *d_ptr;
|
||||
QMediaPlaylistProvider(QMediaPlaylistProviderPrivate &dd, QObject *parent);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QMediaPlaylistProvider)
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
|
||||
#endif // QMEDIAPLAYLISTPROVIDER_H
|
||||
80
src/multimedia/playback/qmediaplaylistprovider_p.h
Normal file
80
src/multimedia/playback/qmediaplaylistprovider_p.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMEDIAPLAYLISTPROVIDER_P_H
|
||||
#define QMEDIAPLAYLISTPROVIDER_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qmediaplaylist.h"
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
|
||||
class QMediaPlaylistProviderPrivate
|
||||
{
|
||||
public:
|
||||
QMediaPlaylistProviderPrivate()
|
||||
{}
|
||||
virtual ~QMediaPlaylistProviderPrivate()
|
||||
{}
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
|
||||
|
||||
#endif // QMEDIAPLAYLISTSOURCE_P_H
|
||||
453
src/multimedia/playback/qmediaresource.cpp
Normal file
453
src/multimedia/playback/qmediaresource.cpp
Normal file
@@ -0,0 +1,453 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmediaresource.h"
|
||||
|
||||
#include <QtCore/qsize.h>
|
||||
#include <QtCore/qurl.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace
|
||||
{
|
||||
class QMediaResourcePrivateRegisterMetaTypes
|
||||
{
|
||||
public:
|
||||
QMediaResourcePrivateRegisterMetaTypes()
|
||||
{
|
||||
qRegisterMetaType<QMediaResource>();
|
||||
qRegisterMetaType<QMediaResourceList>();
|
||||
}
|
||||
} _registerMetaTypes;
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QMediaResource
|
||||
|
||||
\brief The QMediaResource class provides a description of a media resource.
|
||||
\inmodule QtMultimedia
|
||||
\ingroup multimedia
|
||||
\since 1.0
|
||||
|
||||
A media resource is composed of a \l {url()}{URL} containing the
|
||||
location of the resource and a set of properties that describe the
|
||||
format of the resource. The properties provide a means to assess a
|
||||
resource without first attempting to load it, and in situations where
|
||||
media be represented by multiple alternative representations provide a
|
||||
means to select the appropriate resource.
|
||||
|
||||
Media made available by a remote services can often be available in
|
||||
multiple encodings or quality levels, this allows a client to select
|
||||
an appropriate resource based on considerations such as codecs supported,
|
||||
network bandwidth, and display constraints. QMediaResource includes
|
||||
information such as the \l {mimeType()}{MIME type}, \l {audioCodec()}{audio}
|
||||
and \l {videoCodec()}{video} codecs, \l {audioBitRate()}{audio} and
|
||||
\l {videoBitRate()}{video} bit rates, and \l {resolution()}{resolution}
|
||||
so these constraints and others can be evaluated.
|
||||
|
||||
The only mandatory property of a QMediaResource is the url().
|
||||
|
||||
\sa QMediaContent
|
||||
*/
|
||||
|
||||
/*!
|
||||
\typedef QMediaResourceList
|
||||
|
||||
Synonym for \c QList<QMediaResource>
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a null media resource.
|
||||
*/
|
||||
QMediaResource::QMediaResource()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a media resource with the given \a mimeType from a \a url.
|
||||
\since 1.0
|
||||
*/
|
||||
QMediaResource::QMediaResource(const QUrl &url, const QString &mimeType)
|
||||
{
|
||||
values.insert(Url, url);
|
||||
values.insert(MimeType, mimeType);
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a media resource with the given \a mimeType from a network \a request.
|
||||
\since 1.0
|
||||
*/
|
||||
QMediaResource::QMediaResource(const QNetworkRequest &request, const QString &mimeType)
|
||||
{
|
||||
values.insert(Request, QVariant::fromValue(request));
|
||||
values.insert(Url, request.url());
|
||||
values.insert(MimeType, mimeType);
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a copy of a media resource \a other.
|
||||
\since 1.0
|
||||
*/
|
||||
QMediaResource::QMediaResource(const QMediaResource &other)
|
||||
: values(other.values)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Assigns the value of \a other to a media resource.
|
||||
\since 1.0
|
||||
*/
|
||||
QMediaResource &QMediaResource::operator =(const QMediaResource &other)
|
||||
{
|
||||
values = other.values;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys a media resource.
|
||||
*/
|
||||
QMediaResource::~QMediaResource()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Compares a media resource to \a other.
|
||||
|
||||
Returns true if the resources are identical, and false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaResource::operator ==(const QMediaResource &other) const
|
||||
{
|
||||
// Compare requests directly as QNetworkRequests are "custom types".
|
||||
foreach (int key, values.keys()) {
|
||||
switch (key) {
|
||||
case Request:
|
||||
if (request() != other.request())
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
if (values.value(key) != other.values.value(key))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
Compares a media resource to \a other.
|
||||
|
||||
Returns true if they are different, and false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaResource::operator !=(const QMediaResource &other) const
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
/*!
|
||||
Identifies if a media resource is null.
|
||||
|
||||
Returns true if the resource is null, and false otherwise.
|
||||
\since 1.0
|
||||
*/
|
||||
bool QMediaResource::isNull() const
|
||||
{
|
||||
return values.isEmpty();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the URL of a media resource.
|
||||
\since 1.0
|
||||
*/
|
||||
QUrl QMediaResource::url() const
|
||||
{
|
||||
return qvariant_cast<QUrl>(values.value(Url));
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the network request associated with this media resource.
|
||||
\since 1.0
|
||||
*/
|
||||
QNetworkRequest QMediaResource::request() const
|
||||
{
|
||||
if(values.contains(Request))
|
||||
return qvariant_cast<QNetworkRequest>(values.value(Request));
|
||||
|
||||
return QNetworkRequest(url());
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the MIME type of a media resource.
|
||||
|
||||
This may be null if the MIME type is unknown.
|
||||
\since 1.0
|
||||
*/
|
||||
QString QMediaResource::mimeType() const
|
||||
{
|
||||
return qvariant_cast<QString>(values.value(MimeType));
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the language of a media resource as an ISO 639-2 code.
|
||||
|
||||
This may be null if the language is unknown.
|
||||
\since 1.0
|
||||
*/
|
||||
QString QMediaResource::language() const
|
||||
{
|
||||
return qvariant_cast<QString>(values.value(Language));
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a language of a media resource.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaResource::setLanguage(const QString &language)
|
||||
{
|
||||
if (!language.isNull())
|
||||
values.insert(Language, language);
|
||||
else
|
||||
values.remove(Language);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the audio codec of a media resource.
|
||||
|
||||
This may be null if the media resource does not contain an audio stream, or the codec is
|
||||
unknown.
|
||||
\since 1.0
|
||||
*/
|
||||
QString QMediaResource::audioCodec() const
|
||||
{
|
||||
return qvariant_cast<QString>(values.value(AudioCodec));
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the audio \a codec of a media resource.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaResource::setAudioCodec(const QString &codec)
|
||||
{
|
||||
if (!codec.isNull())
|
||||
values.insert(AudioCodec, codec);
|
||||
else
|
||||
values.remove(AudioCodec);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the video codec of a media resource.
|
||||
|
||||
This may be null if the media resource does not contain a video stream, or the codec is
|
||||
unknonwn.
|
||||
\since 1.0
|
||||
*/
|
||||
QString QMediaResource::videoCodec() const
|
||||
{
|
||||
return qvariant_cast<QString>(values.value(VideoCodec));
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the video \a codec of media resource.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaResource::setVideoCodec(const QString &codec)
|
||||
{
|
||||
if (!codec.isNull())
|
||||
values.insert(VideoCodec, codec);
|
||||
else
|
||||
values.remove(VideoCodec);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the size in bytes of a media resource.
|
||||
|
||||
This may be zero if the size is unknown.
|
||||
\since 1.0
|
||||
*/
|
||||
qint64 QMediaResource::dataSize() const
|
||||
{
|
||||
return qvariant_cast<qint64>(values.value(DataSize));
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a size in bytes of a media resource.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaResource::setDataSize(const qint64 size)
|
||||
{
|
||||
if (size != 0)
|
||||
values.insert(DataSize, size);
|
||||
else
|
||||
values.remove(DataSize);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the bit rate in bits per second of a media resource's audio stream.
|
||||
|
||||
This may be zero if the bit rate is unknown, or the resource contains no audio stream.
|
||||
\since 1.0
|
||||
*/
|
||||
int QMediaResource::audioBitRate() const
|
||||
{
|
||||
return values.value(AudioBitRate).toInt();
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the bit \a rate in bits per second of a media resource's video stream.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaResource::setAudioBitRate(int rate)
|
||||
{
|
||||
if (rate != 0)
|
||||
values.insert(AudioBitRate, rate);
|
||||
else
|
||||
values.remove(AudioBitRate);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the audio sample rate of a media resource.
|
||||
|
||||
This may be zero if the sample size is unknown, or the resource contains no audio stream.
|
||||
\since 1.0
|
||||
*/
|
||||
int QMediaResource::sampleRate() const
|
||||
{
|
||||
return qvariant_cast<int>(values.value(SampleRate));
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the audio \a sampleRate of a media resource.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaResource::setSampleRate(int sampleRate)
|
||||
{
|
||||
if (sampleRate != 0)
|
||||
values.insert(SampleRate, sampleRate);
|
||||
else
|
||||
values.remove(SampleRate);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the number of audio channels in a media resource.
|
||||
|
||||
This may be zero if the sample size is unknown, or the resource contains no audio stream.
|
||||
\since 1.0
|
||||
*/
|
||||
int QMediaResource::channelCount() const
|
||||
{
|
||||
return qvariant_cast<int>(values.value(ChannelCount));
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the number of audio \a channels in a media resource.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaResource::setChannelCount(int channels)
|
||||
{
|
||||
if (channels != 0)
|
||||
values.insert(ChannelCount, channels);
|
||||
else
|
||||
values.remove(ChannelCount);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the bit rate in bits per second of a media resource's video stream.
|
||||
|
||||
This may be zero if the bit rate is unknown, or the resource contains no video stream.
|
||||
\since 1.0
|
||||
*/
|
||||
int QMediaResource::videoBitRate() const
|
||||
{
|
||||
return values.value(VideoBitRate).toInt();
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the bit \a rate in bits per second of a media resource's video stream.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaResource::setVideoBitRate(int rate)
|
||||
{
|
||||
if (rate != 0)
|
||||
values.insert(VideoBitRate, rate);
|
||||
else
|
||||
values.remove(VideoBitRate);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the resolution in pixels of a media resource.
|
||||
|
||||
This may be null is the resolution is unknown, or the resource contains no pixel data (i.e. the
|
||||
resource is an audio stream.
|
||||
\since 1.0
|
||||
*/
|
||||
QSize QMediaResource::resolution() const
|
||||
{
|
||||
return qvariant_cast<QSize>(values.value(Resolution));
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a resolution in pixels of a media resource.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaResource::setResolution(const QSize &resolution)
|
||||
{
|
||||
if (resolution.width() != -1 || resolution.height() != -1)
|
||||
values.insert(Resolution, resolution);
|
||||
else
|
||||
values.remove(Resolution);
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a width and \a height in pixels of a media resource.
|
||||
\since 1.0
|
||||
*/
|
||||
void QMediaResource::setResolution(int width, int height)
|
||||
{
|
||||
if (width != -1 || height != -1)
|
||||
values.insert(Resolution, QSize(width, height));
|
||||
else
|
||||
values.remove(Resolution);
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
134
src/multimedia/playback/qmediaresource.h
Normal file
134
src/multimedia/playback/qmediaresource.h
Normal file
@@ -0,0 +1,134 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMEDIARESOURCE_H
|
||||
#define QMEDIARESOURCE_H
|
||||
|
||||
#include <QtCore/qmap.h>
|
||||
#include <QtCore/qmetatype.h>
|
||||
#include <QtNetwork/qnetworkrequest.h>
|
||||
|
||||
#include <qtmultimediadefs.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Multimedia)
|
||||
|
||||
|
||||
class Q_MULTIMEDIA_EXPORT QMediaResource
|
||||
{
|
||||
public:
|
||||
QMediaResource();
|
||||
QMediaResource(const QUrl &url, const QString &mimeType = QString());
|
||||
QMediaResource(const QNetworkRequest &request, const QString &mimeType = QString());
|
||||
QMediaResource(const QMediaResource &other);
|
||||
QMediaResource &operator =(const QMediaResource &other);
|
||||
~QMediaResource();
|
||||
|
||||
bool isNull() const;
|
||||
|
||||
bool operator ==(const QMediaResource &other) const;
|
||||
bool operator !=(const QMediaResource &other) const;
|
||||
|
||||
QUrl url() const;
|
||||
QNetworkRequest request() const;
|
||||
QString mimeType() const;
|
||||
|
||||
QString language() const;
|
||||
void setLanguage(const QString &language);
|
||||
|
||||
QString audioCodec() const;
|
||||
void setAudioCodec(const QString &codec);
|
||||
|
||||
QString videoCodec() const;
|
||||
void setVideoCodec(const QString &codec);
|
||||
|
||||
qint64 dataSize() const;
|
||||
void setDataSize(const qint64 size);
|
||||
|
||||
int audioBitRate() const;
|
||||
void setAudioBitRate(int rate);
|
||||
|
||||
int sampleRate() const;
|
||||
void setSampleRate(int frequency);
|
||||
|
||||
int channelCount() const;
|
||||
void setChannelCount(int channels);
|
||||
|
||||
int videoBitRate() const;
|
||||
void setVideoBitRate(int rate);
|
||||
|
||||
QSize resolution() const;
|
||||
void setResolution(const QSize &resolution);
|
||||
void setResolution(int width, int height);
|
||||
|
||||
|
||||
private:
|
||||
enum Property
|
||||
{
|
||||
Url,
|
||||
Request,
|
||||
MimeType,
|
||||
Language,
|
||||
AudioCodec,
|
||||
VideoCodec,
|
||||
DataSize,
|
||||
AudioBitRate,
|
||||
VideoBitRate,
|
||||
SampleRate,
|
||||
ChannelCount,
|
||||
Resolution
|
||||
};
|
||||
QMap<int, QVariant> values;
|
||||
};
|
||||
|
||||
typedef QList<QMediaResource> QMediaResourceList;
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(QMediaResource)
|
||||
Q_DECLARE_METATYPE(QMediaResourceList)
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user