Changeset 846 for trunk/demos/qmediaplayer
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/demos/qmediaplayer/main.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 43 43 #include "mediaplayer.h" 44 44 45 const qreal DefaultVolume = -1.0; 46 45 47 int main (int argc, char *argv[]) 46 48 { … … 51 53 app.setQuitOnLastWindowClosed(true); 52 54 53 bool hasSmallScreen = 55 QString fileName; 56 qreal volume = DefaultVolume; 57 bool smallScreen = false; 54 58 #ifdef Q_OS_SYMBIAN 55 /* On Symbian, we always want fullscreen. One reason is that it's not 56 * possible to launch any demos from the fluidlauncher due to a 57 * limitation in the emulator. */ 58 true 59 #else 60 false 59 smallScreen = true; 61 60 #endif 62 ;63 61 64 QString fileString; 65 const QStringList args(app.arguments()); 66 /* We have a minor problem here, we accept two arguments, both are 67 * optional: 68 * - A file name 69 * - the option "-small-screen", so let's try to cope with that. 70 */ 71 for (int i = 0; i < args.count(); ++i) { 72 const QString &at = args.at(i); 73 74 if (at == QLatin1String("-small-screen")) 75 hasSmallScreen = true; 76 else if (i > 0) // We don't want the app name. 77 fileString = at; 62 QStringList args(app.arguments()); 63 args.removeFirst(); // remove name of executable 64 while (!args.empty()) { 65 const QString &arg = args.first(); 66 if (QLatin1String("-small-screen") == arg || QLatin1String("--small-screen") == arg) { 67 smallScreen = true; 68 } else if (QLatin1String("-volume") == arg || QLatin1String("--volume") == arg) { 69 if (!args.empty()) { 70 args.removeFirst(); 71 volume = qMax(qMin(args.first().toFloat(), float(1.0)), float(0.0)); 72 } 73 } else if (fileName.isNull()) { 74 fileName = arg; 75 } 76 args.removeFirst(); 78 77 } 79 78 80 MediaPlayer player(fileString, hasSmallScreen); 79 MediaPlayer player; 80 player.setSmallScreen(smallScreen); 81 if (DefaultVolume != volume) 82 player.setVolume(volume); 83 if (!fileName.isNull()) 84 player.setFile(fileName); 81 85 82 if ( hasSmallScreen)86 if (smallScreen) 83 87 player.showMaximized(); 84 88 else -
trunk/demos/qmediaplayer/mediaplayer.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 47 47 #include "ui_settings.h" 48 48 49 #ifdef Q_OS_SYMBIAN 50 #include <cdbcols.h> 51 #include <cdblen.h> 52 #include <commdb.h> 53 #endif 49 54 50 55 MediaVideoWidget::MediaVideoWidget(MediaPlayer *player, QWidget *parent) : … … 153 158 154 159 155 MediaPlayer::MediaPlayer(const QString &filePath, 156 const bool hasSmallScreen) : 160 MediaPlayer::MediaPlayer() : 157 161 playButton(0), nextEffect(0), settingsDialog(0), ui(0), 158 162 m_AudioOutput(Phonon::VideoCategory), 159 m_videoWidget(new MediaVideoWidget(this)), 160 m_hasSmallScreen(hasSmallScreen) 163 m_videoWidget(new MediaVideoWidget(this)) 161 164 { 162 165 setWindowTitle(tr("Media Player")); … … 272 275 QAction *openFileAction = fileMenu->addAction(tr("Open &File...")); 273 276 QAction *openUrlAction = fileMenu->addAction(tr("Open &Location...")); 277 #ifdef Q_OS_SYMBIAN 278 QAction *selectIAPAction = fileMenu->addAction(tr("Select &IAP...")); 279 connect(selectIAPAction, SIGNAL(triggered(bool)), this, SLOT(selectIAP())); 280 #endif 274 281 QAction *const openLinkAction = fileMenu->addAction(tr("Open &RAM File...")); 275 282 … … 347 354 Phonon::createPath(&m_MediaObject, m_videoWidget); 348 355 349 if (!filePath.isEmpty())350 setFile(filePath);351 356 resize(minimumSizeHint()); 352 357 } … … 359 364 QRect videoHintRect = QRect(QPoint(0, 0), m_videoWindow.sizeHint()); 360 365 QRect newVideoRect = QApplication::desktop()->screenGeometry().intersected(videoHintRect); 361 if (!m_ hasSmallScreen) {366 if (!m_smallScreen) { 362 367 if (m_MediaObject.hasVideo()) { 363 368 // Flush event que so that sizeHint takes the … … 467 472 } 468 473 474 void MediaPlayer::setVolume(qreal volume) 475 { 476 m_AudioOutput.setVolume(volume); 477 } 478 479 void MediaPlayer::setSmallScreen(bool smallScreen) 480 { 481 m_smallScreen = smallScreen; 482 } 483 469 484 void MediaPlayer::effectChanged() 470 485 { … … 590 605 591 606 if (effectDialog.result() != QDialog::Accepted) { 592 //we need to restore the param aters values607 //we need to restore the parameters values 593 608 int currentIndex = 0; 594 609 foreach(Phonon::EffectParameter param, nextEffect->parameters()) { … … 686 701 // popping up dialogs. We neither want to tamper with the state if the 687 702 // user has paused. 688 if (m_ hasSmallScreen && m_MediaObject.hasVideo()) {703 if (m_smallScreen && m_MediaObject.hasVideo()) { 689 704 if (Phonon::PlayingState == m_MediaObject.state()) { 690 705 m_MediaObject.pause(); … … 717 732 void MediaPlayer::bufferStatus(int percent) 718 733 { 719 if (percent == 0 || percent ==100)734 if (percent == 100) 720 735 progressLabel->setText(QString()); 721 736 else { … … 944 959 m_fullScreenAction->setEnabled(bHasVideo); 945 960 } 961 962 #ifdef Q_OS_SYMBIAN 963 void MediaPlayer::selectIAP() 964 { 965 TRAPD(err, selectIAPL()); 966 if (KErrNone != err) 967 QMessageBox::warning(this, "Phonon Mediaplayer", "Error selecting IAP", QMessageBox::Close); 968 } 969 970 void MediaPlayer::selectIAPL() 971 { 972 QVariant currentIAPValue = m_MediaObject.property("InternetAccessPointName"); 973 QString currentIAPString = currentIAPValue.toString(); 974 bool ok = false; 975 CCommsDatabase *commsDb = CCommsDatabase::NewL(EDatabaseTypeIAP); 976 CleanupStack::PushL(commsDb); 977 commsDb->ShowHiddenRecords(); 978 CCommsDbTableView* view = commsDb->OpenTableLC(TPtrC(IAP)); 979 QStringList items; 980 TInt currentIAP = 0; 981 for (TInt l = view->GotoFirstRecord(), i = 0; l != KErrNotFound; l = view->GotoNextRecord(), i++) { 982 TBuf<KCommsDbSvrMaxColumnNameLength> iapName; 983 view->ReadTextL(TPtrC(COMMDB_NAME), iapName); 984 QString iapString = QString::fromUtf16(iapName.Ptr(), iapName.Length()); 985 items << iapString; 986 if (iapString == currentIAPString) 987 currentIAP = i; 988 } 989 currentIAPString = QInputDialog::getItem(this, tr("Select Access Point"), tr("Select Access Point"), items, currentIAP, false, &ok); 990 if (ok) 991 m_MediaObject.setProperty("InternetAccessPointName", currentIAPString); 992 CleanupStack::PopAndDestroy(2); //commsDB, view 993 } 994 #endif -
trunk/demos/qmediaplayer/mediaplayer.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 105 105 Q_OBJECT 106 106 public: 107 MediaPlayer(const QString &, 108 const bool hasSmallScreen); 107 MediaPlayer(); 109 108 110 109 void dragEnterEvent(QDragEnterEvent *e); … … 116 115 void initVideoWindow(); 117 116 void initSettingsDialog(); 117 void setVolume(qreal volume); 118 void setSmallScreen(bool smallScreen); 118 119 119 120 public slots: … … 141 142 void bufferStatus(int percent); 142 143 void openUrl(); 144 #ifdef Q_OS_SYMBIAN 145 void selectIAP(); 146 #endif 143 147 void openRamFile(); 144 148 void configureEffect(); … … 147 151 private: 148 152 bool playPauseForDialog(); 153 #ifdef Q_OS_SYMBIAN 154 void selectIAPL(); 155 #endif 149 156 150 157 QIcon playIcon; … … 172 179 MediaVideoWidget *m_videoWidget; 173 180 Phonon::Path m_audioOutputPath; 174 const bool m_hasSmallScreen;181 bool m_smallScreen; 175 182 }; 176 183 -
trunk/demos/qmediaplayer/qmediaplayer.pro
r561 r846 34 34 include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) 35 35 36 LIBS += -lCommDb 37 36 38 TARGET.CAPABILITY="NetworkServices" 37 39 }
Note:
See TracChangeset
for help on using the changeset viewer.