qtmobility/plugins/multimedia/symbian/mediaplayer/s60mediametadataprovider.cpp
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 #include "s60mediametadataprovider.h"
       
    43 #include "s60mediaplayersession.h"
       
    44 #include <QtCore/qdebug.h>
       
    45 
       
    46 S60MediaMetaDataProvider::S60MediaMetaDataProvider(MS60MediaPlayerResolver& mediaPlayerResolver, QObject *parent)
       
    47     : QMetaDataControl(parent)
       
    48     , m_mediaPlayerResolver(mediaPlayerResolver)
       
    49     , m_session(NULL)
       
    50 {
       
    51 }
       
    52 
       
    53 S60MediaMetaDataProvider::~S60MediaMetaDataProvider()
       
    54 {
       
    55 }
       
    56 
       
    57 bool S60MediaMetaDataProvider::isMetaDataAvailable() const
       
    58 {
       
    59     m_session = m_mediaPlayerResolver.PlayerSession();
       
    60     if (m_session)
       
    61        return m_session->isMetadataAvailable();
       
    62     return false;
       
    63 }
       
    64 
       
    65 bool S60MediaMetaDataProvider::isWritable() const
       
    66 {
       
    67     return false;
       
    68 }
       
    69 
       
    70 QVariant S60MediaMetaDataProvider::metaData(QtMedia::MetaData key) const
       
    71 {
       
    72     m_session = m_mediaPlayerResolver.PlayerSession();
       
    73     if (m_session && m_session->isMetadataAvailable())
       
    74         return m_session->metaData(metaDataKeyAsString(key));
       
    75     return QVariant();
       
    76 }
       
    77 
       
    78 void S60MediaMetaDataProvider::setMetaData(QtMedia::MetaData key, QVariant const &value)
       
    79 {
       
    80     Q_UNUSED(key);
       
    81     Q_UNUSED(value);
       
    82 }
       
    83 QList<QtMedia::MetaData> S60MediaMetaDataProvider::availableMetaData() const
       
    84 {
       
    85     m_session = m_mediaPlayerResolver.PlayerSession();
       
    86     QList<QtMedia::MetaData> metaDataTags;
       
    87     if (m_session && m_session->isMetadataAvailable()) {
       
    88         for (int i = QtMedia::Title; i <= QtMedia::DeviceSettingDescription; i++) {
       
    89             QString metaData = metaDataKeyAsString((QtMedia::MetaData)i);
       
    90             if (!metaData.isEmpty()) {
       
    91                 if (!m_session->metaData(metaData).toString().isEmpty()) {
       
    92                     metaDataTags.append((QtMedia::MetaData)i);               
       
    93                 }
       
    94             }
       
    95         }
       
    96     }
       
    97     return metaDataTags;
       
    98 }
       
    99 
       
   100 QVariant S60MediaMetaDataProvider::extendedMetaData(const QString &key) const
       
   101 {
       
   102     m_session = m_mediaPlayerResolver.PlayerSession();
       
   103     if (m_session && m_session->isMetadataAvailable())
       
   104         return m_session->metaData(key);
       
   105     return QVariant();
       
   106 }
       
   107 
       
   108 void S60MediaMetaDataProvider::setExtendedMetaData(const QString &key, QVariant const &value)
       
   109 {
       
   110     Q_UNUSED(key);
       
   111     Q_UNUSED(value);
       
   112 }
       
   113 
       
   114 QStringList S60MediaMetaDataProvider::availableExtendedMetaData() const
       
   115 {
       
   116     m_session = m_mediaPlayerResolver.PlayerSession();
       
   117     if (m_session && m_session->isMetadataAvailable())
       
   118         return m_session->availableMetaData().keys();
       
   119     return QStringList();
       
   120 }
       
   121 
       
   122 QString S60MediaMetaDataProvider::metaDataKeyAsString(QtMedia::MetaData key) const
       
   123 {
       
   124     switch(key) {
       
   125         case QtMedia::Title: return "title";
       
   126         case QtMedia::AlbumArtist: return "artist";
       
   127         case QtMedia::Comment: return "comment";
       
   128         case QtMedia::Genre: return "genre";
       
   129         case QtMedia::Year: return "year";
       
   130         case QtMedia::Copyright: return "copyright";
       
   131         case QtMedia::AlbumTitle: return "album";
       
   132         case QtMedia::Composer: return "composer";
       
   133         case QtMedia::TrackNumber: return "albumtrack";
       
   134         case QtMedia::AudioBitRate: return "audiobitrate";
       
   135         case QtMedia::VideoBitRate: return "videobitrate";
       
   136         case QtMedia::Duration: return "duration";
       
   137         case QtMedia::MediaType: return "contenttype";
       
   138         case QtMedia::SubTitle: // TODO: Find the matching metadata keys
       
   139         case QtMedia::Description:
       
   140         case QtMedia::Category:
       
   141         case QtMedia::Date:
       
   142         case QtMedia::UserRating:
       
   143         case QtMedia::Keywords:
       
   144         case QtMedia::Language:
       
   145         case QtMedia::Publisher:
       
   146         case QtMedia::ParentalRating:
       
   147         case QtMedia::RatingOrganisation:
       
   148         case QtMedia::Size:
       
   149         case QtMedia::AudioCodec:
       
   150         case QtMedia::AverageLevel:
       
   151         case QtMedia::ChannelCount:
       
   152         case QtMedia::PeakValue:
       
   153         case QtMedia::SampleRate:
       
   154         case QtMedia::Author:
       
   155         case QtMedia::ContributingArtist:
       
   156         case QtMedia::Conductor:
       
   157         case QtMedia::Lyrics:
       
   158         case QtMedia::Mood:
       
   159         case QtMedia::TrackCount:
       
   160         case QtMedia::CoverArtUrlSmall:
       
   161         case QtMedia::CoverArtUrlLarge:
       
   162         case QtMedia::Resolution:
       
   163         case QtMedia::PixelAspectRatio:
       
   164         case QtMedia::VideoFrameRate:
       
   165         case QtMedia::VideoCodec:
       
   166         case QtMedia::PosterUrl:
       
   167         case QtMedia::ChapterNumber:
       
   168         case QtMedia::Director:
       
   169         case QtMedia::LeadPerformer:
       
   170         case QtMedia::Writer:
       
   171         case QtMedia::CameraManufacturer:
       
   172         case QtMedia::CameraModel:
       
   173         case QtMedia::Event:
       
   174         case QtMedia::Subject:
       
   175         default:
       
   176             break;
       
   177     }
       
   178 
       
   179     return QString();
       
   180 }