Initial copy of QtMultimediaKit.
Comes from original repo, with SHA1: 2c82d5611655e5967f5c5095af50c0991c4378b2
This commit is contained in:
85
src/imports/multimedia/multimedia.cpp
Normal file
85
src/imports/multimedia/multimedia.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtDeclarative/qdeclarativeextensionplugin.h>
|
||||
#include <QtDeclarative/qdeclarative.h>
|
||||
#include <QtDeclarative/qdeclarativeengine.h>
|
||||
#include <QtDeclarative/qdeclarativecomponent.h>
|
||||
#include "private/qsoundeffect_p.h"
|
||||
|
||||
#include "qdeclarativevideo_p.h"
|
||||
#include "qdeclarativeaudio_p.h"
|
||||
#include "qdeclarativemediametadata_p.h"
|
||||
#include "qdeclarativecamera_p.h"
|
||||
#include "qdeclarativecamerapreviewprovider_p.h"
|
||||
|
||||
QML_DECLARE_TYPE(QSoundEffect)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QMultimediaDeclarativeModule : public QDeclarativeExtensionPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual void registerTypes(const char *uri)
|
||||
{
|
||||
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtMultimediaKit"));
|
||||
|
||||
qmlRegisterType<QSoundEffect>(uri, 1, 1, "SoundEffect");
|
||||
qmlRegisterType<QDeclarativeAudio>(uri, 1, 1, "Audio");
|
||||
qmlRegisterType<QDeclarativeVideo>(uri, 1, 1, "Video");
|
||||
qmlRegisterType<QDeclarativeCamera>(uri, 1, 1, "Camera");
|
||||
qmlRegisterType<QDeclarativeMediaMetaData>();
|
||||
}
|
||||
|
||||
void initializeEngine(QDeclarativeEngine *engine, const char *uri)
|
||||
{
|
||||
Q_UNUSED(uri);
|
||||
engine->addImageProvider("camera", new QDeclarativeCameraPreviewProvider);
|
||||
}
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "multimedia.moc"
|
||||
|
||||
Q_EXPORT_PLUGIN2(qmultimediadeclarativemodule, QT_PREPEND_NAMESPACE(QMultimediaDeclarativeModule));
|
||||
|
||||
41
src/imports/multimedia/multimedia.pro
Normal file
41
src/imports/multimedia/multimedia.pro
Normal file
@@ -0,0 +1,41 @@
|
||||
TARGET = declarative_multimedia
|
||||
TARGETPATH = Qt/multimediakit
|
||||
|
||||
include(../qimportbase.pri)
|
||||
|
||||
QT += declarative network multimediakit-private
|
||||
|
||||
DESTDIR = $$QT.multimediakit.imports/$$TARGETPATH
|
||||
target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
|
||||
|
||||
HEADERS += \
|
||||
qdeclarativeaudio_p.h \
|
||||
qdeclarativemediabase_p.h \
|
||||
qdeclarativemediametadata_p.h \
|
||||
qdeclarativevideo_p.h \
|
||||
qdeclarativecamera_p.h \
|
||||
qdeclarativecamerapreviewprovider_p.h
|
||||
|
||||
SOURCES += \
|
||||
multimedia.cpp \
|
||||
qdeclarativeaudio.cpp \
|
||||
qdeclarativemediabase.cpp \
|
||||
qdeclarativevideo.cpp \
|
||||
qdeclarativecamera.cpp \
|
||||
qdeclarativecamerapreviewprovider.cpp
|
||||
|
||||
qmldir.files += $$PWD/qmldir
|
||||
qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
|
||||
|
||||
INSTALLS += target qmldir
|
||||
|
||||
symbian {
|
||||
# In Symbian, a library should enjoy _largest_ possible capability set.
|
||||
TARGET.CAPABILITY = ALL -TCB
|
||||
TARGET.UID3 = 0x20021313
|
||||
TARGET.EPOCALLOWDLLDATA=1
|
||||
# Specifies what files shall be deployed: the plugin itself and the qmldir file.
|
||||
importFiles.sources = $$DESTDIR/declarative_multimedia$${QT_LIBINFIX}.dll qmldir
|
||||
importFiles.path = $$QT_IMPORTS_BASE_DIR/$$TARGETPATH
|
||||
DEPLOYMENT = importFiles
|
||||
}
|
||||
698
src/imports/multimedia/qdeclarativeaudio.cpp
Normal file
698
src/imports/multimedia/qdeclarativeaudio.cpp
Normal file
@@ -0,0 +1,698 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdeclarativeaudio_p.h"
|
||||
|
||||
#include <qmediaplayercontrol.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
/*!
|
||||
\qmlclass Audio QDeclarativeAudio
|
||||
\brief The Audio element allows you to add audio playback to a scene.
|
||||
|
||||
\ingroup qml-multimedia
|
||||
|
||||
This element is part of the \bold{QtMultimediaKit 1.1} module.
|
||||
|
||||
\qml
|
||||
import Qt 4.7
|
||||
import QtMultimediaKit 1.1
|
||||
|
||||
Text {
|
||||
text: "Click Me!";
|
||||
font.pointSize: 24;
|
||||
width: 150; height: 50;
|
||||
|
||||
Audio {
|
||||
id: playMusic
|
||||
source: "music.wav"
|
||||
}
|
||||
MouseArea {
|
||||
id: playArea
|
||||
anchors.fill: parent
|
||||
onPressed: { playMusic.play() }
|
||||
}
|
||||
}
|
||||
\endqml
|
||||
|
||||
\sa Video
|
||||
*/
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\class QDeclarativeAudio
|
||||
\brief The QDeclarativeAudio class provides an audio item that you can add to a QDeclarativeView.
|
||||
*/
|
||||
|
||||
void QDeclarativeAudio::_q_error(int errorCode, const QString &errorString)
|
||||
{
|
||||
m_error = QMediaPlayer::Error(errorCode);
|
||||
m_errorString = errorString;
|
||||
|
||||
emit error(Error(errorCode), errorString);
|
||||
emit errorChanged();
|
||||
}
|
||||
|
||||
|
||||
QDeclarativeAudio::QDeclarativeAudio(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QDeclarativeAudio::~QDeclarativeAudio()
|
||||
{
|
||||
shutdown();
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlmethod Audio::play()
|
||||
|
||||
Starts playback of the media.
|
||||
|
||||
Sets the \l playing property to true, and the \l paused property to false.
|
||||
*/
|
||||
|
||||
void QDeclarativeAudio::play()
|
||||
{
|
||||
if (!m_complete)
|
||||
return;
|
||||
|
||||
setPaused(false);
|
||||
setPlaying(true);
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlmethod Audio::pause()
|
||||
|
||||
Pauses playback of the media.
|
||||
|
||||
Sets the \l playing and \l paused properties to true.
|
||||
*/
|
||||
|
||||
void QDeclarativeAudio::pause()
|
||||
{
|
||||
if (!m_complete)
|
||||
return;
|
||||
|
||||
setPaused(true);
|
||||
setPlaying(true);
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlmethod Audio::stop()
|
||||
|
||||
Stops playback of the media.
|
||||
|
||||
Sets the \l playing and \l paused properties to false.
|
||||
*/
|
||||
|
||||
void QDeclarativeAudio::stop()
|
||||
{
|
||||
if (!m_complete)
|
||||
return;
|
||||
|
||||
setPlaying(false);
|
||||
setPaused(false);
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlproperty url Audio::source
|
||||
|
||||
This property holds the source URL of the media.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty url Audio::autoLoad
|
||||
|
||||
This property indicates if loading of media should begin immediately.
|
||||
|
||||
Defaults to true, if false media will not be loaded until playback is started.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty bool Audio::playing
|
||||
|
||||
This property holds whether the media is playing.
|
||||
|
||||
Defaults to false, and can be set to true to start playback.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty bool Audio::paused
|
||||
|
||||
This property holds whether the media is paused.
|
||||
|
||||
Defaults to false, and can be set to true to pause playback.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Audio::onStarted()
|
||||
|
||||
This handler is called when playback is started.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Audio::onResumed()
|
||||
|
||||
This handler is called when playback is resumed from the paused state.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Audio::onPaused()
|
||||
|
||||
This handler is called when playback is paused.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Audio::onStopped()
|
||||
|
||||
This handler is called when playback is stopped.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty enumeration Audio::status
|
||||
|
||||
This property holds the status of media loading. It can be one of:
|
||||
|
||||
\list
|
||||
\o NoMedia - no media has been set.
|
||||
\o Loading - the media is currently being loaded.
|
||||
\o Loaded - the media has been loaded.
|
||||
\o Buffering - the media is buffering data.
|
||||
\o Stalled - playback has been interrupted while the media is buffering data.
|
||||
\o Buffered - the media has buffered data.
|
||||
\o EndOfMedia - the media has played to the end.
|
||||
\o InvalidMedia - the media cannot be played.
|
||||
\o UnknownStatus - the status of the media is unknown.
|
||||
\endlist
|
||||
*/
|
||||
|
||||
QDeclarativeAudio::Status QDeclarativeAudio::status() const
|
||||
{
|
||||
return Status(m_status);
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlproperty int Audio::duration
|
||||
|
||||
This property holds the duration of the media in milliseconds.
|
||||
|
||||
If the media doesn't have a fixed duration (a live stream for example) this will be 0.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty int Audio::position
|
||||
|
||||
This property holds the current playback position in milliseconds.
|
||||
|
||||
If the \l seekable property is true, this property can be set to seek to a new position.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty real Audio::volume
|
||||
|
||||
This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume).
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty bool Audio::muted
|
||||
|
||||
This property holds whether the audio output is muted.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty real Audio::bufferProgress
|
||||
|
||||
This property holds how much of the data buffer is currently filled, from 0.0 (empty) to 1.0
|
||||
(full).
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty bool Audio::seekable
|
||||
|
||||
This property holds whether position of the audio can be changed.
|
||||
|
||||
If true; setting a \l position value will cause playback to seek to the new position.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty real Audio::playbackRate
|
||||
|
||||
This property holds the rate at which audio is played at as a multiple of the normal rate.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty enumeration Audio::error
|
||||
|
||||
This property holds the error state of the audio. It can be one of:
|
||||
|
||||
\list
|
||||
\o NoError - there is no current error.
|
||||
\o ResourceError - the audio cannot be played due to a problem allocating resources.
|
||||
\o FormatError - the audio format is not supported.
|
||||
\o NetworkError - the audio cannot be played due to network issues.
|
||||
\o AccessDenied - the audio cannot be played due to insufficient permissions.
|
||||
\o ServiceMissing - the audio cannot be played because the media service could not be
|
||||
instantiated.
|
||||
\endlist
|
||||
*/
|
||||
|
||||
QDeclarativeAudio::Error QDeclarativeAudio::error() const
|
||||
{
|
||||
return Error(m_error);
|
||||
}
|
||||
|
||||
void QDeclarativeAudio::classBegin()
|
||||
{
|
||||
setObject(this);
|
||||
}
|
||||
|
||||
void QDeclarativeAudio::componentComplete()
|
||||
{
|
||||
QDeclarativeMediaBase::componentComplete();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\qmlproperty string Audio::errorString
|
||||
|
||||
This property holds a string describing the current error condition in more detail.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Audio::onError(error, errorString)
|
||||
|
||||
This handler is called when an \l {QMediaPlayer::Error}{error} has
|
||||
occurred. The errorString parameter may contain more detailed
|
||||
information about the error.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.title
|
||||
|
||||
This property holds the tile of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Title}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.subTitle
|
||||
|
||||
This property holds the sub-title of the media.
|
||||
|
||||
\sa {QtMultimediaKit::SubTitle}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.author
|
||||
|
||||
This property holds the author of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Author}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.comment
|
||||
|
||||
This property holds a user comment about the media.
|
||||
|
||||
\sa {QtMultimediaKit::Comment}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.description
|
||||
|
||||
This property holds a description of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Description}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.category
|
||||
|
||||
This property holds the category of the media
|
||||
|
||||
\sa {QtMultimediaKit::Category}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.genre
|
||||
|
||||
This property holds the genre of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Genre}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.year
|
||||
|
||||
This property holds the year of release of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Year}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.date
|
||||
|
||||
This property holds the date of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Date}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.userRating
|
||||
|
||||
This property holds a user rating of the media in the range of 0 to 100.
|
||||
|
||||
\sa {QtMultimediaKit::UserRating}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.keywords
|
||||
|
||||
This property holds a list of keywords describing the media.
|
||||
|
||||
\sa {QtMultimediaKit::Keywords}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.language
|
||||
|
||||
This property holds the language of the media, as an ISO 639-2 code.
|
||||
|
||||
\sa {QtMultimediaKit::Language}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.publisher
|
||||
|
||||
This property holds the publisher of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Publisher}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.copyright
|
||||
|
||||
This property holds the media's copyright notice.
|
||||
|
||||
\sa {QtMultimediaKit::Copyright}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.parentalRating
|
||||
|
||||
This property holds the parental rating of the media.
|
||||
|
||||
\sa {QtMultimediaKit::ParentalRating}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.ratingOrganisation
|
||||
|
||||
This property holds the name of the rating organisation responsible for the
|
||||
parental rating of the media.
|
||||
|
||||
\sa {QtMultimediaKit::RatingOrganisation}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.size
|
||||
|
||||
This property property holds the size of the media in bytes.
|
||||
|
||||
\sa {QtMultimediaKit::Size}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.mediaType
|
||||
|
||||
This property holds the type of the media.
|
||||
|
||||
\sa {QtMultimediaKit::MediaType}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.audioBitRate
|
||||
|
||||
This property holds the bit rate of the media's audio stream ni bits per
|
||||
second.
|
||||
|
||||
\sa {QtMultimediaKit::AudioBitRate}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.audioCodec
|
||||
|
||||
This property holds the encoding of the media audio stream.
|
||||
|
||||
\sa {QtMultimediaKit::AudioCodec}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.averageLevel
|
||||
|
||||
This property holds the average volume level of the media.
|
||||
|
||||
\sa {QtMultimediaKit::AverageLevel}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.channelCount
|
||||
|
||||
This property holds the number of channels in the media's audio stream.
|
||||
|
||||
\sa {QtMultimediaKit::ChannelCount}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.peakValue
|
||||
|
||||
This property holds the peak volume of media's audio stream.
|
||||
|
||||
\sa {QtMultimediaKit::PeakValue}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.sampleRate
|
||||
|
||||
This property holds the sample rate of the media's audio stream in hertz.
|
||||
|
||||
\sa {QtMultimediaKit::SampleRate}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.albumTitle
|
||||
|
||||
This property holds the title of the album the media belongs to.
|
||||
|
||||
\sa {QtMultimediaKit::AlbumTitle}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.albumArtist
|
||||
|
||||
This property holds the name of the principal artist of the album the media
|
||||
belongs to.
|
||||
|
||||
\sa {QtMultimediaKit::AlbumArtist}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.contributingArtist
|
||||
|
||||
This property holds the names of artists contributing to the media.
|
||||
|
||||
\sa {QtMultimediaKit::ContributingArtist}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.composer
|
||||
|
||||
This property holds the composer of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Composer}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.conductor
|
||||
|
||||
This property holds the conductor of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Conductor}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.lyrics
|
||||
|
||||
This property holds the lyrics to the media.
|
||||
|
||||
\sa {QtMultimediaKit::Lyrics}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.mood
|
||||
|
||||
This property holds the mood of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Mood}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.trackNumber
|
||||
|
||||
This property holds the track number of the media.
|
||||
|
||||
\sa {QtMultimediaKit::TrackNumber}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.trackCount
|
||||
|
||||
This property holds the number of track on the album containing the media.
|
||||
|
||||
\sa {QtMultimediaKit::TrackNumber}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.coverArtUrlSmall
|
||||
|
||||
This property holds the URL of a small cover art image.
|
||||
|
||||
\sa {QtMultimediaKit::CoverArtUrlSmall}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.coverArtUrlLarge
|
||||
|
||||
This property holds the URL of a large cover art image.
|
||||
|
||||
\sa {QtMultimediaKit::CoverArtUrlLarge}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.resolution
|
||||
|
||||
This property holds the dimension of an image or video.
|
||||
|
||||
\sa {QtMultimediaKit::Resolution}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.pixelAspectRatio
|
||||
|
||||
This property holds the pixel aspect ratio of an image or video.
|
||||
|
||||
\sa {QtMultimediaKit::PixelAspectRatio}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.videoFrameRate
|
||||
|
||||
This property holds the frame rate of the media's video stream.
|
||||
|
||||
\sa {QtMultimediaKit::VideoFrameRate}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.videoBitRate
|
||||
|
||||
This property holds the bit rate of the media's video stream in bits per
|
||||
second.
|
||||
|
||||
\sa {QtMultimediaKit::VideoBitRate}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.videoCodec
|
||||
|
||||
This property holds the encoding of the media's video stream.
|
||||
|
||||
\sa {QtMultimediaKit::VideoCodec}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.posterUrl
|
||||
|
||||
This property holds the URL of a poster image.
|
||||
|
||||
\sa {QtMultimediaKit::PosterUrl}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.chapterNumber
|
||||
|
||||
This property holds the chapter number of the media.
|
||||
|
||||
\sa {QtMultimediaKit::ChapterNumber}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.director
|
||||
|
||||
This property holds the director of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Director}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.leadPerformer
|
||||
|
||||
This property holds the lead performer in the media.
|
||||
|
||||
\sa {QtMultimediaKit::LeadPerformer}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Audio::metaData.writer
|
||||
|
||||
This property holds the writer of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Writer}
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "moc_qdeclarativeaudio_p.cpp"
|
||||
|
||||
|
||||
178
src/imports/multimedia/qdeclarativeaudio_p.h
Normal file
178
src/imports/multimedia/qdeclarativeaudio_p.h
Normal file
@@ -0,0 +1,178 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVEAUDIO_P_H
|
||||
#define QDECLARATIVEAUDIO_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of other Qt classes. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qdeclarativemediabase_p.h"
|
||||
|
||||
#include <QtCore/qbasictimer.h>
|
||||
#include <QtDeclarative/qdeclarativeitem.h>
|
||||
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QTimerEvent;
|
||||
|
||||
class QDeclarativeAudio : public QObject, public QDeclarativeMediaBase, public QDeclarativeParserStatus
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
|
||||
Q_PROPERTY(bool autoLoad READ isAutoLoad WRITE setAutoLoad NOTIFY autoLoadChanged)
|
||||
Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
|
||||
Q_PROPERTY(int loops READ loopCount WRITE setLoopCount NOTIFY loopCountChanged)
|
||||
Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
|
||||
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
|
||||
Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
|
||||
Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
|
||||
Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
|
||||
Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
|
||||
Q_PROPERTY(int bufferProgress READ bufferProgress NOTIFY bufferProgressChanged)
|
||||
Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged)
|
||||
Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged)
|
||||
Q_PROPERTY(Error error READ error NOTIFY errorChanged)
|
||||
Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
|
||||
Q_PROPERTY(QDeclarativeMediaMetaData *metaData READ metaData CONSTANT)
|
||||
Q_ENUMS(Status)
|
||||
Q_ENUMS(Error)
|
||||
Q_ENUMS(Loop)
|
||||
Q_INTERFACES(QDeclarativeParserStatus)
|
||||
public:
|
||||
enum Status
|
||||
{
|
||||
UnknownStatus = QMediaPlayer::UnknownMediaStatus,
|
||||
NoMedia = QMediaPlayer::NoMedia,
|
||||
Loading = QMediaPlayer::LoadingMedia,
|
||||
Loaded = QMediaPlayer::LoadedMedia,
|
||||
Stalled = QMediaPlayer::StalledMedia,
|
||||
Buffering = QMediaPlayer::BufferingMedia,
|
||||
Buffered = QMediaPlayer::BufferedMedia,
|
||||
EndOfMedia = QMediaPlayer::EndOfMedia,
|
||||
InvalidMedia = QMediaPlayer::InvalidMedia
|
||||
};
|
||||
|
||||
enum Error
|
||||
{
|
||||
NoError = QMediaPlayer::NoError,
|
||||
ResourceError = QMediaPlayer::ResourceError,
|
||||
FormatError = QMediaPlayer::FormatError,
|
||||
NetworkError = QMediaPlayer::NetworkError,
|
||||
AccessDenied = QMediaPlayer::AccessDeniedError,
|
||||
ServiceMissing = QMediaPlayer::ServiceMissingError
|
||||
};
|
||||
|
||||
enum Loop
|
||||
{
|
||||
Infinite = QDeclarativeMediaBase::INFINITE
|
||||
};
|
||||
|
||||
QDeclarativeAudio(QObject *parent = 0);
|
||||
~QDeclarativeAudio();
|
||||
|
||||
Status status() const;
|
||||
Error error() const;
|
||||
|
||||
void classBegin();
|
||||
void componentComplete();
|
||||
|
||||
public Q_SLOTS:
|
||||
void play();
|
||||
void pause();
|
||||
void stop();
|
||||
|
||||
Q_SIGNALS:
|
||||
void sourceChanged();
|
||||
void autoLoadChanged();
|
||||
void playingChanged();
|
||||
void pausedChanged();
|
||||
void loopCountChanged();
|
||||
|
||||
void started();
|
||||
void resumed();
|
||||
void paused();
|
||||
void stopped();
|
||||
|
||||
void statusChanged();
|
||||
|
||||
void durationChanged();
|
||||
void positionChanged();
|
||||
|
||||
void volumeChanged();
|
||||
void mutedChanged();
|
||||
|
||||
void bufferProgressChanged();
|
||||
|
||||
void seekableChanged();
|
||||
void playbackRateChanged();
|
||||
|
||||
void errorChanged();
|
||||
void error(QDeclarativeAudio::Error error, const QString &errorString);
|
||||
|
||||
private Q_SLOTS:
|
||||
void _q_error(int, const QString &);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QDeclarativeAudio)
|
||||
Q_PRIVATE_SLOT(mediaBase(), void _q_statusChanged())
|
||||
|
||||
inline QDeclarativeMediaBase *mediaBase() { return this; }
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeAudio))
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
||||
1342
src/imports/multimedia/qdeclarativecamera.cpp
Normal file
1342
src/imports/multimedia/qdeclarativecamera.cpp
Normal file
File diff suppressed because it is too large
Load Diff
302
src/imports/multimedia/qdeclarativecamera_p.h
Normal file
302
src/imports/multimedia/qdeclarativecamera_p.h
Normal file
@@ -0,0 +1,302 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVECAMERA_H
|
||||
#define QDECLARATIVECAMERA_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of other Qt classes. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qgraphicsvideoitem.h"
|
||||
#include <QtCore/qbasictimer.h>
|
||||
#include <QtDeclarative/qdeclarativeitem.h>
|
||||
#include <QtCore/QTime>
|
||||
|
||||
#include <qcamera.h>
|
||||
#include <qcameraimageprocessing.h>
|
||||
#include <qcameraimagecapture.h>
|
||||
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QTimerEvent;
|
||||
class QVideoSurfaceFormat;
|
||||
|
||||
|
||||
class QDeclarativeCamera : public QDeclarativeItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(State cameraState READ cameraState WRITE setCameraState NOTIFY cameraStateChanged)
|
||||
Q_PROPERTY(LockStatus lockStatus READ lockStatus NOTIFY lockStatusChanged)
|
||||
Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
|
||||
|
||||
Q_PROPERTY(QString capturedImagePath READ capturedImagePath NOTIFY imageSaved)
|
||||
|
||||
Q_PROPERTY(int iso READ isoSensitivity WRITE setManualIsoSensitivity NOTIFY isoSensitivityChanged)
|
||||
Q_PROPERTY(qreal shutterSpeed READ shutterSpeed NOTIFY shutterSpeedChanged)
|
||||
Q_PROPERTY(qreal aperture READ aperture NOTIFY apertureChanged)
|
||||
Q_PROPERTY(qreal exposureCompensation READ exposureCompensation WRITE setExposureCompensation NOTIFY exposureCompensationChanged)
|
||||
|
||||
Q_PROPERTY(ExposureMode exposureMode READ exposureMode WRITE setExposureMode NOTIFY exposureModeChanged)
|
||||
Q_PROPERTY(int flashMode READ flashMode WRITE setFlashMode NOTIFY flashModeChanged)
|
||||
Q_PROPERTY(WhiteBalanceMode whiteBalanceMode READ whiteBalanceMode WRITE setWhiteBalanceMode NOTIFY whiteBalanceModeChanged)
|
||||
Q_PROPERTY(int manualWhiteBalance READ manualWhiteBalance WRITE setManualWhiteBalance NOTIFY manualWhiteBalanceChanged)
|
||||
|
||||
Q_PROPERTY(QSize captureResolution READ captureResolution WRITE setCaptureResolution NOTIFY captureResolutionChanged)
|
||||
|
||||
Q_PROPERTY(qreal opticalZoom READ opticalZoom WRITE setOpticalZoom NOTIFY opticalZoomChanged)
|
||||
Q_PROPERTY(qreal maximumOpticalZoom READ maximumOpticalZoom NOTIFY maximumOpticalZoomChanged)
|
||||
Q_PROPERTY(qreal digitalZoom READ digitalZoom WRITE setDigitalZoom NOTIFY digitalZoomChanged)
|
||||
Q_PROPERTY(qreal maximumDigitalZoom READ maximumDigitalZoom NOTIFY maximumDigitalZoomChanged)
|
||||
|
||||
Q_ENUMS(State)
|
||||
Q_ENUMS(LockStatus)
|
||||
Q_ENUMS(Error)
|
||||
Q_ENUMS(FlashMode)
|
||||
Q_ENUMS(ExposureMode)
|
||||
Q_ENUMS(WhiteBalanceMode)
|
||||
public:
|
||||
enum State
|
||||
{
|
||||
ActiveState = QCamera::ActiveState,
|
||||
LoadedState = QCamera::LoadedState,
|
||||
UnloadedState = QCamera::UnloadedState
|
||||
};
|
||||
|
||||
enum LockStatus
|
||||
{
|
||||
Unlocked = QCamera::Unlocked,
|
||||
Searching = QCamera::Searching,
|
||||
Locked = QCamera::Locked
|
||||
};
|
||||
|
||||
enum Error
|
||||
{
|
||||
NoError = QCamera::NoError,
|
||||
CameraError = QCamera::CameraError,
|
||||
InvalidRequestError = QCamera::InvalidRequestError,
|
||||
ServiceMissingError = QCamera::ServiceMissingError,
|
||||
NotSupportedFeatureError = QCamera::NotSupportedFeatureError
|
||||
};
|
||||
|
||||
enum FlashMode {
|
||||
FlashAuto = 0x1,
|
||||
FlashOff = 0x2,
|
||||
FlashOn = 0x4,
|
||||
FlashRedEyeReduction = 0x8,
|
||||
FlashFill = 0x10,
|
||||
FlashTorch = 0x20,
|
||||
FlashSlowSyncFrontCurtain = 0x40,
|
||||
FlashSlowSyncRearCurtain = 0x80,
|
||||
FlashManual = 0x100
|
||||
};
|
||||
|
||||
enum ExposureMode {
|
||||
ExposureAuto = 0,
|
||||
ExposureManual = 1,
|
||||
ExposurePortrait = 2,
|
||||
ExposureNight = 3,
|
||||
ExposureBacklight = 4,
|
||||
ExposureSpotlight = 5,
|
||||
ExposureSports = 6,
|
||||
ExposureSnow = 7,
|
||||
ExposureBeach = 8,
|
||||
ExposureLargeAperture = 9,
|
||||
ExposureSmallAperture = 10,
|
||||
ExposureModeVendor = 1000
|
||||
};
|
||||
|
||||
enum WhiteBalanceMode {
|
||||
WhiteBalanceAuto = 0,
|
||||
WhiteBalanceManual = 1,
|
||||
WhiteBalanceSunlight = 2,
|
||||
WhiteBalanceCloudy = 3,
|
||||
WhiteBalanceShade = 4,
|
||||
WhiteBalanceTungsten = 5,
|
||||
WhiteBalanceFluorescent = 6,
|
||||
WhiteBalanceIncandescent = 7,
|
||||
WhiteBalanceFlash = 8,
|
||||
WhiteBalanceSunset = 9,
|
||||
WhiteBalanceVendor = 1000
|
||||
};
|
||||
|
||||
QDeclarativeCamera(QDeclarativeItem *parent = 0);
|
||||
~QDeclarativeCamera();
|
||||
|
||||
State cameraState() const;
|
||||
|
||||
Error error() const;
|
||||
QString errorString() const;
|
||||
|
||||
LockStatus lockStatus() const;
|
||||
|
||||
QImage capturedImagePreview() const;
|
||||
QString capturedImagePath() const;
|
||||
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||
|
||||
int flashMode() const;
|
||||
ExposureMode exposureMode() const;
|
||||
qreal exposureCompensation() const;
|
||||
int isoSensitivity() const;
|
||||
qreal shutterSpeed() const;
|
||||
qreal aperture() const;
|
||||
|
||||
WhiteBalanceMode whiteBalanceMode() const;
|
||||
int manualWhiteBalance() const;
|
||||
|
||||
QSize captureResolution() const;
|
||||
|
||||
qreal maximumOpticalZoom() const;
|
||||
qreal maximumDigitalZoom() const;
|
||||
|
||||
qreal opticalZoom() const;
|
||||
qreal digitalZoom() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
void setCameraState(State state);
|
||||
|
||||
void searchAndLock();
|
||||
void unlock();
|
||||
|
||||
void captureImage();
|
||||
|
||||
void setFlashMode(int);
|
||||
void setExposureMode(QDeclarativeCamera::ExposureMode);
|
||||
void setExposureCompensation(qreal ev);
|
||||
void setManualIsoSensitivity(int iso);
|
||||
|
||||
void setWhiteBalanceMode(QDeclarativeCamera::WhiteBalanceMode mode) const;
|
||||
void setManualWhiteBalance(int colorTemp) const;
|
||||
|
||||
void setCaptureResolution(const QSize &size);
|
||||
|
||||
void setOpticalZoom(qreal);
|
||||
void setDigitalZoom(qreal);
|
||||
|
||||
Q_SIGNALS:
|
||||
void errorChanged();
|
||||
void error(QDeclarativeCamera::Error error, const QString &errorString);
|
||||
|
||||
void cameraStateChanged(QDeclarativeCamera::State);
|
||||
|
||||
void lockStatusChanged();
|
||||
|
||||
void imageCaptured(const QString &preview);
|
||||
void imageSaved(const QString &path);
|
||||
void captureFailed(const QString &message);
|
||||
|
||||
void isoSensitivityChanged(int);
|
||||
void apertureChanged(qreal);
|
||||
void shutterSpeedChanged(qreal);
|
||||
void exposureCompensationChanged(qreal);
|
||||
void exposureModeChanged(QDeclarativeCamera::ExposureMode);
|
||||
void flashModeChanged(int);
|
||||
|
||||
void whiteBalanceModeChanged(QDeclarativeCamera::WhiteBalanceMode) const;
|
||||
void manualWhiteBalanceChanged(int) const;
|
||||
|
||||
void captureResolutionChanged(const QSize&);
|
||||
|
||||
void opticalZoomChanged(qreal);
|
||||
void digitalZoomChanged(qreal);
|
||||
void maximumOpticalZoomChanged(qreal);
|
||||
void maximumDigitalZoomChanged(qreal);
|
||||
|
||||
protected:
|
||||
void geometryChanged(const QRectF &geometry, const QRectF &);
|
||||
void keyPressEvent(QKeyEvent * event);
|
||||
void keyReleaseEvent(QKeyEvent * event);
|
||||
|
||||
private Q_SLOTS:
|
||||
void _q_updateState(QCamera::State);
|
||||
void _q_nativeSizeChanged(const QSizeF &size);
|
||||
void _q_error(int, const QString &);
|
||||
void _q_imageCaptured(int, const QImage&);
|
||||
void _q_imageSaved(int, const QString&);
|
||||
void _q_captureFailed(int, QCameraImageCapture::Error, const QString&);
|
||||
void _q_updateFocusZones();
|
||||
void _q_updateLockStatus(QCamera::LockType, QCamera::LockStatus, QCamera::LockChangeReason);
|
||||
void _q_updateImageSettings();
|
||||
void _q_applyPendingState();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QDeclarativeCamera)
|
||||
QCamera *m_camera;
|
||||
QGraphicsVideoItem *m_viewfinderItem;
|
||||
|
||||
QCameraExposure *m_exposure;
|
||||
QCameraFocus *m_focus;
|
||||
QCameraImageCapture *m_capture;
|
||||
|
||||
QImage m_capturedImagePreview;
|
||||
QString m_capturedImagePath;
|
||||
QList <QGraphicsItem*> m_focusZones;
|
||||
QTime m_focusFailedTime;
|
||||
|
||||
QImageEncoderSettings m_imageSettings;
|
||||
bool m_imageSettingsChanged;
|
||||
|
||||
State m_pendingState;
|
||||
bool m_isStateSet;
|
||||
bool m_isValid;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeCamera))
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
||||
97
src/imports/multimedia/qdeclarativecamerapreviewprovider.cpp
Normal file
97
src/imports/multimedia/qdeclarativecamerapreviewprovider.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdeclarativecamerapreviewprovider_p.h"
|
||||
#include <QtCore/qmutex.h>
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
struct QDeclarativeCameraPreviewProviderPrivate
|
||||
{
|
||||
QString id;
|
||||
QImage image;
|
||||
QMutex mutex;
|
||||
};
|
||||
|
||||
Q_GLOBAL_STATIC(QDeclarativeCameraPreviewProviderPrivate, qDeclarativeCameraPreviewProviderPrivate)
|
||||
|
||||
QDeclarativeCameraPreviewProvider::QDeclarativeCameraPreviewProvider()
|
||||
: QDeclarativeImageProvider(QDeclarativeImageProvider::Image)
|
||||
{
|
||||
}
|
||||
|
||||
QDeclarativeCameraPreviewProvider::~QDeclarativeCameraPreviewProvider()
|
||||
{
|
||||
QDeclarativeCameraPreviewProviderPrivate *d = qDeclarativeCameraPreviewProviderPrivate();
|
||||
QMutexLocker lock(&d->mutex);
|
||||
d->id.clear();
|
||||
d->image = QImage();
|
||||
}
|
||||
|
||||
QImage QDeclarativeCameraPreviewProvider::requestImage(const QString &id, QSize *size, const QSize& requestedSize)
|
||||
{
|
||||
QDeclarativeCameraPreviewProviderPrivate *d = qDeclarativeCameraPreviewProviderPrivate();
|
||||
QMutexLocker lock(&d->mutex);
|
||||
|
||||
if (d->id != id)
|
||||
return QImage();
|
||||
|
||||
QImage res = d->image;
|
||||
if (!requestedSize.isEmpty())
|
||||
res = res.scaled(requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
if (size)
|
||||
*size = res.size();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void QDeclarativeCameraPreviewProvider::registerPreview(const QString &id, const QImage &preview)
|
||||
{
|
||||
//only the last preview is kept
|
||||
QDeclarativeCameraPreviewProviderPrivate *d = qDeclarativeCameraPreviewProviderPrivate();
|
||||
QMutexLocker lock(&d->mutex);
|
||||
d->id = id;
|
||||
d->image = preview;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
76
src/imports/multimedia/qdeclarativecamerapreviewprovider_p.h
Normal file
76
src/imports/multimedia/qdeclarativecamerapreviewprovider_p.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVECAMERAPREVIEWPROVIDER_H
|
||||
#define QDECLARATIVECAMERAPREVIEWPROVIDER_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of other Qt classes. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtDeclarative/qdeclarativeimageprovider.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDeclarativeCameraPreviewProvider : public QDeclarativeImageProvider
|
||||
{
|
||||
public:
|
||||
QDeclarativeCameraPreviewProvider();
|
||||
~QDeclarativeCameraPreviewProvider();
|
||||
|
||||
virtual QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize);
|
||||
static void registerPreview(const QString &id, const QImage &preview);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
||||
567
src/imports/multimedia/qdeclarativemediabase.cpp
Normal file
567
src/imports/multimedia/qdeclarativemediabase.cpp
Normal file
@@ -0,0 +1,567 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdeclarativemediabase_p.h"
|
||||
|
||||
#include <QtCore/qcoreevent.h>
|
||||
#include <QtCore/qurl.h>
|
||||
#include <QtDeclarative/qdeclarativeinfo.h>
|
||||
|
||||
#include <qmediaplayercontrol.h>
|
||||
#include <qmediaservice.h>
|
||||
#include <qmediaserviceprovider.h>
|
||||
#include <qmetadatareadercontrol.h>
|
||||
|
||||
#include "qdeclarativemediametadata_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
class QDeclarativeMediaBaseObject : public QMediaObject
|
||||
{
|
||||
public:
|
||||
QDeclarativeMediaBaseObject(QMediaService *service)
|
||||
: QMediaObject(0, service)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class QDeclarativeMediaBasePlayerControl : public QMediaPlayerControl
|
||||
{
|
||||
public:
|
||||
QDeclarativeMediaBasePlayerControl(QObject *parent)
|
||||
: QMediaPlayerControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QMediaPlayer::State state() const { return QMediaPlayer::StoppedState; }
|
||||
QMediaPlayer::MediaStatus mediaStatus() const { return QMediaPlayer::NoMedia; }
|
||||
|
||||
qint64 duration() const { return 0; }
|
||||
qint64 position() const { return 0; }
|
||||
void setPosition(qint64) {}
|
||||
int volume() const { return 0; }
|
||||
void setVolume(int) {}
|
||||
bool isMuted() const { return false; }
|
||||
void setMuted(bool) {}
|
||||
int bufferStatus() const { return 0; }
|
||||
bool isAudioAvailable() const { return false; }
|
||||
bool isVideoAvailable() const { return false; }
|
||||
bool isSeekable() const { return false; }
|
||||
QMediaTimeRange availablePlaybackRanges() const { return QMediaTimeRange(); }
|
||||
qreal playbackRate() const { return 1; }
|
||||
void setPlaybackRate(qreal) {}
|
||||
QMediaContent media() const { return QMediaContent(); }
|
||||
const QIODevice *mediaStream() const { return 0; }
|
||||
void setMedia(const QMediaContent &, QIODevice *) {}
|
||||
|
||||
void play() {}
|
||||
void pause() {}
|
||||
void stop() {}
|
||||
};
|
||||
|
||||
|
||||
class QDeclarativeMediaBaseMetaDataControl : public QMetaDataReaderControl
|
||||
{
|
||||
public:
|
||||
QDeclarativeMediaBaseMetaDataControl(QObject *parent)
|
||||
: QMetaDataReaderControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
bool isMetaDataAvailable() const { return false; }
|
||||
|
||||
QVariant metaData(QtMultimediaKit::MetaData) const { return QVariant(); }
|
||||
QList<QtMultimediaKit::MetaData> availableMetaData() const {
|
||||
return QList<QtMultimediaKit::MetaData>(); }
|
||||
|
||||
QVariant extendedMetaData(const QString &) const { return QVariant(); }
|
||||
QStringList availableExtendedMetaData() const { return QStringList(); }
|
||||
};
|
||||
|
||||
class QDeclarativeMediaBaseAnimation : public QObject
|
||||
{
|
||||
public:
|
||||
QDeclarativeMediaBaseAnimation(QDeclarativeMediaBase *media)
|
||||
: m_media(media)
|
||||
{
|
||||
}
|
||||
|
||||
void start() { if (!m_timer.isActive()) m_timer.start(500, this); }
|
||||
void stop() { m_timer.stop(); }
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *event)
|
||||
{
|
||||
if (event->timerId() == m_timer.timerId()) {
|
||||
event->accept();
|
||||
|
||||
if (m_media->m_playing && !m_media->m_paused)
|
||||
emit m_media->positionChanged();
|
||||
if (m_media->m_status == QMediaPlayer::BufferingMedia || QMediaPlayer::StalledMedia)
|
||||
emit m_media->bufferProgressChanged();
|
||||
} else {
|
||||
QObject::timerEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
QDeclarativeMediaBase *m_media;
|
||||
QBasicTimer m_timer;
|
||||
};
|
||||
|
||||
void QDeclarativeMediaBase::_q_statusChanged()
|
||||
{
|
||||
if (m_playerControl->mediaStatus() == QMediaPlayer::EndOfMedia && m_runningCount != 0) {
|
||||
m_runningCount -= 1;
|
||||
m_playerControl->play();
|
||||
}
|
||||
|
||||
const QMediaPlayer::MediaStatus oldStatus = m_status;
|
||||
const bool wasPlaying = m_playing;
|
||||
const bool wasPaused = m_paused;
|
||||
|
||||
const QMediaPlayer::State state = m_playerControl->state();
|
||||
|
||||
m_status = m_playerControl->mediaStatus();
|
||||
|
||||
if (m_complete)
|
||||
m_playing = state != QMediaPlayer::StoppedState;
|
||||
|
||||
if (state == QMediaPlayer::PausedState)
|
||||
m_paused = true;
|
||||
else if (state == QMediaPlayer::PlayingState)
|
||||
m_paused = false;
|
||||
|
||||
if (m_status != oldStatus)
|
||||
emit statusChanged();
|
||||
|
||||
switch (state) {
|
||||
case QMediaPlayer::StoppedState:
|
||||
if (wasPlaying) {
|
||||
emit stopped();
|
||||
|
||||
if (!m_playing)
|
||||
emit playingChanged();
|
||||
}
|
||||
break;
|
||||
case QMediaPlayer::PausedState:
|
||||
if (!wasPlaying) {
|
||||
emit started();
|
||||
if (m_playing)
|
||||
emit playingChanged();
|
||||
}
|
||||
if ((!wasPaused || !wasPlaying) && m_paused)
|
||||
emit paused();
|
||||
if (!wasPaused && m_paused)
|
||||
emit pausedChanged();
|
||||
|
||||
break;
|
||||
|
||||
case QMediaPlayer::PlayingState:
|
||||
if (wasPaused && wasPlaying)
|
||||
emit resumed();
|
||||
else
|
||||
emit started();
|
||||
|
||||
if (wasPaused && !m_paused)
|
||||
emit pausedChanged();
|
||||
if (!wasPlaying && m_playing)
|
||||
emit playingChanged();
|
||||
break;
|
||||
}
|
||||
|
||||
// Check
|
||||
if ((m_playing && !m_paused)
|
||||
|| m_status == QMediaPlayer::BufferingMedia
|
||||
|| m_status == QMediaPlayer::StalledMedia) {
|
||||
m_animation->start();
|
||||
}
|
||||
else {
|
||||
m_animation->stop();
|
||||
}
|
||||
}
|
||||
|
||||
QDeclarativeMediaBase::QDeclarativeMediaBase()
|
||||
: m_paused(false)
|
||||
, m_playing(false)
|
||||
, m_autoLoad(true)
|
||||
, m_loaded(false)
|
||||
, m_muted(false)
|
||||
, m_complete(false)
|
||||
, m_loopCount(1)
|
||||
, m_runningCount(0)
|
||||
, m_position(0)
|
||||
, m_vol(1.0)
|
||||
, m_playbackRate(1.0)
|
||||
, m_mediaService(0)
|
||||
, m_playerControl(0)
|
||||
, m_qmlObject(0)
|
||||
, m_mediaObject(0)
|
||||
, m_mediaProvider(0)
|
||||
, m_metaDataControl(0)
|
||||
, m_animation(0)
|
||||
, m_status(QMediaPlayer::NoMedia)
|
||||
, m_error(QMediaPlayer::ServiceMissingError)
|
||||
{
|
||||
}
|
||||
|
||||
QDeclarativeMediaBase::~QDeclarativeMediaBase()
|
||||
{
|
||||
}
|
||||
|
||||
void QDeclarativeMediaBase::shutdown()
|
||||
{
|
||||
delete m_mediaObject;
|
||||
m_metaData.reset();
|
||||
|
||||
if (m_mediaProvider)
|
||||
m_mediaProvider->releaseService(m_mediaService);
|
||||
|
||||
delete m_animation;
|
||||
|
||||
}
|
||||
|
||||
void QDeclarativeMediaBase::setObject(QObject *object)
|
||||
{
|
||||
m_qmlObject = object;
|
||||
|
||||
if ((m_mediaProvider = QMediaServiceProvider::defaultServiceProvider()) != 0) {
|
||||
if ((m_mediaService = m_mediaProvider->requestService(Q_MEDIASERVICE_MEDIAPLAYER)) != 0) {
|
||||
m_playerControl = qobject_cast<QMediaPlayerControl *>(
|
||||
m_mediaService->requestControl(QMediaPlayerControl_iid));
|
||||
m_metaDataControl = qobject_cast<QMetaDataReaderControl *>(
|
||||
m_mediaService->requestControl(QMetaDataReaderControl_iid));
|
||||
m_mediaObject = new QDeclarativeMediaBaseObject(m_mediaService);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_playerControl) {
|
||||
QObject::connect(m_playerControl, SIGNAL(stateChanged(QMediaPlayer::State)),
|
||||
object, SLOT(_q_statusChanged()));
|
||||
QObject::connect(m_playerControl, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
|
||||
object, SLOT(_q_statusChanged()));
|
||||
QObject::connect(m_playerControl, SIGNAL(mediaChanged(QMediaContent)),
|
||||
object, SIGNAL(sourceChanged()));
|
||||
QObject::connect(m_playerControl, SIGNAL(durationChanged(qint64)),
|
||||
object, SIGNAL(durationChanged()));
|
||||
QObject::connect(m_playerControl, SIGNAL(positionChanged(qint64)),
|
||||
object, SIGNAL(positionChanged()));
|
||||
QObject::connect(m_playerControl, SIGNAL(volumeChanged(int)),
|
||||
object, SIGNAL(volumeChanged()));
|
||||
QObject::connect(m_playerControl, SIGNAL(mutedChanged(bool)),
|
||||
object, SIGNAL(mutedChanged()));
|
||||
QObject::connect(m_playerControl, SIGNAL(bufferStatusChanged(int)),
|
||||
object, SIGNAL(bufferProgressChanged()));
|
||||
QObject::connect(m_playerControl, SIGNAL(seekableChanged(bool)),
|
||||
object, SIGNAL(seekableChanged()));
|
||||
QObject::connect(m_playerControl, SIGNAL(playbackRateChanged(qreal)),
|
||||
object, SIGNAL(playbackRateChanged()));
|
||||
QObject::connect(m_playerControl, SIGNAL(error(int,QString)),
|
||||
object, SLOT(_q_error(int,QString)));
|
||||
|
||||
m_animation = new QDeclarativeMediaBaseAnimation(this);
|
||||
m_error = QMediaPlayer::NoError;
|
||||
} else {
|
||||
m_playerControl = new QDeclarativeMediaBasePlayerControl(object);
|
||||
}
|
||||
|
||||
if (!m_metaDataControl)
|
||||
m_metaDataControl = new QDeclarativeMediaBaseMetaDataControl(object);
|
||||
|
||||
m_metaData.reset(new QDeclarativeMediaMetaData(m_metaDataControl));
|
||||
|
||||
QObject::connect(m_metaDataControl, SIGNAL(metaDataChanged()),
|
||||
m_metaData.data(), SIGNAL(metaDataChanged()));
|
||||
}
|
||||
|
||||
void QDeclarativeMediaBase::componentComplete()
|
||||
{
|
||||
m_playerControl->setVolume(m_vol * 100);
|
||||
m_playerControl->setMuted(m_muted);
|
||||
m_playerControl->setPlaybackRate(m_playbackRate);
|
||||
|
||||
if (!m_source.isEmpty() && (m_autoLoad || m_playing)) // Override autoLoad if playing set
|
||||
m_playerControl->setMedia(m_source, 0);
|
||||
|
||||
m_complete = true;
|
||||
|
||||
if (m_playing) {
|
||||
if (m_position > 0)
|
||||
m_playerControl->setPosition(m_position);
|
||||
|
||||
if (m_source.isEmpty()) {
|
||||
m_playing = false;
|
||||
|
||||
emit playingChanged();
|
||||
} else if (m_paused) {
|
||||
m_playerControl->pause();
|
||||
} else {
|
||||
m_playerControl->play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Properties
|
||||
|
||||
QUrl QDeclarativeMediaBase::source() const
|
||||
{
|
||||
return m_source;
|
||||
}
|
||||
|
||||
void QDeclarativeMediaBase::setSource(const QUrl &url)
|
||||
{
|
||||
if (url == m_source)
|
||||
return;
|
||||
|
||||
m_source = url;
|
||||
m_loaded = false;
|
||||
if (m_complete && (m_autoLoad || url.isEmpty())) {
|
||||
if (m_error != QMediaPlayer::ServiceMissingError && m_error != QMediaPlayer::NoError) {
|
||||
m_error = QMediaPlayer::NoError;
|
||||
m_errorString = QString();
|
||||
|
||||
emit errorChanged();
|
||||
}
|
||||
|
||||
m_playerControl->setMedia(m_source, 0);
|
||||
m_loaded = true;
|
||||
}
|
||||
else
|
||||
emit sourceChanged();
|
||||
}
|
||||
|
||||
bool QDeclarativeMediaBase::isAutoLoad() const
|
||||
{
|
||||
return m_autoLoad;
|
||||
}
|
||||
|
||||
void QDeclarativeMediaBase::setAutoLoad(bool autoLoad)
|
||||
{
|
||||
if (m_autoLoad == autoLoad)
|
||||
return;
|
||||
|
||||
m_autoLoad = autoLoad;
|
||||
emit autoLoadChanged();
|
||||
}
|
||||
|
||||
int QDeclarativeMediaBase::loopCount() const
|
||||
{
|
||||
return m_loopCount;
|
||||
}
|
||||
|
||||
void QDeclarativeMediaBase::setLoopCount(int loopCount)
|
||||
{
|
||||
if (loopCount == 0)
|
||||
loopCount = 1;
|
||||
else if (loopCount < -1)
|
||||
loopCount = -1;
|
||||
|
||||
if (m_loopCount == loopCount) {
|
||||
return;
|
||||
}
|
||||
m_loopCount = loopCount;
|
||||
emit loopCountChanged();
|
||||
}
|
||||
|
||||
bool QDeclarativeMediaBase::isPlaying() const
|
||||
{
|
||||
return m_playing;
|
||||
}
|
||||
|
||||
void QDeclarativeMediaBase::setPlaying(bool playing)
|
||||
{
|
||||
if (playing == m_playing)
|
||||
return;
|
||||
|
||||
if (m_complete) {
|
||||
if (playing) {
|
||||
if (!m_autoLoad && !m_loaded) {
|
||||
m_playerControl->setMedia(m_source, 0);
|
||||
m_playerControl->setPosition(m_position);
|
||||
m_loaded = true;
|
||||
}
|
||||
|
||||
m_runningCount = m_loopCount - 1;
|
||||
|
||||
if (!m_paused)
|
||||
m_playerControl->play();
|
||||
else
|
||||
m_playerControl->pause();
|
||||
} else {
|
||||
m_playerControl->stop();
|
||||
}
|
||||
} else {
|
||||
m_playing = playing;
|
||||
emit playingChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool QDeclarativeMediaBase::isPaused() const
|
||||
{
|
||||
return m_paused;
|
||||
}
|
||||
|
||||
void QDeclarativeMediaBase::setPaused(bool paused)
|
||||
{
|
||||
if (m_paused == paused)
|
||||
return;
|
||||
|
||||
if (m_complete && m_playing) {
|
||||
if (!m_autoLoad && !m_loaded) {
|
||||
m_playerControl->setMedia(m_source, 0);
|
||||
m_playerControl->setPosition(m_position);
|
||||
m_loaded = true;
|
||||
}
|
||||
|
||||
if (!paused)
|
||||
m_playerControl->play();
|
||||
else
|
||||
m_playerControl->pause();
|
||||
} else {
|
||||
m_paused = paused;
|
||||
emit pausedChanged();
|
||||
}
|
||||
}
|
||||
|
||||
int QDeclarativeMediaBase::duration() const
|
||||
{
|
||||
return !m_complete ? 0 : m_playerControl->duration();
|
||||
}
|
||||
|
||||
int QDeclarativeMediaBase::position() const
|
||||
{
|
||||
return !m_complete ? m_position : m_playerControl->position();
|
||||
}
|
||||
|
||||
void QDeclarativeMediaBase::setPosition(int position)
|
||||
{
|
||||
if (this->position() == position)
|
||||
return;
|
||||
|
||||
m_position = position;
|
||||
if (m_complete)
|
||||
m_playerControl->setPosition(m_position);
|
||||
else
|
||||
emit positionChanged();
|
||||
}
|
||||
|
||||
qreal QDeclarativeMediaBase::volume() const
|
||||
{
|
||||
return !m_complete ? m_vol : qreal(m_playerControl->volume()) / 100;
|
||||
}
|
||||
|
||||
void QDeclarativeMediaBase::setVolume(qreal volume)
|
||||
{
|
||||
if (volume < 0 || volume > 1) {
|
||||
qmlInfo(m_qmlObject) << m_qmlObject->tr("volume should be between 0.0 and 1.0");
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_vol == volume)
|
||||
return;
|
||||
|
||||
m_vol = volume;
|
||||
|
||||
if (m_complete)
|
||||
m_playerControl->setVolume(qRound(volume * 100));
|
||||
else
|
||||
emit volumeChanged();
|
||||
}
|
||||
|
||||
bool QDeclarativeMediaBase::isMuted() const
|
||||
{
|
||||
return !m_complete ? m_muted : m_playerControl->isMuted();
|
||||
}
|
||||
|
||||
void QDeclarativeMediaBase::setMuted(bool muted)
|
||||
{
|
||||
if (m_muted == muted)
|
||||
return;
|
||||
|
||||
m_muted = muted;
|
||||
|
||||
if (m_complete)
|
||||
m_playerControl->setMuted(muted);
|
||||
else
|
||||
emit mutedChanged();
|
||||
}
|
||||
|
||||
qreal QDeclarativeMediaBase::bufferProgress() const
|
||||
{
|
||||
return !m_complete ? 0 : qreal(m_playerControl->bufferStatus()) / 100;
|
||||
}
|
||||
|
||||
bool QDeclarativeMediaBase::isSeekable() const
|
||||
{
|
||||
return !m_complete ? false : m_playerControl->isSeekable();
|
||||
}
|
||||
|
||||
qreal QDeclarativeMediaBase::playbackRate() const
|
||||
{
|
||||
return m_playbackRate;
|
||||
}
|
||||
|
||||
void QDeclarativeMediaBase::setPlaybackRate(qreal rate)
|
||||
{
|
||||
if (m_playbackRate == rate)
|
||||
return;
|
||||
|
||||
m_playbackRate = rate;
|
||||
|
||||
if (m_complete)
|
||||
m_playerControl->setPlaybackRate(m_playbackRate);
|
||||
else
|
||||
emit playbackRateChanged();
|
||||
}
|
||||
|
||||
QString QDeclarativeMediaBase::errorString() const
|
||||
{
|
||||
return m_errorString;
|
||||
}
|
||||
|
||||
QDeclarativeMediaMetaData *QDeclarativeMediaBase::metaData() const
|
||||
{
|
||||
return m_metaData.data();
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
187
src/imports/multimedia/qdeclarativemediabase_p.h
Normal file
187
src/imports/multimedia/qdeclarativemediabase_p.h
Normal file
@@ -0,0 +1,187 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVEMEDIABASE_P_H
|
||||
#define QDECLARATIVEMEDIABASE_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of other Qt classes. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/qbasictimer.h>
|
||||
#include <qmediaplayer.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QMediaPlayerControl;
|
||||
class QMediaService;
|
||||
class QMediaServiceProvider;
|
||||
class QMetaDataReaderControl;
|
||||
class QDeclarativeMediaBaseAnimation;
|
||||
class QDeclarativeMediaMetaData;
|
||||
|
||||
class QDeclarativeMediaBase
|
||||
{
|
||||
public:
|
||||
enum Loop {
|
||||
INFINITE = -1
|
||||
};
|
||||
|
||||
QDeclarativeMediaBase();
|
||||
virtual ~QDeclarativeMediaBase();
|
||||
|
||||
QUrl source() const;
|
||||
void setSource(const QUrl &url);
|
||||
|
||||
bool isAutoLoad() const;
|
||||
void setAutoLoad(bool autoLoad);
|
||||
|
||||
int loopCount() const;
|
||||
void setLoopCount(int loopCount);
|
||||
|
||||
bool isPlaying() const;
|
||||
void setPlaying(bool playing);
|
||||
|
||||
bool isPaused() const;
|
||||
void setPaused(bool paused);
|
||||
|
||||
int duration() const;
|
||||
|
||||
int position() const;
|
||||
void setPosition(int position);
|
||||
|
||||
qreal volume() const;
|
||||
void setVolume(qreal volume);
|
||||
|
||||
bool isMuted() const;
|
||||
void setMuted(bool muted);
|
||||
|
||||
qreal bufferProgress() const;
|
||||
|
||||
bool isSeekable() const;
|
||||
|
||||
qreal playbackRate() const;
|
||||
void setPlaybackRate(qreal rate);
|
||||
|
||||
QString errorString() const;
|
||||
|
||||
QDeclarativeMediaMetaData *metaData() const;
|
||||
|
||||
void _q_statusChanged();
|
||||
|
||||
void _q_metaDataChanged();
|
||||
|
||||
void componentComplete();
|
||||
|
||||
protected:
|
||||
void shutdown();
|
||||
|
||||
void setObject(QObject *object);
|
||||
|
||||
virtual void sourceChanged() = 0;
|
||||
virtual void autoLoadChanged() = 0;
|
||||
virtual void playingChanged() = 0;
|
||||
virtual void pausedChanged() = 0;
|
||||
virtual void loopCountChanged() = 0;
|
||||
|
||||
virtual void started() = 0;
|
||||
virtual void resumed() = 0;
|
||||
virtual void paused() = 0;
|
||||
virtual void stopped() = 0;
|
||||
|
||||
virtual void statusChanged() = 0;
|
||||
|
||||
virtual void durationChanged() = 0;
|
||||
virtual void positionChanged() = 0;
|
||||
|
||||
virtual void volumeChanged() = 0;
|
||||
virtual void mutedChanged() = 0;
|
||||
|
||||
virtual void bufferProgressChanged() = 0;
|
||||
|
||||
virtual void seekableChanged() = 0;
|
||||
virtual void playbackRateChanged() = 0;
|
||||
|
||||
virtual void errorChanged() = 0;
|
||||
|
||||
bool m_paused;
|
||||
bool m_playing;
|
||||
bool m_autoLoad;
|
||||
bool m_loaded;
|
||||
bool m_muted;
|
||||
bool m_complete;
|
||||
int m_loopCount;
|
||||
int m_runningCount;
|
||||
int m_position;
|
||||
qreal m_vol;
|
||||
qreal m_playbackRate;
|
||||
QMediaService *m_mediaService;
|
||||
QMediaPlayerControl *m_playerControl;
|
||||
|
||||
QObject *m_qmlObject;
|
||||
QMediaObject *m_mediaObject;
|
||||
QMediaServiceProvider *m_mediaProvider;
|
||||
QMetaDataReaderControl *m_metaDataControl;
|
||||
QDeclarativeMediaBaseAnimation *m_animation;
|
||||
QScopedPointer<QDeclarativeMediaMetaData> m_metaData;
|
||||
|
||||
QMediaPlayer::MediaStatus m_status;
|
||||
QMediaPlayer::Error m_error;
|
||||
QString m_errorString;
|
||||
QUrl m_source;
|
||||
|
||||
friend class QDeclarativeMediaBaseAnimation;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
||||
185
src/imports/multimedia/qdeclarativemediametadata_p.h
Normal file
185
src/imports/multimedia/qdeclarativemediametadata_p.h
Normal file
@@ -0,0 +1,185 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVEMEDIAMETADATA_P_H
|
||||
#define QDECLARATIVEMEDIAMETADATA_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of other Qt classes. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <qmetadatareadercontrol.h>
|
||||
|
||||
#include <qdeclarative.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDeclarativeMediaMetaData : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QVariant title READ title NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant subTitle READ subTitle NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant author READ author NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant comment READ comment NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant description READ description NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant category READ category NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant genre READ genre NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant year READ year NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant date READ date NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant userRating READ userRating NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant keywords READ keywords NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant language READ language NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant publisher READ publisher NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant copyright READ copyright NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant parentalRating READ parentalRating NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant ratingOrganisation READ ratingOrganisation NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant size READ size NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant mediaType READ mediaType NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant duration READ duration NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant audioBitRate READ audioBitRate NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant audioCodec READ audioCodec NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant averageLevel READ averageLevel NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant channelCount READ channelCount NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant peakValue READ peakValue NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant sampleRate READ sampleRate NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant albumTitle READ albumTitle NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant albumArtist READ albumArtist NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant contributingArtist READ contributingArtist NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant composer READ composer NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant conductor READ conductor NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant lyrics READ lyrics NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant mood READ mood NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant trackNumber READ trackNumber NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant trackCount READ trackCount NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant coverArtUrlSmall READ coverArtUrlSmall NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant coverArtUrlLarge READ coverArtUrlLarge NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant resolution READ resolution NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant pixelAspectRatio READ pixelAspectRatio NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant videoFrameRate READ videoFrameRate NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant videoBitRate READ videoBitRate NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant videoCodec READ videoCodec NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant posterUrl READ posterUrl NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant chapterNumber READ chapterNumber NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant director READ director NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant leadPerformer READ leadPerformer NOTIFY metaDataChanged)
|
||||
Q_PROPERTY(QVariant writer READ writer NOTIFY metaDataChanged)
|
||||
public:
|
||||
QDeclarativeMediaMetaData(QMetaDataReaderControl *control, QObject *parent = 0)
|
||||
: QObject(parent)
|
||||
, m_control(control)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant title() const { return m_control->metaData(QtMultimediaKit::Title); }
|
||||
QVariant subTitle() const { return m_control->metaData(QtMultimediaKit::SubTitle); }
|
||||
QVariant author() const { return m_control->metaData(QtMultimediaKit::Author); }
|
||||
QVariant comment() const { return m_control->metaData(QtMultimediaKit::Comment); }
|
||||
QVariant description() const { return m_control->metaData(QtMultimediaKit::Description); }
|
||||
QVariant category() const { return m_control->metaData(QtMultimediaKit::Category); }
|
||||
QVariant genre() const { return m_control->metaData(QtMultimediaKit::Genre); }
|
||||
QVariant year() const { return m_control->metaData(QtMultimediaKit::Year); }
|
||||
QVariant date() const { return m_control->metaData(QtMultimediaKit::Date); }
|
||||
QVariant userRating() const { return m_control->metaData(QtMultimediaKit::UserRating); }
|
||||
QVariant keywords() const { return m_control->metaData(QtMultimediaKit::Keywords); }
|
||||
QVariant language() const { return m_control->metaData(QtMultimediaKit::Language); }
|
||||
QVariant publisher() const { return m_control->metaData(QtMultimediaKit::Publisher); }
|
||||
QVariant copyright() const { return m_control->metaData(QtMultimediaKit::Copyright); }
|
||||
QVariant parentalRating() const { return m_control->metaData(QtMultimediaKit::ParentalRating); }
|
||||
QVariant ratingOrganisation() const {
|
||||
return m_control->metaData(QtMultimediaKit::RatingOrganisation); }
|
||||
QVariant size() const { return m_control->metaData(QtMultimediaKit::Size); }
|
||||
QVariant mediaType() const { return m_control->metaData(QtMultimediaKit::MediaType); }
|
||||
QVariant duration() const { return m_control->metaData(QtMultimediaKit::Duration); }
|
||||
QVariant audioBitRate() const { return m_control->metaData(QtMultimediaKit::AudioBitRate); }
|
||||
QVariant audioCodec() const { return m_control->metaData(QtMultimediaKit::AudioCodec); }
|
||||
QVariant averageLevel() const { return m_control->metaData(QtMultimediaKit::AverageLevel); }
|
||||
QVariant channelCount() const { return m_control->metaData(QtMultimediaKit::ChannelCount); }
|
||||
QVariant peakValue() const { return m_control->metaData(QtMultimediaKit::PeakValue); }
|
||||
QVariant sampleRate() const { return m_control->metaData(QtMultimediaKit::SampleRate); }
|
||||
QVariant albumTitle() const { return m_control->metaData(QtMultimediaKit::AlbumTitle); }
|
||||
QVariant albumArtist() const { return m_control->metaData(QtMultimediaKit::AlbumArtist); }
|
||||
QVariant contributingArtist() const {
|
||||
return m_control->metaData(QtMultimediaKit::ContributingArtist); }
|
||||
QVariant composer() const { return m_control->metaData(QtMultimediaKit::Composer); }
|
||||
QVariant conductor() const { return m_control->metaData(QtMultimediaKit::Conductor); }
|
||||
QVariant lyrics() const { return m_control->metaData(QtMultimediaKit::Lyrics); }
|
||||
QVariant mood() const { return m_control->metaData(QtMultimediaKit::Mood); }
|
||||
QVariant trackNumber() const { return m_control->metaData(QtMultimediaKit::TrackNumber); }
|
||||
QVariant trackCount() const { return m_control->metaData(QtMultimediaKit::TrackCount); }
|
||||
QVariant coverArtUrlSmall() const {
|
||||
return m_control->metaData(QtMultimediaKit::CoverArtUrlSmall); }
|
||||
QVariant coverArtUrlLarge() const {
|
||||
return m_control->metaData(QtMultimediaKit::CoverArtUrlLarge); }
|
||||
QVariant resolution() const { return m_control->metaData(QtMultimediaKit::Resolution); }
|
||||
QVariant pixelAspectRatio() const {
|
||||
return m_control->metaData(QtMultimediaKit::PixelAspectRatio); }
|
||||
QVariant videoFrameRate() const { return m_control->metaData(QtMultimediaKit::VideoFrameRate); }
|
||||
QVariant videoBitRate() const { return m_control->metaData(QtMultimediaKit::VideoBitRate); }
|
||||
QVariant videoCodec() const { return m_control->metaData(QtMultimediaKit::VideoCodec); }
|
||||
QVariant posterUrl() const { return m_control->metaData(QtMultimediaKit::PosterUrl); }
|
||||
QVariant chapterNumber() const { return m_control->metaData(QtMultimediaKit::ChapterNumber); }
|
||||
QVariant director() const { return m_control->metaData(QtMultimediaKit::Director); }
|
||||
QVariant leadPerformer() const { return m_control->metaData(QtMultimediaKit::LeadPerformer); }
|
||||
QVariant writer() const { return m_control->metaData(QtMultimediaKit::Writer); }
|
||||
|
||||
Q_SIGNALS:
|
||||
void metaDataChanged();
|
||||
|
||||
private:
|
||||
QMetaDataReaderControl *m_control;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeMediaMetaData))
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
||||
951
src/imports/multimedia/qdeclarativevideo.cpp
Normal file
951
src/imports/multimedia/qdeclarativevideo.cpp
Normal file
@@ -0,0 +1,951 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdeclarativevideo_p.h"
|
||||
|
||||
#include <qmediaplayercontrol.h>
|
||||
#include <qmediaservice.h>
|
||||
#include <private/qpaintervideosurface_p.h>
|
||||
#include <qvideorenderercontrol.h>
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
void QDeclarativeVideo::_q_nativeSizeChanged(const QSizeF &size)
|
||||
{
|
||||
setImplicitWidth(size.width());
|
||||
setImplicitHeight(size.height());
|
||||
}
|
||||
|
||||
void QDeclarativeVideo::_q_error(int errorCode, const QString &errorString)
|
||||
{
|
||||
m_error = QMediaPlayer::Error(errorCode);
|
||||
m_errorString = errorString;
|
||||
|
||||
emit error(Error(errorCode), errorString);
|
||||
emit errorChanged();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\qmlclass Video QDeclarativeVideo
|
||||
\brief The Video element allows you to add videos to a scene.
|
||||
\inherits Item
|
||||
\ingroup qml-multimedia
|
||||
|
||||
This element is part of the \bold{QtMultimediaKit 1.1} module.
|
||||
|
||||
\qml
|
||||
import Qt 4.7
|
||||
import QtMultimediaKit 1.1
|
||||
|
||||
Video {
|
||||
id: video
|
||||
width : 800
|
||||
height : 600
|
||||
source: "video.avi"
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
video.play()
|
||||
}
|
||||
}
|
||||
|
||||
focus: true
|
||||
Keys.onSpacePressed: video.paused = !video.paused
|
||||
Keys.onLeftPressed: video.position -= 5000
|
||||
Keys.onRightPressed: video.position += 5000
|
||||
}
|
||||
\endqml
|
||||
|
||||
The Video item supports untransformed, stretched, and uniformly scaled video presentation.
|
||||
For a description of stretched uniformly scaled presentation, see the \l fillMode property
|
||||
description.
|
||||
|
||||
The Video item is only visible when the \l hasVideo property is true and the video is playing.
|
||||
|
||||
\sa Audio
|
||||
*/
|
||||
|
||||
/*!
|
||||
\internal
|
||||
\class QDeclarativeVideo
|
||||
\brief The QDeclarativeVideo class provides a video item that you can add to a QDeclarativeView.
|
||||
*/
|
||||
|
||||
QDeclarativeVideo::QDeclarativeVideo(QDeclarativeItem *parent)
|
||||
: QDeclarativeItem(parent)
|
||||
, m_graphicsItem(0)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
QDeclarativeVideo::~QDeclarativeVideo()
|
||||
{
|
||||
shutdown();
|
||||
|
||||
delete m_graphicsItem;
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlproperty url Video::source
|
||||
|
||||
This property holds the source URL of the media.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty url Video::autoLoad
|
||||
|
||||
This property indicates if loading of media should begin immediately.
|
||||
|
||||
Defaults to true, if false media will not be loaded until playback is started.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty bool Video::playing
|
||||
|
||||
This property holds whether the media is playing.
|
||||
|
||||
Defaults to false, and can be set to true to start playback.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty bool Video::paused
|
||||
|
||||
This property holds whether the media is paused.
|
||||
|
||||
Defaults to false, and can be set to true to pause playback.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Video::onStarted()
|
||||
|
||||
This handler is called when playback is started.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Video::onResumed()
|
||||
|
||||
This handler is called when playback is resumed from the paused state.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Video::onPaused()
|
||||
|
||||
This handler is called when playback is paused.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Video::onStopped()
|
||||
|
||||
This handler is called when playback is stopped.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty enumeration Video::status
|
||||
|
||||
This property holds the status of media loading. It can be one of:
|
||||
|
||||
\list
|
||||
\o NoMedia - no media has been set.
|
||||
\o Loading - the media is currently being loaded.
|
||||
\o Loaded - the media has been loaded.
|
||||
\o Buffering - the media is buffering data.
|
||||
\o Stalled - playback has been interrupted while the media is buffering data.
|
||||
\o Buffered - the media has buffered data.
|
||||
\o EndOfMedia - the media has played to the end.
|
||||
\o InvalidMedia - the media cannot be played.
|
||||
\o UnknownStatus - the status of the media is cannot be determined.
|
||||
\endlist
|
||||
*/
|
||||
|
||||
QDeclarativeVideo::Status QDeclarativeVideo::status() const
|
||||
{
|
||||
return Status(m_status);
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlproperty int Video::duration
|
||||
|
||||
This property holds the duration of the media in milliseconds.
|
||||
|
||||
If the media doesn't have a fixed duration (a live stream for example) this will be 0.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty int Video::position
|
||||
|
||||
This property holds the current playback position in milliseconds.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty real Video::volume
|
||||
|
||||
This property holds the volume of the audio output, from 0.0 (silent) to 1.0 (maximum volume).
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty bool Video::muted
|
||||
|
||||
This property holds whether the audio output is muted.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty bool Video::hasAudio
|
||||
|
||||
This property holds whether the media contains audio.
|
||||
*/
|
||||
|
||||
bool QDeclarativeVideo::hasAudio() const
|
||||
{
|
||||
return !m_complete ? false : m_playerControl->isAudioAvailable();
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlproperty bool Video::hasVideo
|
||||
|
||||
This property holds whether the media contains video.
|
||||
*/
|
||||
|
||||
bool QDeclarativeVideo::hasVideo() const
|
||||
{
|
||||
return !m_complete ? false : m_playerControl->isVideoAvailable();
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlproperty real Video::bufferProgress
|
||||
|
||||
This property holds how much of the data buffer is currently filled, from 0.0 (empty) to 1.0
|
||||
(full).
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty bool Video::seekable
|
||||
|
||||
This property holds whether position of the video can be changed.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty real Video::playbackRate
|
||||
|
||||
This property holds the rate at which video is played at as a multiple of the normal rate.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty enumeration Video::error
|
||||
|
||||
This property holds the error state of the video. It can be one of:
|
||||
|
||||
\list
|
||||
\o NoError - there is no current error.
|
||||
\o ResourceError - the video cannot be played due to a problem allocating resources.
|
||||
\o FormatError - the video format is not supported.
|
||||
\o NetworkError - the video cannot be played due to network issues.
|
||||
\o AccessDenied - the video cannot be played due to insufficient permissions.
|
||||
\o ServiceMissing - the video cannot be played because the media service could not be
|
||||
instantiated.
|
||||
\endlist
|
||||
*/
|
||||
|
||||
|
||||
QDeclarativeVideo::Error QDeclarativeVideo::error() const
|
||||
{
|
||||
return Error(m_error);
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlproperty string Video::errorString
|
||||
|
||||
This property holds a string describing the current error condition in more detail.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Video::onError(error, errorString)
|
||||
|
||||
This handler is called when an \l {QMediaPlayer::Error}{error} has
|
||||
occurred. The errorString parameter may contain more detailed
|
||||
information about the error.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty enumeration Video::fillMode
|
||||
|
||||
Set this property to define how the video is scaled to fit the target area.
|
||||
|
||||
\list
|
||||
\o Stretch - the video is scaled to fit.
|
||||
\o PreserveAspectFit - the video is scaled uniformly to fit without cropping
|
||||
\o PreserveAspectCrop - the video is scaled uniformly to fill, cropping if necessary
|
||||
\endlist
|
||||
|
||||
The default fill mode is PreserveAspectFit.
|
||||
*/
|
||||
|
||||
QDeclarativeVideo::FillMode QDeclarativeVideo::fillMode() const
|
||||
{
|
||||
return FillMode(m_graphicsItem->aspectRatioMode());
|
||||
}
|
||||
|
||||
void QDeclarativeVideo::setFillMode(FillMode mode)
|
||||
{
|
||||
m_graphicsItem->setAspectRatioMode(Qt::AspectRatioMode(mode));
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlmethod Video::play()
|
||||
|
||||
Starts playback of the media.
|
||||
|
||||
Sets the \l playing property to true, and the \l paused property to false.
|
||||
*/
|
||||
|
||||
void QDeclarativeVideo::play()
|
||||
{
|
||||
if (!m_complete)
|
||||
return;
|
||||
|
||||
setPaused(false);
|
||||
setPlaying(true);
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlmethod Video::pause()
|
||||
|
||||
Pauses playback of the media.
|
||||
|
||||
Sets the \l playing and \l paused properties to true.
|
||||
*/
|
||||
|
||||
void QDeclarativeVideo::pause()
|
||||
{
|
||||
if (!m_complete)
|
||||
return;
|
||||
|
||||
setPaused(true);
|
||||
setPlaying(true);
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlmethod Video::stop()
|
||||
|
||||
Stops playback of the media.
|
||||
|
||||
Sets the \l playing and \l paused properties to false.
|
||||
*/
|
||||
|
||||
void QDeclarativeVideo::stop()
|
||||
{
|
||||
if (!m_complete)
|
||||
return;
|
||||
|
||||
setPlaying(false);
|
||||
setPaused(false);
|
||||
}
|
||||
|
||||
void QDeclarativeVideo::paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
|
||||
{
|
||||
}
|
||||
|
||||
void QDeclarativeVideo::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
|
||||
{
|
||||
m_graphicsItem->setSize(newGeometry.size());
|
||||
|
||||
QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
|
||||
}
|
||||
|
||||
void QDeclarativeVideo::classBegin()
|
||||
{
|
||||
m_graphicsItem = new QGraphicsVideoItem(this);
|
||||
connect(m_graphicsItem, SIGNAL(nativeSizeChanged(QSizeF)),
|
||||
this, SLOT(_q_nativeSizeChanged(QSizeF)));
|
||||
|
||||
setObject(this);
|
||||
|
||||
if (m_mediaService) {
|
||||
connect(m_playerControl, SIGNAL(audioAvailableChanged(bool)),
|
||||
this, SIGNAL(hasAudioChanged()));
|
||||
connect(m_playerControl, SIGNAL(videoAvailableChanged(bool)),
|
||||
this, SIGNAL(hasVideoChanged()));
|
||||
|
||||
m_mediaObject->bind(m_graphicsItem);
|
||||
}
|
||||
}
|
||||
|
||||
void QDeclarativeVideo::componentComplete()
|
||||
{
|
||||
QDeclarativeMediaBase::componentComplete();
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
// ***************************************
|
||||
// Documentation for meta-data properties.
|
||||
// ***************************************
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.title
|
||||
|
||||
This property holds the tile of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Title}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.subTitle
|
||||
|
||||
This property holds the sub-title of the media.
|
||||
|
||||
\sa {QtMultimediaKit::SubTitle}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.author
|
||||
|
||||
This property holds the author of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Author}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.comment
|
||||
|
||||
This property holds a user comment about the media.
|
||||
|
||||
\sa {QtMultimediaKit::Comment}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.description
|
||||
|
||||
This property holds a description of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Description}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.category
|
||||
|
||||
This property holds the category of the media
|
||||
|
||||
\sa {QtMultimediaKit::Category}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.genre
|
||||
|
||||
This property holds the genre of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Genre}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.year
|
||||
|
||||
This property holds the year of release of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Year}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.date
|
||||
|
||||
This property holds the date of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Date}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.userRating
|
||||
|
||||
This property holds a user rating of the media in the range of 0 to 100.
|
||||
|
||||
\sa {QtMultimediaKit::UserRating}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.keywords
|
||||
|
||||
This property holds a list of keywords describing the media.
|
||||
|
||||
\sa {QtMultimediaKit::Keywords}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.language
|
||||
|
||||
This property holds the language of the media, as an ISO 639-2 code.
|
||||
|
||||
\sa {QtMultimediaKit::Language}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.publisher
|
||||
|
||||
This property holds the publisher of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Publisher}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.copyright
|
||||
|
||||
This property holds the media's copyright notice.
|
||||
|
||||
\sa {QtMultimediaKit::Copyright}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.parentalRating
|
||||
|
||||
This property holds the parental rating of the media.
|
||||
|
||||
\sa {QtMultimediaKit::ParentalRating}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.ratingOrganisation
|
||||
|
||||
This property holds the name of the rating organisation responsible for the
|
||||
parental rating of the media.
|
||||
|
||||
\sa {QtMultimediaKit::RatingOrganisation}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.size
|
||||
|
||||
This property property holds the size of the media in bytes.
|
||||
|
||||
\sa {QtMultimediaKit::Size}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.mediaType
|
||||
|
||||
This property holds the type of the media.
|
||||
|
||||
\sa {QtMultimediaKit::MediaType}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.audioBitRate
|
||||
|
||||
This property holds the bit rate of the media's audio stream ni bits per
|
||||
second.
|
||||
|
||||
\sa {QtMultimediaKit::AudioBitRate}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.audioCodec
|
||||
|
||||
This property holds the encoding of the media audio stream.
|
||||
|
||||
\sa {QtMultimediaKit::AudioCodec}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.averageLevel
|
||||
|
||||
This property holds the average volume level of the media.
|
||||
|
||||
\sa {QtMultimediaKit::AverageLevel}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.channelCount
|
||||
|
||||
This property holds the number of channels in the media's audio stream.
|
||||
|
||||
\sa {QtMultimediaKit::ChannelCount}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.peakValue
|
||||
|
||||
This property holds the peak volume of media's audio stream.
|
||||
|
||||
\sa {QtMultimediaKit::PeakValue}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.sampleRate
|
||||
|
||||
This property holds the sample rate of the media's audio stream in hertz.
|
||||
|
||||
\sa {QtMultimediaKit::SampleRate}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.albumTitle
|
||||
|
||||
This property holds the title of the album the media belongs to.
|
||||
|
||||
\sa {QtMultimediaKit::AlbumTitle}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.albumArtist
|
||||
|
||||
This property holds the name of the principal artist of the album the media
|
||||
belongs to.
|
||||
|
||||
\sa {QtMultimediaKit::AlbumArtist}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.contributingArtist
|
||||
|
||||
This property holds the names of artists contributing to the media.
|
||||
|
||||
\sa {QtMultimediaKit::ContributingArtist}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.composer
|
||||
|
||||
This property holds the composer of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Composer}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.conductor
|
||||
|
||||
This property holds the conductor of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Conductor}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.lyrics
|
||||
|
||||
This property holds the lyrics to the media.
|
||||
|
||||
\sa {QtMultimediaKit::Lyrics}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.mood
|
||||
|
||||
This property holds the mood of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Mood}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.trackNumber
|
||||
|
||||
This property holds the track number of the media.
|
||||
|
||||
\sa {QtMultimediaKit::TrackNumber}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.trackCount
|
||||
|
||||
This property holds the number of track on the album containing the media.
|
||||
|
||||
\sa {QtMultimediaKit::TrackNumber}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.coverArtUrlSmall
|
||||
|
||||
This property holds the URL of a small cover art image.
|
||||
|
||||
\sa {QtMultimediaKit::CoverArtUrlSmall}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.coverArtUrlLarge
|
||||
|
||||
This property holds the URL of a large cover art image.
|
||||
|
||||
\sa {QtMultimediaKit::CoverArtUrlLarge}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.resolution
|
||||
|
||||
This property holds the dimension of an image or video.
|
||||
|
||||
\sa {QtMultimediaKit::Resolution}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.pixelAspectRatio
|
||||
|
||||
This property holds the pixel aspect ratio of an image or video.
|
||||
|
||||
\sa {QtMultimediaKit::PixelAspectRatio}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.videoFrameRate
|
||||
|
||||
This property holds the frame rate of the media's video stream.
|
||||
|
||||
\sa {QtMultimediaKit::VideoFrameRate}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.videoBitRate
|
||||
|
||||
This property holds the bit rate of the media's video stream in bits per
|
||||
second.
|
||||
|
||||
\sa {QtMultimediaKit::VideoBitRate}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.videoCodec
|
||||
|
||||
This property holds the encoding of the media's video stream.
|
||||
|
||||
\sa {QtMultimediaKit::VideoCodec}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.posterUrl
|
||||
|
||||
This property holds the URL of a poster image.
|
||||
|
||||
\sa {QtMultimediaKit::PosterUrl}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.chapterNumber
|
||||
|
||||
This property holds the chapter number of the media.
|
||||
|
||||
\sa {QtMultimediaKit::ChapterNumber}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.director
|
||||
|
||||
This property holds the director of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Director}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.leadPerformer
|
||||
|
||||
This property holds the lead performer in the media.
|
||||
|
||||
\sa {QtMultimediaKit::LeadPerformer}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.writer
|
||||
|
||||
This property holds the writer of the media.
|
||||
|
||||
\sa {QtMultimediaKit::Writer}
|
||||
*/
|
||||
|
||||
// The remaining properties are related to photos, and are technically
|
||||
// available but will certainly never have values.
|
||||
#ifndef Q_QDOC
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.cameraManufacturer
|
||||
|
||||
\sa {QtMultimediaKit::CameraManufacturer}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.cameraModel
|
||||
|
||||
\sa {QtMultimediaKit::CameraModel}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.event
|
||||
|
||||
\sa {QtMultimediaKit::Event}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.subject
|
||||
|
||||
\sa {QtMultimediaKit::Subject}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.orientation
|
||||
|
||||
\sa {QtMultimediaKit::Orientation}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.exposureTime
|
||||
|
||||
\sa {QtMultimediaKit::ExposureTime}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.fNumber
|
||||
|
||||
\sa {QtMultimediaKit::FNumber}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.exposureProgram
|
||||
|
||||
\sa {QtMultimediaKit::ExposureProgram}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.isoSpeedRatings
|
||||
|
||||
\sa {QtMultimediaKit::ISOSpeedRatings}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.exposureBiasValue
|
||||
|
||||
\sa {QtMultimediaKit::ExposureBiasValue}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.dateTimeDigitized
|
||||
|
||||
\sa {QtMultimediaKit::DateTimeDigitized}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.subjectDistance
|
||||
|
||||
\sa {QtMultimediaKit::SubjectDistance}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.meteringMode
|
||||
|
||||
\sa {QtMultimediaKit::MeteringMode}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.lightSource
|
||||
|
||||
\sa {QtMultimediaKit::LightSource}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.flash
|
||||
|
||||
\sa {QtMultimediaKit::Flash}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.focalLength
|
||||
|
||||
\sa {QtMultimediaKit::FocalLength}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.exposureMode
|
||||
|
||||
\sa {QtMultimediaKit::ExposureMode}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.whiteBalance
|
||||
|
||||
\sa {QtMultimediaKit::WhiteBalance}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.DigitalZoomRatio
|
||||
|
||||
\sa {QtMultimediaKit::DigitalZoomRatio}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.focalLengthIn35mmFilm
|
||||
|
||||
\sa {QtMultimediaKit::FocalLengthIn35mmFile}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.sceneCaptureType
|
||||
|
||||
\sa {QtMultimediaKit::SceneCaptureType}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.gainControl
|
||||
|
||||
\sa {QtMultimediaKit::GainControl}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.contrast
|
||||
|
||||
\sa {QtMultimediaKit::contrast}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.saturation
|
||||
|
||||
\sa {QtMultimediaKit::Saturation}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.sharpness
|
||||
|
||||
\sa {QtMultimediaKit::Sharpness}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlproperty variant Video::metaData.deviceSettingDescription
|
||||
|
||||
\sa {QtMultimediaKit::DeviceSettingDescription}
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
#include "moc_qdeclarativevideo_p.cpp"
|
||||
202
src/imports/multimedia/qdeclarativevideo_p.h
Normal file
202
src/imports/multimedia/qdeclarativevideo_p.h
Normal file
@@ -0,0 +1,202 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** No Commercial Usage
|
||||
** This file contains pre-release code and may not be distributed.
|
||||
** You may use this file in accordance with the terms and conditions
|
||||
** contained in the Technology Preview License Agreement accompanying
|
||||
** this package.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, 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.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at qt-info@nokia.com.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVEVIDEO_H
|
||||
#define QDECLARATIVEVIDEO_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of other Qt classes. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qdeclarativemediabase_p.h"
|
||||
|
||||
#include <qgraphicsvideoitem.h>
|
||||
|
||||
#include <QtCore/qbasictimer.h>
|
||||
#include <QtDeclarative/qdeclarativeitem.h>
|
||||
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QTimerEvent;
|
||||
class QVideoSurfaceFormat;
|
||||
|
||||
|
||||
class QDeclarativeVideo : public QDeclarativeItem, public QDeclarativeMediaBase
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
|
||||
Q_PROPERTY(bool autoLoad READ isAutoLoad WRITE setAutoLoad NOTIFY autoLoadChanged)
|
||||
Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
|
||||
Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
|
||||
Q_PROPERTY(Status status READ status NOTIFY statusChanged)
|
||||
Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
|
||||
Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
|
||||
Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
|
||||
Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
|
||||
Q_PROPERTY(bool hasAudio READ hasAudio NOTIFY hasAudioChanged)
|
||||
Q_PROPERTY(bool hasVideo READ hasVideo NOTIFY hasVideoChanged)
|
||||
Q_PROPERTY(int bufferProgress READ bufferProgress NOTIFY bufferProgressChanged)
|
||||
Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged)
|
||||
Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged)
|
||||
Q_PROPERTY(Error error READ error NOTIFY errorChanged)
|
||||
Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
|
||||
Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode)
|
||||
Q_PROPERTY(QDeclarativeMediaMetaData *metaData READ metaData CONSTANT)
|
||||
Q_ENUMS(FillMode)
|
||||
Q_ENUMS(Status)
|
||||
Q_ENUMS(Error)
|
||||
public:
|
||||
enum FillMode
|
||||
{
|
||||
Stretch = Qt::IgnoreAspectRatio,
|
||||
PreserveAspectFit = Qt::KeepAspectRatio,
|
||||
PreserveAspectCrop = Qt::KeepAspectRatioByExpanding
|
||||
};
|
||||
|
||||
enum Status
|
||||
{
|
||||
UnknownStatus = QMediaPlayer::UnknownMediaStatus,
|
||||
NoMedia = QMediaPlayer::NoMedia,
|
||||
Loading = QMediaPlayer::LoadingMedia,
|
||||
Loaded = QMediaPlayer::LoadedMedia,
|
||||
Stalled = QMediaPlayer::StalledMedia,
|
||||
Buffering = QMediaPlayer::BufferingMedia,
|
||||
Buffered = QMediaPlayer::BufferedMedia,
|
||||
EndOfMedia = QMediaPlayer::EndOfMedia,
|
||||
InvalidMedia = QMediaPlayer::InvalidMedia
|
||||
};
|
||||
|
||||
enum Error
|
||||
{
|
||||
NoError = QMediaPlayer::NoError,
|
||||
ResourceError = QMediaPlayer::ResourceError,
|
||||
FormatError = QMediaPlayer::FormatError,
|
||||
NetworkError = QMediaPlayer::NetworkError,
|
||||
AccessDenied = QMediaPlayer::AccessDeniedError,
|
||||
ServiceMissing = QMediaPlayer::ServiceMissingError
|
||||
};
|
||||
|
||||
QDeclarativeVideo(QDeclarativeItem *parent = 0);
|
||||
~QDeclarativeVideo();
|
||||
|
||||
bool hasAudio() const;
|
||||
bool hasVideo() const;
|
||||
|
||||
FillMode fillMode() const;
|
||||
void setFillMode(FillMode mode);
|
||||
|
||||
Status status() const;
|
||||
Error error() const;
|
||||
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||
|
||||
void classBegin();
|
||||
void componentComplete();
|
||||
|
||||
public Q_SLOTS:
|
||||
void play();
|
||||
void pause();
|
||||
void stop();
|
||||
|
||||
Q_SIGNALS:
|
||||
void sourceChanged();
|
||||
void autoLoadChanged();
|
||||
void playingChanged();
|
||||
void pausedChanged();
|
||||
void loopCountChanged();
|
||||
|
||||
void started();
|
||||
void resumed();
|
||||
void paused();
|
||||
void stopped();
|
||||
|
||||
void statusChanged();
|
||||
|
||||
void durationChanged();
|
||||
void positionChanged();
|
||||
|
||||
void volumeChanged();
|
||||
void mutedChanged();
|
||||
void hasAudioChanged();
|
||||
void hasVideoChanged();
|
||||
|
||||
void bufferProgressChanged();
|
||||
|
||||
void seekableChanged();
|
||||
void playbackRateChanged();
|
||||
|
||||
void errorChanged();
|
||||
void error(QDeclarativeVideo::Error error, const QString &errorString);
|
||||
|
||||
protected:
|
||||
void geometryChanged(const QRectF &geometry, const QRectF &);
|
||||
|
||||
private Q_SLOTS:
|
||||
void _q_nativeSizeChanged(const QSizeF &size);
|
||||
void _q_error(int, const QString &);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QDeclarativeVideo)
|
||||
|
||||
QGraphicsVideoItem *m_graphicsItem;
|
||||
|
||||
Q_PRIVATE_SLOT(mediaBase(), void _q_statusChanged())
|
||||
|
||||
inline QDeclarativeMediaBase *mediaBase() { return this; }
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeVideo))
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif
|
||||
1
src/imports/multimedia/qmldir
Normal file
1
src/imports/multimedia/qmldir
Normal file
@@ -0,0 +1 @@
|
||||
plugin declarative_multimedia
|
||||
Reference in New Issue
Block a user