plugins/multimedia/qt7/mediaplayer/qt7playercontrol.mm
changeset 5 603d3f8b6302
equal deleted inserted replaced
3:e4ebb16b39ea 5:603d3f8b6302
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 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 #include "qt7playercontrol.h"
       
    43 #include "qt7playersession.h"
       
    44 
       
    45 #include <qmediaplaylistnavigator.h>
       
    46 
       
    47 #include <QtCore/qurl.h>
       
    48 #include <QtCore/qdebug.h>
       
    49 
       
    50 QT_USE_NAMESPACE
       
    51 
       
    52 QT7PlayerControl::QT7PlayerControl(QObject *parent)
       
    53    : QMediaPlayerControl(parent)
       
    54 {    
       
    55 }
       
    56 
       
    57 QT7PlayerControl::~QT7PlayerControl()
       
    58 {
       
    59 }
       
    60 
       
    61 void QT7PlayerControl::setSession(QT7PlayerSession *session)
       
    62 {
       
    63     m_session = session;
       
    64 
       
    65     connect(m_session, SIGNAL(positionChanged(qint64)), this, SIGNAL(positionChanged(qint64)));
       
    66     connect(m_session, SIGNAL(durationChanged(qint64)), this, SIGNAL(durationChanged(qint64)));
       
    67     connect(m_session, SIGNAL(stateChanged(QMediaPlayer::State)),
       
    68             this, SIGNAL(stateChanged(QMediaPlayer::State)));
       
    69     connect(m_session, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
       
    70             this, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)));
       
    71     connect(m_session, SIGNAL(volumeChanged(int)), this, SIGNAL(volumeChanged(int)));
       
    72     connect(m_session, SIGNAL(mutedChanged(bool)), this, SIGNAL(mutedChanged(bool)));
       
    73     connect(m_session, SIGNAL(audioAvailableChanged(bool)), this, SIGNAL(audioAvailableChanged(bool)));
       
    74     connect(m_session, SIGNAL(videoAvailableChanged(bool)), this, SIGNAL(videoAvailableChanged(bool)));
       
    75     connect(m_session, SIGNAL(error(int,QString)), this, SIGNAL(error(int,QString)));
       
    76 }
       
    77 
       
    78 qint64 QT7PlayerControl::position() const
       
    79 {
       
    80     return m_session->position();
       
    81 }
       
    82 
       
    83 qint64 QT7PlayerControl::duration() const
       
    84 {
       
    85     return m_session->duration();
       
    86 }
       
    87 
       
    88 QMediaPlayer::State QT7PlayerControl::state() const
       
    89 {
       
    90     return m_session->state();
       
    91 }
       
    92 
       
    93 QMediaPlayer::MediaStatus QT7PlayerControl::mediaStatus() const
       
    94 {
       
    95     return m_session->mediaStatus();
       
    96 }
       
    97 
       
    98 int QT7PlayerControl::bufferStatus() const
       
    99 {
       
   100     return m_session->bufferStatus();
       
   101 }
       
   102 
       
   103 int QT7PlayerControl::volume() const
       
   104 {
       
   105     return m_session->volume();
       
   106 }
       
   107 
       
   108 bool QT7PlayerControl::isMuted() const
       
   109 {
       
   110     return m_session->isMuted();
       
   111 }
       
   112 
       
   113 bool QT7PlayerControl::isSeekable() const
       
   114 {
       
   115     return m_session->isSeekable();
       
   116 }
       
   117 
       
   118 QMediaTimeRange QT7PlayerControl::availablePlaybackRanges() const
       
   119 {
       
   120     QMediaTimeRange result;
       
   121 
       
   122     if (isSeekable())
       
   123         result.addInterval(0, duration());
       
   124 
       
   125     return result;
       
   126 }
       
   127 
       
   128 qreal QT7PlayerControl::playbackRate() const
       
   129 {
       
   130     return m_session->playbackRate();
       
   131 }
       
   132 
       
   133 void QT7PlayerControl::setPlaybackRate(qreal rate)
       
   134 {
       
   135     m_session->setPlaybackRate(rate);
       
   136 }
       
   137 
       
   138 void QT7PlayerControl::setPosition(qint64 pos)
       
   139 {
       
   140     m_session->setPosition(pos);
       
   141 }
       
   142 
       
   143 void QT7PlayerControl::play()
       
   144 {
       
   145     m_session->play();
       
   146 }
       
   147 
       
   148 void QT7PlayerControl::pause()
       
   149 {
       
   150     m_session->pause();
       
   151 }
       
   152 
       
   153 void QT7PlayerControl::stop()
       
   154 {
       
   155     m_session->stop();
       
   156 }
       
   157 
       
   158 void QT7PlayerControl::setVolume(int volume)
       
   159 {
       
   160     m_session->setVolume(volume);
       
   161 }
       
   162 
       
   163 void QT7PlayerControl::setMuted(bool muted)
       
   164 {
       
   165     m_session->setMuted(muted);
       
   166 }
       
   167 
       
   168 QMediaContent QT7PlayerControl::media() const
       
   169 {
       
   170     return m_session->media();
       
   171 }
       
   172 
       
   173 const QIODevice *QT7PlayerControl::mediaStream() const
       
   174 {
       
   175     return m_session->mediaStream();
       
   176 }
       
   177 
       
   178 void QT7PlayerControl::setMedia(const QMediaContent &content, QIODevice *stream)
       
   179 {
       
   180     m_session->setMedia(content, stream);
       
   181 
       
   182     emit mediaChanged(content);
       
   183 }
       
   184 
       
   185 bool QT7PlayerControl::isAudioAvailable() const
       
   186 {
       
   187     return m_session->isAudioAvailable();
       
   188 }
       
   189 
       
   190 bool QT7PlayerControl::isVideoAvailable() const
       
   191 {
       
   192     return m_session->isVideoAvailable();
       
   193 }
       
   194 
       
   195 
       
   196 #include "moc_qt7playercontrol.cpp"