From b7db42c72cd12a464034045cc17af8cd7a7c8b8b Mon Sep 17 00:00:00 2001 From: tamas Date: Sun, 8 Aug 2010 22:09:03 +0200 Subject: [PATCH] bugfixes, README file --- README | 7 ++++++ bugs.txt | 6 ++--- playlistmanager.cpp | 65 +++++++++++++++++++++++++++++---------------------- playlistmanager.h | 3 +++ tomamp.pro | 3 ++- 5 files changed, 52 insertions(+), 32 deletions(-) create mode 100644 README diff --git a/README b/README new file mode 100644 index 0000000..9ef4f0b --- /dev/null +++ b/README @@ -0,0 +1,7 @@ +TomAmp v0.1 +(c) 2010 Tamas Marki + +TomAmp is a simple playlist-based audio player written in Qt, designed for Maemo. + + +The project is released under the LGPL license. See http://www.gnu.org/licenses/lgpl.html diff --git a/bugs.txt b/bugs.txt index d1d4d75..b772738 100644 --- a/bugs.txt +++ b/bugs.txt @@ -1,9 +1,9 @@ -- meta info display mismatch (title duplication, some files receive some other file's meta info instead of their ("reality")) (might be related to previous) -- quick next-next while playing stops playback -- bold-italic highlight does not move on normal track switch (when one ends and the next starts) Fixed: + context menu event outside of musicTable causes crash + cancel add folder, add url causes crash + doesn't remember add folder folder + adding some files can cause a crash ("Blessing, Compassion") ++ bold-italic highlight does not move on normal track switch (when one ends and the next starts) ++ quick next-next while playing stops playback ++ meta info display mismatch (title duplication, some files receive some other file's meta info instead of their ("reality")) (might be related to previous) diff --git a/playlistmanager.cpp b/playlistmanager.cpp index a172cdd..5ddfcf4 100644 --- a/playlistmanager.cpp +++ b/playlistmanager.cpp @@ -3,9 +3,14 @@ #include #include +QStringList allowedExtensions; + + PlaylistManager::PlaylistManager(QWidget* parent) - : parentWidget (parent) + : parentWidget (parent), lastMetaRead (-1) { + allowedExtensions << "mp3" << "ogg" << "wav" << "wmv" << "wma"; +// qDebug () << Phonon::BackendCapabilities::availableMimeTypes(); metaInformationResolver = new Phonon::MediaObject(parent); connect(metaInformationResolver, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(metaStateChanged(Phonon::State,Phonon::State))); @@ -54,7 +59,10 @@ void PlaylistManager::parseAndAddFolder(const QString &dir, bool recursive) } } if (!items.isEmpty()) + { metaInformationResolver->setCurrentSource(items.at(index).source); + lastMetaRead = index; + } qDebug () << " SIZE: " << items.size (); emit playlistChanged (index); } @@ -71,50 +79,42 @@ void PlaylistManager::addStringList(const QStringList& list) } } if (!items.isEmpty()) + { metaInformationResolver->setCurrentSource(items.at(index).source); + lastMetaRead = index; + } emit playlistChanged(index); } void PlaylistManager::metaStateChanged(Phonon::State newState, Phonon::State oldState) { qDebug () << "Meta state now " << newState << " old state " << oldState; - if (oldState == Phonon::ErrorState) + // This is an ugly hack, since the metaInformationResolver doesn't properly load the assigned source when it's in the error state + // In order to properly read the next file we have to set it as current source again when the resolver entered the stopped state after the error + static bool wasError = false; + if (wasError && newState == Phonon::StoppedState) { -/* int index = indexOf (metaInformationResolver->currentSource()); - metaInformationResolver->setCurrentSource(items[index].source);*/ + metaInformationResolver->setCurrentSource(items[lastMetaRead].source); + wasError = false; + return; } if (newState == Phonon::ErrorState) { - int index = indexOf (metaInformationResolver->currentSource()); - if (index >= 0 && items.size () > index + 1) - { -/* metaInformationResolver->disconnect(); - delete metaInformationResolver; - metaInformationResolver = new Phonon::MediaObject(parent()); - connect(metaInformationResolver, SIGNAL(stateChanged(Phonon::State,Phonon::State)), - this, SLOT(metaStateChanged(Phonon::State,Phonon::State)));*/ - metaInformationResolver->setCurrentSource(items[index + 1].source); -// metaInformationResolver->clear(); - qDebug () << "Set " << items[index + 1].source.fileName() << " error type: " << metaInformationResolver->errorString() << " (" << metaInformationResolver->errorType() << ")"; - } - qDebug () << "Error for item " << index; - return; + wasError = true; } - if (newState != Phonon::StoppedState/* && newState != Phonon::PausedState*/) + if (newState != Phonon::StoppedState && newState != Phonon::ErrorState) { return; } - if (metaInformationResolver->currentSource().type() == Phonon::MediaSource::Invalid) - return; - int index = indexOf (metaInformationResolver->currentSource()); + int index = lastMetaRead; qDebug () << "Reading meta info of " << metaInformationResolver->currentSource().fileName() << " => " << index; QMap metaData = metaInformationResolver->metaData(); - if (index >= 0) + if (index >= 0 && newState != Phonon::ErrorState) { items[index].artist = metaData.value("ARTIST"); items[index].title = metaData.value("TITLE"); @@ -125,8 +125,11 @@ void PlaylistManager::metaStateChanged(Phonon::State newState, Phonon::State old else items[index].playable = true; emit itemUpdated (index); - if (index >= 0 && items.size () > index + 1) - metaInformationResolver->setCurrentSource(items[index + 1].source); + } + if (index >= 0 && items.size () > index + 1) + { + metaInformationResolver->setCurrentSource(items[index + 1].source); + lastMetaRead = index + 1; } } @@ -185,6 +188,7 @@ void PlaylistManager::loadPlaylist(const QString& filename) if (!items.isEmpty()) { metaInformationResolver->setCurrentSource(items.at(0).source); + lastMetaRead = 0; } emit playlistChanged (0); } @@ -199,6 +203,7 @@ void PlaylistManager::addPlaylist(const QString& filename) if (!items.isEmpty()) { metaInformationResolver->setCurrentSource(items.at(index).source); + lastMetaRead = index; emit playlistChanged (index); } } @@ -304,7 +309,11 @@ void PlaylistManager::removeItem(int i) bool PlaylistManager::fileSupported (const QString& fname) const { QString ext = fname.right(3).toLower(); -// if (ext != "mp3") -// return false; - return true; + foreach (QString e, allowedExtensions) + { + if (ext == e) + return true; + } + + return false; } diff --git a/playlistmanager.h b/playlistmanager.h index 25e6dde..eb91c09 100644 --- a/playlistmanager.h +++ b/playlistmanager.h @@ -5,6 +5,8 @@ #include #include + + struct PlaylistItem { Phonon::MediaSource source; @@ -50,6 +52,7 @@ private: Phonon::MediaObject *metaInformationResolver; QList items; QWidget* parentWidget; + int lastMetaRead; }; #endif // PLAYLISTMANAGER_H diff --git a/tomamp.pro b/tomamp.pro index 731d5a6..9cc2006 100644 --- a/tomamp.pro +++ b/tomamp.pro @@ -33,4 +33,5 @@ RESOURCES += \ ampres.qrc OTHER_FILES += \ - bugs.txt + bugs.txt \ + README -- 1.7.9.5