fix: add to playlist even if it's not using a common suffix

This commit is contained in:
Gary Wang 2020-08-19 19:53:05 +08:00
parent e4cf159010
commit 636122c8c6
2 changed files with 8 additions and 2 deletions

View File

@ -64,7 +64,7 @@ void MainWindow::loadPlaylistBySingleLocalFile(const QString &path)
QFileInfo info(path); QFileInfo info(path);
QDir dir(info.path()); QDir dir(info.path());
QString currentFileName = info.fileName(); 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); QDir::Files | QDir::NoSymLinks, QDir::NoSort);
QCollator collator; 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); QMediaPlaylist * playlist = createPlaylist(urlList);
playlist->setCurrentIndex(currentFileIndex); playlist->setCurrentIndex(currentFileIndex);
} }

View File

@ -1,5 +1,5 @@
[Desktop Entry] [Desktop Entry]
Categories=Player;Audio; Categories=Audio;Player;
Comment=Pineapple Music Audio Player. Comment=Pineapple Music Audio Player.
Exec=pmusic %F Exec=pmusic %F
GenericName=Music GenericName=Music