mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-09-03 02:41:12 +02:00
audioplayer: show cover from id3-tag or folder.jpg in header
if exist a file called folder.jpg in same dir as the audiofile
or a audiocover is defined in id3-tag it will be displayed in header.
cover in tag is preferred.
ported from mohusch. original patch by tangocash. thx!
Origin commit data
------------------
Commit: fe07423ad1
Author: vanhofen <vanhofen@gmx.de>
Date: 2013-11-09 (Sat, 09 Nov 2013)
Origin message was:
------------------
- audioplayer: show cover from id3-tag or folder.jpg in header
if exist a file called folder.jpg in same dir as the audiofile
or a audiocover is defined in id3-tag it will be displayed in header.
cover in tag is preferred.
ported from mohusch. original patch by tangocash. thx!
This commit is contained in:
@@ -944,6 +944,7 @@ bool CMP3Dec::GetMetaData(FILE* in, const bool nice, CAudioMetaData* const m)
|
||||
{
|
||||
res = GetMP3Info(in, nice, m);
|
||||
GetID3(in, m);
|
||||
SaveCover(in, m);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1344,6 +1345,82 @@ void CMP3Dec::GetID3(FILE* in, CAudioMetaData* const m)
|
||||
}
|
||||
}
|
||||
|
||||
bool CMP3Dec::SaveCover(FILE * in, CAudioMetaData * const m)
|
||||
{
|
||||
struct id3_frame const *frame;
|
||||
const char * coverfile = "/tmp/cover.jpg";
|
||||
|
||||
/* text information */
|
||||
struct id3_file *id3file = id3_file_fdopen(fileno(in), ID3_FILE_MODE_READONLY);
|
||||
|
||||
if(id3file == 0)
|
||||
{
|
||||
printf("CMP3Dec::SaveCover: error open id3 file\n");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
id3_tag * tag = id3_file_tag(id3file);
|
||||
if(tag)
|
||||
{
|
||||
frame = id3_tag_findframe(tag, "APIC", 0);
|
||||
|
||||
if (frame)
|
||||
{
|
||||
printf("CMP3Dec::SaveCover: Cover found\n");
|
||||
// Picture file data
|
||||
unsigned int j;
|
||||
union id3_field const *field;
|
||||
|
||||
for (j = 0; (field = id3_frame_field(frame, j)); j++)
|
||||
{
|
||||
switch (id3_field_type(field))
|
||||
{
|
||||
case ID3_FIELD_TYPE_BINARYDATA:
|
||||
id3_length_t size;
|
||||
id3_byte_t const *data;
|
||||
|
||||
data = id3_field_getbinarydata(field, &size);
|
||||
if ( data )
|
||||
{
|
||||
m->cover = coverfile;
|
||||
FILE * pFile;
|
||||
pFile = fopen ( coverfile , "wb" );
|
||||
fwrite (data , 1 , size , pFile );
|
||||
fclose (pFile);
|
||||
}
|
||||
break;
|
||||
|
||||
case ID3_FIELD_TYPE_INT8:
|
||||
//pic->type = id3_field_getint(field);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
id3_tag_delete(tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("CMP3Dec::SaveCover: error open id3 tag\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
id3_finish_file(id3file);
|
||||
}
|
||||
|
||||
if(0)
|
||||
{
|
||||
printf("CMP3Dec::SaveCover:id3: not enough memory to display tag\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// this is a copy of static libid3tag function "finish_file"
|
||||
// which cannot be called from outside
|
||||
void id3_finish_file(struct id3_file* file)
|
||||
|
Reference in New Issue
Block a user