xref: /MusicPlayer2/MusicPlayer2/AudioTagOld.h (revision 1598e86c976ecacad15f3f6383421bb42cf540a7)
1 #pragma once
2 #include "AudioCommon.h"
3 
4 //主要通过BASS获取音频标签位置并手动解析标签内容,目前已经基本不再使用,现在获取音频标签使用taglib库,代码在CAudioTag类中。
5 class CAudioTagOld
6 {
7 public:
8 	CAudioTagOld(HSTREAM hStream, SongInfo & song_info, AudioType type);
9 	~CAudioTagOld();
10 
11     wstring GetAudioLyric();
12 
13     //向一个MP3文件写入ID3V1标签
14 	//file_path:mp3文件的路径
15 	//text_cut_off:如果写入的文本长度超过ID3V1可容纳的长度,则过长的文本将会被截断,并将text_cut_off置为true
16 	//返回值:成功返回true,否则返回false
17 	static bool WriteMp3Tag(LPCTSTR file_path, SongInfo song_info, bool& text_cut_off);
18 
19     bool GetTagDefault();       //通过BASS获取标签起始位置手动解析标签
20     string GetAlbumCoverDefault(int& image_type);     //通过BASS获取id3v2标签的位置手动解析专辑封面
21 
GetAudioType()22 	AudioType GetAudioType() const { return m_type; }
23 
24     bool GetID3V1Tag();
25     bool GetID3V2Tag();
26     bool GetWmaTag();
27     bool GetMp4Tag();
28     bool GetOggTag();
29     bool GetApeTag();
30     bool GetFlacTag();
31 
32 private:
33 	HSTREAM m_hStream;
34 	SongInfo& m_song_info;
35 	AudioType m_type;
36 
37 
38 	//获取ID3V2标签区域的内容
39 	string GetID3V2TagContents() const;
40 
41 	//从ID3V2标签区域的内容中提取出指定的ID3标签
42 	//tag_contents:整个标签区域的内容
43 	//tag_identify:标签的标识
44 	wstring GetSpecifiedId3V2Tag(const string& tag_contents, const string& tag_identify);
45 
46 	wstring FindOneFlacTag(const string& tag_contents, const string& tag_identify, size_t& index);
47 
48     //从FLAC标签区域的内容中提取出指定的FLAC标签
49     //tag_contents:整个标签区域的内容
50     //tag_identify:标签的标识
51     wstring GetSpecifiedFlacTag(const string& tag_contents, const string& tag_identify);
52 
53 	//获取wma/mp4/ogg格式的UTF8格式的标签区域
54 	string GetUtf8TagContents(const char* tag_start);
55 
56 	string GetWmaTagContents();
57 	string GetMp4TagContents();
58 	string GetOggTagContents();
59 	string GetApeTagContents();
60 
61 	//从UTF8标签区域的内容中提取出指定的标签
62 	wstring GetSpecifiedUtf8Tag(const string& tag_contents, const string& tag_identify);
63 
64 	//获取FLAC音频的标签区域的内容
65 	static void GetFlacTagContents(wstring file_path, string& contents_buff);
66 
67     static string FindID3V2AlbumCover(const string& tag_content, int& image_type);
68 };
69