qtmobility/src/multimedia/qmlaudio_p.h
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
child 5 453da2cfceef
equal deleted inserted replaced
1:2b40d63a9c3d 4:90517678cc4f
     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 QMLAUDIO_P_H
       
    43 #define QMLAUDIO_P_H
       
    44 
       
    45 #include <qmlmediabase_p.h>
       
    46 
       
    47 #include <QtCore/qbasictimer.h>
       
    48 #include <QtDeclarative/qmlgraphicsitem.h>
       
    49 
       
    50 class QTimerEvent;
       
    51 
       
    52 QTM_BEGIN_NAMESPACE
       
    53 
       
    54 class QmlAudio : public QObject, public QmlMediaBase, public QmlParserStatus
       
    55 {
       
    56     Q_OBJECT
       
    57     Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
       
    58     Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
       
    59     Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
       
    60     Q_PROPERTY(Status status READ status NOTIFY statusChanged)
       
    61     Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
       
    62     Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
       
    63     Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
       
    64     Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
       
    65     Q_PROPERTY(int bufferProgress READ bufferProgress NOTIFY bufferProgressChanged)
       
    66     Q_PROPERTY(bool seekable READ isSeekable NOTIFY seekableChanged)
       
    67     Q_PROPERTY(qreal playbackRate READ playbackRate WRITE setPlaybackRate NOTIFY playbackRateChanged)
       
    68     Q_PROPERTY(Error error READ error NOTIFY errorChanged)
       
    69     Q_PROPERTY(QString errorString READ errorString NOTIFY errorChanged)
       
    70     Q_ENUMS(Status)
       
    71     Q_ENUMS(Error)
       
    72     Q_INTERFACES(QmlParserStatus)
       
    73 public:
       
    74     enum Status
       
    75     {
       
    76         UnknownStatus = QMediaPlayer::UnknownMediaStatus,
       
    77         NoMedia       = QMediaPlayer::NoMedia,
       
    78         Loading       = QMediaPlayer::LoadingMedia,
       
    79         Loaded        = QMediaPlayer::LoadedMedia,
       
    80         Stalled       = QMediaPlayer::StalledMedia,
       
    81         Buffering     = QMediaPlayer::BufferingMedia,
       
    82         Buffered      = QMediaPlayer::BufferedMedia,
       
    83         EndOfMedia    = QMediaPlayer::EndOfMedia,
       
    84         InvalidMedia  = QMediaPlayer::InvalidMedia
       
    85     };
       
    86 
       
    87     enum Error
       
    88     {
       
    89         NoError        = QMediaPlayer::NoError,
       
    90         ResourceError  = QMediaPlayer::ResourceError,
       
    91         FormatError    = QMediaPlayer::FormatError,
       
    92         NetworkError   = QMediaPlayer::NetworkError,
       
    93         AccessDenied   = QMediaPlayer::AccessDeniedError,
       
    94         ServiceMissing = QMediaPlayer::ServiceMissingError
       
    95     };
       
    96 
       
    97     QmlAudio(QObject *parent = 0);
       
    98     ~QmlAudio();
       
    99 
       
   100     Status status() const;
       
   101     Error error() const;
       
   102 
       
   103 public Q_SLOTS:
       
   104     void play();
       
   105     void pause();
       
   106     void stop();
       
   107 
       
   108 Q_SIGNALS:
       
   109     void sourceChanged();
       
   110 
       
   111     void playingChanged();
       
   112     void pausedChanged();
       
   113 
       
   114     void started();
       
   115     void resumed();
       
   116     void paused();
       
   117     void stopped();
       
   118 
       
   119     void statusChanged();
       
   120 
       
   121     void loaded();
       
   122     void buffering();
       
   123     void stalled();
       
   124     void buffered();
       
   125     void endOfMedia();
       
   126 
       
   127     void durationChanged();
       
   128     void positionChanged();
       
   129 
       
   130     void volumeChanged();
       
   131     void mutedChanged();
       
   132 
       
   133     void bufferProgressChanged();
       
   134 
       
   135     void seekableChanged();
       
   136     void playbackRateChanged();
       
   137 
       
   138     void errorChanged();
       
   139     void error(QmlAudio::Error error, const QString &errorString);
       
   140 
       
   141 private Q_SLOTS:
       
   142     void _q_error(QMediaPlayer::Error, const QString &);
       
   143 
       
   144 private:
       
   145     Q_DISABLE_COPY(QmlAudio)
       
   146     Q_PRIVATE_SLOT(mediaBase(), void _q_stateChanged(QMediaPlayer::State))
       
   147     Q_PRIVATE_SLOT(mediaBase(), void _q_mediaStatusChanged(QMediaPlayer::MediaStatus))
       
   148     Q_PRIVATE_SLOT(mediaBase(), void _q_metaDataChanged())
       
   149 
       
   150     inline QmlMediaBase *mediaBase() { return this; }
       
   151 };
       
   152 
       
   153 QTM_END_NAMESPACE
       
   154 
       
   155 QML_DECLARE_TYPE(QTM_PREPEND_NAMESPACE(QmlAudio))
       
   156 
       
   157 #endif