mirror of
https://github.com/zhongyang219/MusicPlayer2.git
synced 2026-10-29 13:18:58 +08:00
新增aiff格式专辑封面的读写
This commit is contained in:
@@ -130,6 +130,9 @@ wstring CAudioTag::GetAlbumCover(int & image_type, wchar_t* file_name, size_t* f
|
||||
case AU_SPX:
|
||||
image_contents = CTagLibHelper::GetSpxAlbumCover(m_song_info.file_path, image_type);
|
||||
break;
|
||||
case AU_AIFF:
|
||||
image_contents = CTagLibHelper::GetAiffAlbumCover(m_song_info.file_path, image_type);
|
||||
break;
|
||||
case AU_CUE:
|
||||
break;
|
||||
case AU_MIDI:
|
||||
@@ -245,7 +248,7 @@ bool CAudioTag::WriteAlbumCover(const wstring & album_cover_path)
|
||||
case AU_APE:
|
||||
return CTagLibHelper::WriteApeAlbumCover(m_song_info.file_path, album_cover_path);
|
||||
case AU_AIFF:
|
||||
break;
|
||||
return CTagLibHelper::WriteAiffAlbumCover(m_song_info.file_path, album_cover_path);
|
||||
case AU_FLAC:
|
||||
return CTagLibHelper::WriteFlacAlbumCover(m_song_info.file_path, album_cover_path);
|
||||
case AU_WAV:
|
||||
@@ -285,6 +288,6 @@ bool CAudioTag::IsFileTypeCoverWriteSupport(const wstring& ext)
|
||||
CCommon::StringTransform(_ext, false);
|
||||
AudioType type = CAudioCommon::GetAudioTypeByFileExtension(_ext);
|
||||
return type == AU_MP3 || type == AU_FLAC || type == AU_MP4 || type == AU_WMA_ASF || type == AU_WAV || type == AU_APE
|
||||
|| type == AU_OGG || type == AU_OPUS || type == AU_SPX;
|
||||
|| type == AU_OGG || type == AU_OPUS || type == AU_SPX || type == AU_AIFF;
|
||||
}
|
||||
|
||||
|
||||
@@ -408,6 +408,16 @@ string CTagLibHelper::GetSpxAlbumCover(const wstring& file_path, int& type)
|
||||
return cover_contents;
|
||||
}
|
||||
|
||||
string CTagLibHelper::GetAiffAlbumCover(const wstring& file_path, int& type)
|
||||
{
|
||||
string cover_contents;
|
||||
RIFF::AIFF::File file(file_path.c_str());
|
||||
auto id3v2 = file.tag();
|
||||
GetId3v2AlbumCover(id3v2, cover_contents, type);
|
||||
return cover_contents;
|
||||
|
||||
}
|
||||
|
||||
void CTagLibHelper::GetFlacTagInfo(SongInfo& song_info)
|
||||
{
|
||||
FLAC::File file(song_info.file_path.c_str());
|
||||
@@ -870,6 +880,26 @@ bool CTagLibHelper::WriteSpxAlbumCover(const wstring& file_path, const wstring&
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CTagLibHelper::WriteAiffAlbumCover(const wstring& file_path, const wstring& album_cover_path, bool remove_exist /*= true*/)
|
||||
{
|
||||
RIFF::AIFF::File file(file_path.c_str());
|
||||
if (!file.isValid())
|
||||
return false;
|
||||
|
||||
//先删除专辑封面
|
||||
auto id3v2tag = file.tag();
|
||||
if (remove_exist)
|
||||
{
|
||||
DeleteId3v2AlbumCover(id3v2tag);
|
||||
}
|
||||
if (!album_cover_path.empty())
|
||||
{
|
||||
WriteId3v2AlbumCover(id3v2tag, album_cover_path);
|
||||
}
|
||||
bool saved = file.save();
|
||||
return saved;
|
||||
}
|
||||
|
||||
bool CTagLibHelper::WriteMpegTag(SongInfo & song_info)
|
||||
{
|
||||
MPEG::File file(song_info.file_path.c_str());
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
static string GetOggAlbumCover(const wstring& file_path, int& type);
|
||||
static string GetOpusAlbumCover(const wstring& file_path, int& type);
|
||||
static string GetSpxAlbumCover(const wstring& file_path, int& type);
|
||||
static string GetAiffAlbumCover(const wstring& file_path, int& type);
|
||||
|
||||
//读标签信息
|
||||
static void GetFlacTagInfo(SongInfo& song_info);
|
||||
@@ -54,6 +55,7 @@ public:
|
||||
static bool WriteOggAlbumCover(const wstring& file_path, const wstring& album_cover_path, bool remove_exist = true);
|
||||
static bool WriteOpusAlbumCover(const wstring& file_path, const wstring& album_cover_path, bool remove_exist = true);
|
||||
static bool WriteSpxAlbumCover(const wstring& file_path, const wstring& album_cover_path, bool remove_exist = true);
|
||||
static bool WriteAiffAlbumCover(const wstring& file_path, const wstring& album_cover_path, bool remove_exist = true);
|
||||
|
||||
//写标签信息
|
||||
static bool WriteMpegTag(SongInfo& song_info);
|
||||
|
||||
Reference in New Issue
Block a user