diff options
author | Frans Englich <frans.englich@nokia.com> | 2009-11-20 11:17:34 (GMT) |
---|---|---|
committer | Frans Englich <frans.englich@nokia.com> | 2009-11-20 11:17:34 (GMT) |
commit | 1b8d5bec5763708c66e7bd586aee3df7f94b5cb5 (patch) | |
tree | 7a3f966f857d17351c42d560fa86a119804d8996 /demos/qmediaplayer | |
parent | e2001432f89b6934b6c60c29c3c742a5bbc322a6 (diff) | |
download | Qt-1b8d5bec5763708c66e7bd586aee3df7f94b5cb5.zip Qt-1b8d5bec5763708c66e7bd586aee3df7f94b5cb5.tar.gz Qt-1b8d5bec5763708c66e7bd586aee3df7f94b5cb5.tar.bz2 |
Add support for opening Real Media RAM files.
Requested by Nokia Dallas/Helix team. Patch supplied by Fu Liz
EXT-DextraTech/Dallas, minor changes by me.
Task-number: QTBUG-4882
Reviewed-by: Gareth Stockwell
Diffstat (limited to 'demos/qmediaplayer')
-rw-r--r-- | demos/qmediaplayer/mediaplayer.cpp | 48 | ||||
-rw-r--r-- | demos/qmediaplayer/mediaplayer.h | 1 |
2 files changed, 49 insertions, 0 deletions
diff --git a/demos/qmediaplayer/mediaplayer.cpp b/demos/qmediaplayer/mediaplayer.cpp index 4021352..f8ca8ea 100644 --- a/demos/qmediaplayer/mediaplayer.cpp +++ b/demos/qmediaplayer/mediaplayer.cpp @@ -266,6 +266,9 @@ MediaPlayer::MediaPlayer(const QString &filePath, fileMenu = new QMenu(this); QAction *openFileAction = fileMenu->addAction(tr("Open &File...")); QAction *openUrlAction = fileMenu->addAction(tr("Open &Location...")); + QAction *const openLinkAction = fileMenu->addAction(tr("Open &RAM File...")); + + connect(openLinkAction, SIGNAL(triggered(bool)), this, SLOT(openRamFile())); fileMenu->addSeparator(); QMenu *aspectMenu = fileMenu->addMenu(tr("&Aspect ratio")); @@ -835,6 +838,51 @@ void MediaPlayer::openUrl() } } +/*! + \since 4.6 + */ +void MediaPlayer::openRamFile() +{ + QSettings settings; + settings.beginGroup(QLatin1String("BrowserMainWindow")); + + const QStringList fileNameList(QFileDialog::getOpenFileNames(this, + QString(), + settings.value("openRamFile").toString(), + QLatin1String("RAM files (*.ram)"))); + + if (fileNameList.isEmpty()) + return; + + QFile linkFile; + QList<QUrl> list; + QByteArray sourceURL; + for (int i = 0; i < fileNameList.count(); i++ ) { + linkFile.setFileName(fileNameList[i]); + if (linkFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + while (!linkFile.atEnd()) { + sourceURL = linkFile.readLine().trimmed(); + if (!sourceURL.isEmpty()) { + const QUrl url(QUrl::fromEncoded(sourceURL)); + if (url.isValid()) + list.append(url); + } + } + linkFile.close(); + } + } + + if (!list.isEmpty()) { + m_MediaObject.setCurrentSource(Phonon::MediaSource(list[0])); + m_MediaObject.play(); + for (int i = 1; i < list.count(); i++) + m_MediaObject.enqueue(Phonon::MediaSource(list[i])); + } + + forwardButton->setEnabled(!m_MediaObject.queue().isEmpty()); + settings.setValue("openRamFile", fileNameList[0]); +} + void MediaPlayer::finished() { } diff --git a/demos/qmediaplayer/mediaplayer.h b/demos/qmediaplayer/mediaplayer.h index a1c3d92..a8f18f0 100644 --- a/demos/qmediaplayer/mediaplayer.h +++ b/demos/qmediaplayer/mediaplayer.h @@ -107,6 +107,7 @@ private slots: void showContextMenu(const QPoint &); void bufferStatus(int percent); void openUrl(); + void openRamFile(); void configureEffect(); void hasVideoChanged(bool); |