From 636122c8c605ae9f771f2d1da41f90b2fb2f446b Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Wed, 19 Aug 2020 19:53:05 +0800 Subject: [PATCH] fix: add to playlist even if it's not using a common suffix --- mainwindow.cpp | 8 +++++++- pineapple-music.desktop | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 7a3d6ae..4b97e85 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -64,7 +64,7 @@ void MainWindow::loadPlaylistBySingleLocalFile(const QString &path) QFileInfo info(path); QDir dir(info.path()); QString currentFileName = info.fileName(); - QStringList entryList = dir.entryList({"*.mp3", "*.wav", "*.aiff", "*.ape", "*.flac", "*.ogg", "*.oga"}, + QStringList entryList = dir.entryList({"*.mp3", "*.wav", "*.aiff", "*.ape", "*.flac", "*.ogg", "*.oga", "*.mpga"}, QDir::Files | QDir::NoSymLinks, QDir::NoSort); QCollator collator; @@ -82,6 +82,12 @@ void MainWindow::loadPlaylistBySingleLocalFile(const QString &path) } } + if (currentFileIndex == -1) { + // not in the list probably because of the suffix is not a common one, add it to the first one anyway. + urlList.prepend(QUrl::fromLocalFile(path)); + currentFileIndex = 0; + } + QMediaPlaylist * playlist = createPlaylist(urlList); playlist->setCurrentIndex(currentFileIndex); } diff --git a/pineapple-music.desktop b/pineapple-music.desktop index f4db60f..9d687be 100644 --- a/pineapple-music.desktop +++ b/pineapple-music.desktop @@ -1,5 +1,5 @@ [Desktop Entry] -Categories=Player;Audio; +Categories=Audio;Player; Comment=Pineapple Music Audio Player. Exec=pmusic %F GenericName=Music