Refactor tagging and add library scanning
- Replace `Tag` class with utility helpers for hashing and file type parsing - Change `Track.artwork` from `std::string` to `TagLib::VariantMap` - Add `importArtwork`, rename `importFolder` to `scanFolder` - Add `scanLibrary`, `updateLibrary`, `editMetadata`, and `seek` methods to `Player` hierarchy - Remove obsolete `Tag.h`/`Tag.cpp` files
This commit is contained in:
@@ -31,7 +31,7 @@ struct Track {
|
||||
unsigned int length;
|
||||
unsigned int year;
|
||||
std::string filePath;
|
||||
std::string artwork;
|
||||
TagLib::VariantMap artwork;
|
||||
TagLib::String genre;
|
||||
std::string format;
|
||||
uint64_t hash;
|
||||
|
||||
+3
-1
@@ -22,10 +22,12 @@ class Database {
|
||||
std::optional<int> getArtistId( const std::string& artistName );
|
||||
std::optional<int> getAlbumId( const std::string& albumTitle );
|
||||
std::optional<int> getGenreId( const std::string& genre );
|
||||
|
||||
void addTrack( Track t);
|
||||
void addArtist( const std::string& artistName );
|
||||
void addAlbum( Track t);
|
||||
void addGenre( std::string& genre );
|
||||
void addGenre( const std::string& genre );
|
||||
|
||||
void setActive( bool active );
|
||||
void updateFilePath( const std::string& filePath );
|
||||
|
||||
|
||||
+2
-1
@@ -11,8 +11,9 @@ namespace fs = std::filesystem;
|
||||
class File {
|
||||
public:
|
||||
Track importFile( const std::string& filePath );
|
||||
void importFolder( const std::string& folderPath, std::vector<Track>& tracks );
|
||||
void scanFolder( const std::string& folderPath, std::vector<Track>& tracks );
|
||||
void readFileTag( Track& t );
|
||||
TagLib::VariantMap importArtwork( Track& t );
|
||||
std::string parseFiletype( const std::string& path );
|
||||
void updateLibrary();
|
||||
uint64_t hashString( Track t );
|
||||
|
||||
@@ -17,6 +17,9 @@ class Player {
|
||||
|
||||
virtual void initPlayer ();
|
||||
virtual void loadFile ( Track track );
|
||||
virtual void scanLibrary();
|
||||
virtual void updateLibrary();
|
||||
virtual void editMetadata();
|
||||
|
||||
// Transport Control
|
||||
virtual void play ();
|
||||
@@ -24,6 +27,7 @@ class Player {
|
||||
virtual void pause ();
|
||||
virtual void previous ();
|
||||
virtual void next ();
|
||||
virtual void seek();
|
||||
|
||||
virtual ma_uint64 getPlayheadPosition ();
|
||||
virtual void setPlayheadPosition () const;
|
||||
@@ -44,6 +48,7 @@ class Player {
|
||||
protected:
|
||||
PlaybackEngine PE_;
|
||||
trackVec queue_;
|
||||
std::vector<Track> library;
|
||||
|
||||
private:
|
||||
std::string artist_;
|
||||
|
||||
+17
-1
@@ -1,17 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "Player.h"
|
||||
#include "Database.h"
|
||||
|
||||
using db = Database;
|
||||
|
||||
class PlayerLocal : public Player {
|
||||
public:
|
||||
// Library Controls
|
||||
void loadFile ( Track track ) override;
|
||||
void scanLibrary() override;
|
||||
void updateLibrary() override;
|
||||
void editMetadata() override;
|
||||
|
||||
// Transport Controls
|
||||
void play() override;
|
||||
void pause() override;
|
||||
void stop() override;
|
||||
void next() override;
|
||||
void previous() override;
|
||||
void seek() override;
|
||||
ma_uint64 getPlayheadPosition () override;
|
||||
void loadFile ( Track track ) override;
|
||||
|
||||
// Queue
|
||||
void addToQueue( Track& track );
|
||||
void playQueue();
|
||||
|
||||
private:
|
||||
unsigned int currentTrack_;
|
||||
db db_;
|
||||
std::string musicFolder_ = "data/";
|
||||
};
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "containers.h"
|
||||
//#include "file.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <taglib/tstring.h>
|
||||
#include <taglib/fileref.h>
|
||||
#include <taglib/tvariant.h>
|
||||
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
class tag {
|
||||
public:
|
||||
void readtag( TagLib::filename filename );
|
||||
metadata getmetadata() const;
|
||||
|
||||
const std::string& getfilepath() const;
|
||||
const auto getartwork() const;
|
||||
private:
|
||||
metadata metadata_;
|
||||
std::string filepath_;
|
||||
fs::path musicdir = music_folder;
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Containers.h"
|
||||
#include <cstdint>
|
||||
|
||||
namespace utility {
|
||||
|
||||
uint64_t hashString( const std::string& s );
|
||||
std::string parseFiletype( const std::string& filePath );
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user