qtmobility/plugins/declarative/multimedia/qdeclarativevideo_p.h
changeset 14 6fbed849b4f4
equal deleted inserted replaced
11:06b8e2af4411 14:6fbed849b4f4
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QDECLARATIVEVIDEO_H
       
    43 #define QDECLARATIVEVIDEO_H
       
    44 
       
    45 //
       
    46 //  W A R N I N G
       
    47 //  -------------
       
    48 //
       
    49 // This file is not part of the Qt API.  It exists for the convenience
       
    50 // of other Qt classes.  This header file may change from version to
       
    51 // version without notice, or even be removed.
       
    52 //
       
    53 // We mean it.
       
    54 //
       
    55 
       
    56 #include "qdeclarativemediabase_p.h"
       
    57 
       
    58 #include <qgraphicsvideoitem.h>
       
    59 
       
    60 #include <QtCore/qbasictimer.h>
       
    61 #include <QtDeclarative/qdeclarativeitem.h>
       
    62 
       
    63 
       
    64 QT_BEGIN_HEADER
       
    65 
       
    66 QT_BEGIN_NAMESPACE
       
    67 
       
    68 class QTimerEvent;
       
    69 class QVideoSurfaceFormat;
       
    70 
       
    71 
       
    72 class QDeclarativeVideo : public QDeclarativeItem, public QDeclarativeMediaBase
       
    73 {
       
    74     Q_OBJECT
       
    75     Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
       
    76     Q_PROPERTY(bool autoLoad READ isAutoLoad WRITE setAutoLoad NOTIFY autoLoadChanged)
       
    77     Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
       
    78     Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
       
    79     Q_PROPERTY(Status status READ status NOTIFY statusChanged)
       
    80     Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
       
    81     Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
       
    82     Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
       
    83     Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
       
    84     Q_PROPERTY(bool hasAudio READ hasAudio NOTIFY hasAudioChanged)
       
    85     Q_PROPERTY(bool hasVideo READ hasVideo NOTIFY hasVideoChanged)
       
    86     Q_PROPERTY(int bufferProgress READ bufferProgress NOTIFY bufferProgressChanged)
       
    87     Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged)
       
    88     Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged)
       
    89     Q_PROPERTY(Error error READ error NOTIFY errorChanged)
       
    90     Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
       
    91     Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode)
       
    92     Q_ENUMS(FillMode)
       
    93     Q_ENUMS(Status)
       
    94     Q_ENUMS(Error)
       
    95 public:
       
    96     enum FillMode
       
    97     {
       
    98         Stretch            = Qt::IgnoreAspectRatio,
       
    99         PreserveAspectFit  = Qt::KeepAspectRatio,
       
   100         PreserveAspectCrop = Qt::KeepAspectRatioByExpanding
       
   101     };
       
   102 
       
   103     enum Status
       
   104     {
       
   105         UnknownStatus = QMediaPlayer::UnknownMediaStatus,
       
   106         NoMedia       = QMediaPlayer::NoMedia,
       
   107         Loading       = QMediaPlayer::LoadingMedia,
       
   108         Loaded        = QMediaPlayer::LoadedMedia,
       
   109         Stalled       = QMediaPlayer::StalledMedia,
       
   110         Buffering     = QMediaPlayer::BufferingMedia,
       
   111         Buffered      = QMediaPlayer::BufferedMedia,
       
   112         EndOfMedia    = QMediaPlayer::EndOfMedia,
       
   113         InvalidMedia  = QMediaPlayer::InvalidMedia
       
   114     };
       
   115 
       
   116     enum Error
       
   117     {
       
   118         NoError        = QMediaPlayer::NoError,
       
   119         ResourceError  = QMediaPlayer::ResourceError,
       
   120         FormatError    = QMediaPlayer::FormatError,
       
   121         NetworkError   = QMediaPlayer::NetworkError,
       
   122         AccessDenied   = QMediaPlayer::AccessDeniedError,
       
   123         ServiceMissing = QMediaPlayer::ServiceMissingError
       
   124     };
       
   125 
       
   126     QDeclarativeVideo(QDeclarativeItem *parent = 0);
       
   127     ~QDeclarativeVideo();
       
   128 
       
   129     bool hasAudio() const;
       
   130     bool hasVideo() const;
       
   131 
       
   132     FillMode fillMode() const;
       
   133     void setFillMode(FillMode mode);
       
   134 
       
   135     Status status() const;
       
   136     Error error() const;
       
   137 
       
   138     void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
       
   139 
       
   140     void classBegin() {}
       
   141     void componentComplete();
       
   142 
       
   143 public Q_SLOTS:
       
   144     void play();
       
   145     void pause();
       
   146     void stop();
       
   147 
       
   148 Q_SIGNALS:
       
   149     void sourceChanged();
       
   150     void autoLoadChanged();
       
   151     void playingChanged();
       
   152     void pausedChanged();
       
   153 
       
   154     void started();
       
   155     void resumed();
       
   156     void paused();
       
   157     void stopped();
       
   158 
       
   159     void statusChanged();
       
   160 
       
   161     void loaded();
       
   162     void buffering();
       
   163     void stalled();
       
   164     void buffered();
       
   165     void endOfMedia();
       
   166 
       
   167     void durationChanged();
       
   168     void positionChanged();
       
   169 
       
   170     void volumeChanged();
       
   171     void mutedChanged();
       
   172     void hasAudioChanged();
       
   173     void hasVideoChanged();
       
   174 
       
   175     void bufferProgressChanged();
       
   176 
       
   177     void seekableChanged();
       
   178     void playbackRateChanged();
       
   179 
       
   180     void errorChanged();
       
   181     void error(QDeclarativeVideo::Error error, const QString &errorString);
       
   182 
       
   183 protected:
       
   184     void geometryChanged(const QRectF &geometry, const QRectF &);
       
   185 
       
   186 private Q_SLOTS:
       
   187     void _q_nativeSizeChanged(const QSizeF &size);
       
   188     void _q_error(int, const QString &);
       
   189 
       
   190 private:
       
   191     Q_DISABLE_COPY(QDeclarativeVideo)
       
   192 
       
   193     QGraphicsVideoItem *m_graphicsItem;
       
   194 
       
   195     Q_PRIVATE_SLOT(mediaBase(), void _q_stateChanged(QMediaPlayer::State))
       
   196     Q_PRIVATE_SLOT(mediaBase(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus))
       
   197     Q_PRIVATE_SLOT(mediaBase(), void _q_metaDataChanged())
       
   198 
       
   199     inline QDeclarativeMediaBase *mediaBase() { return this; }
       
   200 };
       
   201 
       
   202 QT_END_NAMESPACE
       
   203 
       
   204 QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeVideo))
       
   205 
       
   206 QT_END_HEADER
       
   207 
       
   208 #endif