Working on #56
This commit is contained in:
@@ -7,6 +7,7 @@ using NLog;
|
||||
using TagLib;
|
||||
|
||||
using Icarus.Models;
|
||||
using Icarus.Controllers.Managers;
|
||||
|
||||
namespace Icarus.Controllers.Utilities
|
||||
{
|
||||
@@ -63,7 +64,9 @@ namespace Icarus.Controllers.Utilities
|
||||
|
||||
#region C++ Libs
|
||||
[DllImport("libicarus.so")]
|
||||
public static extern void retrieve_metadata(ref Icarus.Controllers.Managers.SongManager.Sng sng, string file_path);
|
||||
public static extern void retrieve_metadata(ref SongManager.Sng sng, string file_path);
|
||||
[DllImport("libicarus.so")]
|
||||
public static extern void update_metadata(ref SongManager.Sng sng_updated, ref SongManager.Sng sng_old);
|
||||
#endregion
|
||||
|
||||
public byte[] RetrieveCoverArtBytes(Song song)
|
||||
|
||||
@@ -10,6 +10,7 @@ extern "C"
|
||||
{
|
||||
|
||||
void retrieve_metadata(Song*, char*);
|
||||
void update_metadata(Song*, Song*);
|
||||
|
||||
void retrieve_metadata(Song *sng, char* song_path)
|
||||
{
|
||||
@@ -24,5 +25,28 @@ void retrieve_metadata(Song *sng, char* song_path)
|
||||
sng->Duration = file.audioProperties()->lengthInSeconds();
|
||||
strcpy(sng->SongPath, song_path);
|
||||
}
|
||||
void update_metadata(Song *sng_updated, Song *sng_old)
|
||||
{
|
||||
std::cout<<"updating metadata"<<std::endl;
|
||||
TagLib::FileRef file(sng_old->SongPath);
|
||||
|
||||
if (strlen(sng_updated->Title) > 0) {
|
||||
file.tag()->setTitle(sng_updated->Title);
|
||||
}
|
||||
if (strlen(sng_updated->Artist) > 0) {
|
||||
file.tag()->setArtist(sng_updated->Artist);
|
||||
}
|
||||
if (strlen(sng_updated->Album) > 0) {
|
||||
file.tag()->setAlbum(sng_updated->Album);
|
||||
}
|
||||
if (strlen(sng_updated->Genre) > 0) {
|
||||
file.tag()->setGenre(sng_updated->Genre);
|
||||
}
|
||||
if (sng_updated->Year > 0) {
|
||||
file.tag()->setYear(sng_updated->Year);
|
||||
}
|
||||
|
||||
file.save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user