qtmobility/plugins/declarative/multimedia/qdeclarativeaudio_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 QDECLARATIVEAUDIO_P_H
       
    43 #define QDECLARATIVEAUDIO_P_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 <QtCore/qbasictimer.h>
       
    59 #include <QtDeclarative/qdeclarativeitem.h>
       
    60 
       
    61 
       
    62 QT_BEGIN_HEADER
       
    63 
       
    64 QT_BEGIN_NAMESPACE
       
    65 
       
    66 class QTimerEvent;
       
    67 
       
    68 class QDeclarativeAudio : public QObject, public QDeclarativeMediaBase, public QDeclarativeParserStatus
       
    69 {
       
    70     Q_OBJECT
       
    71     Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
       
    72     Q_PROPERTY(bool autoLoad READ isAutoLoad WRITE setAutoLoad NOTIFY autoLoadChanged)
       
    73     Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
       
    74     Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
       
    75     Q_PROPERTY(Status status READ status NOTIFY statusChanged)
       
    76     Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
       
    77     Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
       
    78     Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
       
    79     Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
       
    80     Q_PROPERTY(int bufferProgress READ bufferProgress NOTIFY bufferProgressChanged)
       
    81     Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged)
       
    82     Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged)
       
    83     Q_PROPERTY(Error error READ error NOTIFY errorChanged)
       
    84     Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
       
    85     Q_ENUMS(Status)
       
    86     Q_ENUMS(Error)
       
    87     Q_INTERFACES(QDeclarativeParserStatus)
       
    88 public:
       
    89     enum Status
       
    90     {
       
    91         UnknownStatus = QMediaPlayer::UnknownMediaStatus,
       
    92         NoMedia       = QMediaPlayer::NoMedia,
       
    93         Loading       = QMediaPlayer::LoadingMedia,
       
    94         Loaded        = QMediaPlayer::LoadedMedia,
       
    95         Stalled       = QMediaPlayer::StalledMedia,
       
    96         Buffering     = QMediaPlayer::BufferingMedia,
       
    97         Buffered      = QMediaPlayer::BufferedMedia,
       
    98         EndOfMedia    = QMediaPlayer::EndOfMedia,
       
    99         InvalidMedia  = QMediaPlayer::InvalidMedia
       
   100     };
       
   101 
       
   102     enum Error
       
   103     {
       
   104         NoError        = QMediaPlayer::NoError,
       
   105         ResourceError  = QMediaPlayer::ResourceError,
       
   106         FormatError    = QMediaPlayer::FormatError,
       
   107         NetworkError   = QMediaPlayer::NetworkError,
       
   108         AccessDenied   = QMediaPlayer::AccessDeniedError,
       
   109         ServiceMissing = QMediaPlayer::ServiceMissingError
       
   110     };
       
   111 
       
   112     QDeclarativeAudio(QObject *parent = 0);
       
   113     ~QDeclarativeAudio();
       
   114 
       
   115     Status status() const;
       
   116     Error error() const;
       
   117 
       
   118     void classBegin() {};
       
   119     void componentComplete();
       
   120 
       
   121 public Q_SLOTS:
       
   122     void play();
       
   123     void pause();
       
   124     void stop();
       
   125 
       
   126 Q_SIGNALS:
       
   127     void sourceChanged();
       
   128     void autoLoadChanged();
       
   129     void playingChanged();
       
   130     void pausedChanged();
       
   131 
       
   132     void started();
       
   133     void resumed();
       
   134     void paused();
       
   135     void stopped();
       
   136 
       
   137     void statusChanged();
       
   138 
       
   139     void loaded();
       
   140     void buffering();
       
   141     void stalled();
       
   142     void buffered();
       
   143     void endOfMedia();
       
   144 
       
   145     void durationChanged();
       
   146     void positionChanged();
       
   147 
       
   148     void volumeChanged();
       
   149     void mutedChanged();
       
   150 
       
   151     void bufferProgressChanged();
       
   152 
       
   153     void seekableChanged();
       
   154     void playbackRateChanged();
       
   155 
       
   156     void errorChanged();
       
   157     void error(QDeclarativeAudio::Error error, const QString &errorString);
       
   158 
       
   159 private Q_SLOTS:
       
   160     void _q_error(int, const QString &);
       
   161 
       
   162 private:
       
   163     Q_DISABLE_COPY(QDeclarativeAudio)
       
   164     Q_PRIVATE_SLOT(mediaBase(), void _q_stateChanged(QMediaPlayer::State))
       
   165     Q_PRIVATE_SLOT(mediaBase(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus))
       
   166     Q_PRIVATE_SLOT(mediaBase(), void _q_metaDataChanged())
       
   167 
       
   168     inline QDeclarativeMediaBase *mediaBase() { return this; }
       
   169 };
       
   170 
       
   171 QT_END_NAMESPACE
       
   172 
       
   173 QML_DECLARE_TYPE(QT_PREPEND_NAMESPACE(QDeclarativeAudio))
       
   174 
       
   175 QT_END_HEADER
       
   176 
       
   177 #endif