Implement taglib and use in filescan / player | Extend supported media
This commit is contained in:
parent
90ccf5b55a
commit
5234599c90
@ -33,6 +33,7 @@ find_package(Qt5 COMPONENTS Multimedia MultimediaWidgets Bluetooth)
|
||||
find_package(Protobuf REQUIRED)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(rtaudio REQUIRED)
|
||||
find_package(taglib REQUIRED)
|
||||
|
||||
if(WIN32)
|
||||
set(WINSOCK2_LIBRARIES "ws2_32")
|
||||
@ -56,6 +57,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}
|
||||
${PROTOBUF_INCLUDE_DIR}
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
${RTAUDIO_INCLUDE_DIRS}
|
||||
${TAGLIB_INCLUDE_DIRS}
|
||||
${AASDK_PROTO_INCLUDE_DIRS}
|
||||
${AASDK_INCLUDE_DIRS}
|
||||
${BCM_HOST_INCLUDE_DIRS}
|
||||
@ -83,6 +85,7 @@ target_link_libraries(autoapp
|
||||
${ILCLIENT_LIBRARIES}
|
||||
${WINSOCK2_LIBRARIES}
|
||||
${RTAUDIO_LIBRARIES}
|
||||
${TAGLIB_LIBRARIES}
|
||||
${AASDK_PROTO_LIBRARIES}
|
||||
${AASDK_LIBRARIES})
|
||||
|
||||
|
70
cmake_modules/Findtaglib.cmake
Normal file
70
cmake_modules/Findtaglib.cmake
Normal file
@ -0,0 +1,70 @@
|
||||
#
|
||||
# This file is part of openauto project.
|
||||
# Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
#
|
||||
# openauto is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
|
||||
# openauto is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
if (TAGLIB_LIBRARIES AND TAGLIB_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
set(TAGLIB_FOUND TRUE)
|
||||
else (TAGLIB_LIBRARIES AND TAGLIB_INCLUDE_DIRS)
|
||||
find_path(TAGLIB_INCLUDE_DIR
|
||||
NAMES
|
||||
taglib.h
|
||||
PATHS
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/opt/local/include
|
||||
/sw/include
|
||||
PATH_SUFFIXES
|
||||
taglib
|
||||
)
|
||||
|
||||
find_library(TAGLIB_LIBRARY
|
||||
NAMES
|
||||
tag taglib libtag
|
||||
PATHS
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
/opt/local/lib
|
||||
/sw/lib
|
||||
)
|
||||
|
||||
set(TAGLIB_INCLUDE_DIRS
|
||||
${TAGLIB_INCLUDE_DIR}
|
||||
)
|
||||
set(TAGLIB_LIBRARIES
|
||||
${TAGLIB_LIBRARY} -ltag
|
||||
)
|
||||
|
||||
if (TAGLIB_INCLUDE_DIRS AND TAGLIB_LIBRARIES)
|
||||
set(TAGLIB_FOUND TRUE)
|
||||
endif (TAGLIB_INCLUDE_DIRS AND TAGLIB_LIBRARIES)
|
||||
|
||||
if (TAGLIB_FOUND)
|
||||
if (NOT taglib_FIND_QUIETLY)
|
||||
message(STATUS "Found taglib:")
|
||||
message(STATUS " - Includes: ${TAGLIB_INCLUDE_DIRS}")
|
||||
message(STATUS " - Libraries: ${TAGLIB_LIBRARIES}")
|
||||
endif (NOT taglib_FIND_QUIETLY)
|
||||
else (TAGLIB_FOUND)
|
||||
if (taglib_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could not find taglib")
|
||||
endif (taglib_FIND_REQUIRED)
|
||||
endif (TAGLIB_FOUND)
|
||||
|
||||
mark_as_advanced(TAGLIB_INCLUDE_DIRS TAGLIB_LIBRARIES)
|
||||
|
||||
endif (TAGLIB_LIBRARIES AND TAGLIB_INCLUDE_DIRS)
|
@ -37,6 +37,11 @@
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
#include <qmediaplayer.h>
|
||||
#include <taglib/fileref.h>
|
||||
#include <taglib/tag.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class MainWindow;
|
||||
|
@ -29,8 +29,6 @@
|
||||
#include <QFont>
|
||||
#include <QScreen>
|
||||
#include <QRect>
|
||||
#include <string>
|
||||
#include <qmediaplayer.h>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -1305,24 +1303,37 @@ void f1x::openauto::autoapp::ui::MainWindow::metaDataChanged()
|
||||
} else {
|
||||
ui_->pushButtonBack->setIcon(QPixmap("://coverlogo.png"));
|
||||
}
|
||||
QString Title = player->metaData(QMediaMetaData::Title).toString();
|
||||
QString AlbumInterpret = player->metaData(QMediaMetaData::AlbumArtist).toString();
|
||||
if (AlbumInterpret == "" && ui_->comboBoxAlbum->currentText() != ".") {
|
||||
AlbumInterpret = ui_->comboBoxAlbum->currentText();
|
||||
}
|
||||
QString currentPlaying = "";
|
||||
if (AlbumInterpret != "") {
|
||||
currentPlaying.append(AlbumInterpret);
|
||||
}
|
||||
if (Title != "" && AlbumInterpret != "") {
|
||||
currentPlaying.append(" - ");
|
||||
}
|
||||
if (Title != "") {
|
||||
currentPlaying.append(Title);
|
||||
}
|
||||
ui_->labelCurrentPlaying->setText(currentPlaying);
|
||||
|
||||
QString fullpathplaying = player->currentMedia().canonicalUrl().toString();
|
||||
QString filename = QFileInfo(fullpathplaying).fileName();
|
||||
|
||||
try {
|
||||
// use metadata from mp3list widget (prescanned id3 by taglib)
|
||||
if (playlist->currentIndex() != -1 && fullpathplaying != "") {
|
||||
QString currentsong = ui_->mp3List->item(playlist->currentIndex())->text();
|
||||
ui_->labelCurrentPlaying->setText(currentsong);
|
||||
}
|
||||
} catch (...) {
|
||||
// use metadata from player
|
||||
QString AlbumInterpret = player->metaData(QMediaMetaData::AlbumArtist).toString();
|
||||
QString Title = player->metaData(QMediaMetaData::Title).toString();
|
||||
|
||||
if (AlbumInterpret == "" && ui_->comboBoxAlbum->currentText() != ".") {
|
||||
AlbumInterpret = ui_->comboBoxAlbum->currentText();
|
||||
}
|
||||
QString currentPlaying;
|
||||
|
||||
if (AlbumInterpret != "") {
|
||||
currentPlaying.append(AlbumInterpret);
|
||||
}
|
||||
if (Title != "" && AlbumInterpret != "") {
|
||||
currentPlaying.append(" - ");
|
||||
}
|
||||
if (Title != "") {
|
||||
currentPlaying.append(Title);
|
||||
}
|
||||
ui_->labelCurrentPlaying->setText(currentPlaying);
|
||||
}
|
||||
ui_->labelTrack->setText(QString::number(playlist->currentIndex()+1));
|
||||
ui_->labelTrackCount->setText(QString::number(playlist->mediaCount()));
|
||||
}
|
||||
@ -1379,12 +1390,30 @@ void f1x::openauto::autoapp::ui::MainWindow::scanFiles()
|
||||
|
||||
QList<QMediaContent> content;
|
||||
QDir directory(this->musicfolder + "/" + this->albumfolder);
|
||||
QStringList mp3s = directory.entryList(QStringList() << "*.mp3" << "*.flac" << "*.aac" << "*.ogg",QDir::Files, QDir::Name);
|
||||
QStringList mp3s = directory.entryList(QStringList() << "*.mp3" << "*.flac" << "*.aac" << "*.ogg" << "*.mp4",QDir::Files, QDir::Name);
|
||||
foreach (QString filename, mp3s) {
|
||||
// add to mediacontent
|
||||
content.push_back(QMediaContent(QUrl::fromLocalFile(this->musicfolder + "/" + this->albumfolder + "/" + filename)));
|
||||
// add items to gui
|
||||
ui_->mp3List->addItem(filename);
|
||||
// read metadata using taglib
|
||||
try {
|
||||
TagLib::FileRef file((this->musicfolder + "/" + this->albumfolder + "/" + filename).toUtf8(),true);
|
||||
TagLib::String artist_string = file.tag()->artist();
|
||||
TagLib::String title_string = file.tag()->title();
|
||||
TagLib::uint track_string = file.tag()->track();
|
||||
QString artistid3 = QString::fromStdWString(artist_string.toCWString());
|
||||
QString titleid3 = QString::fromStdWString(title_string.toCWString());
|
||||
QString trackid3 = QString::number(track_string);
|
||||
int tracklength = trackid3.length();
|
||||
if (tracklength < 2) {
|
||||
trackid3 = "0" + trackid3;
|
||||
}
|
||||
QString ID3Entry = trackid3 + ": " + artistid3 + " - " + titleid3;
|
||||
ui_->mp3List->addItem(ID3Entry);
|
||||
} catch (...) {
|
||||
// old way only adding filename to list
|
||||
ui_->mp3List->addItem(filename);
|
||||
}
|
||||
}
|
||||
// set playlist
|
||||
this->playlist->addMedia(content);
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>907</width>
|
||||
<height>1291</height>
|
||||
<height>1295</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -3006,13 +3006,13 @@ outline: none;</string>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>16</height>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>16</height>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
@ -3035,13 +3035,13 @@ background-color: rgba(0, 0, 0, 0);</string>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>16</height>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16</height>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
|
Loading…
x
Reference in New Issue
Block a user