File indexing completed on 2024-04-28 04:43:21
0001 /* 0002 Copyright (C) 2010 Jean-Baptiste Kempf <jb@videolan.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Lesser General Public 0006 License as published by the Free Software Foundation; either 0007 version 2.1 of the License, or (at your option) version 3, or any 0008 later version accepted by the membership of KDE e.V. (or its 0009 successor approved by the membership of KDE e.V.), Nokia Corporation 0010 (or its successors, if any) and the KDE Free Qt Foundation, which shall 0011 act as a proxy defined in Section 6 of version 3 of the license. 0012 0013 This library is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 Lesser General Public License for more details. 0017 0018 You should have received a copy of the GNU Lesser General Public 0019 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0020 */ 0021 0022 #include "mediacontroller.h" 0023 0024 #include <phonon/mediasource.h> 0025 #include <phonon/mediaobject.h> 0026 0027 #include <QFileDialog> 0028 0029 MediaController::MediaController(QObject *parent) : 0030 QObject(parent) 0031 { 0032 m_media = new Phonon::MediaObject(this); 0033 } 0034 0035 Phonon::MediaObject *MediaController::mediaObject() const 0036 { 0037 return m_media; 0038 } 0039 0040 void MediaController::openFile() 0041 { 0042 QUrl file = QUrl::fromLocalFile(QFileDialog::getOpenFileName(0, tr("Open a new file to play"), "")); 0043 if (!file.isEmpty()) { 0044 Phonon::MediaSource s(file); 0045 playSource(s); 0046 } 0047 } 0048 0049 void MediaController::openURL() 0050 { 0051 0052 } 0053 0054 void MediaController::playSource(const Phonon::MediaSource &s) 0055 { 0056 m_media->setCurrentSource(s); 0057 m_media->play(); 0058 }