这里需要说明的是:一般的播放器用的是 Lyric 文件格式,对应的标签是 WM/Lyrics.
WM/Lyrics 是属于 WMT_TYPE_STRING
而这里说的并非这个。
在WMF SDK 11中:
typedef struct _WMSynchronisedLyrics{
BYTE bTimeStampFormat;
BYTE bContentType;
LPWSTR pwszContentDescriptor;
DWORD dwLyricsLen;
BYTE* pbLyrics;
} WM_SYNCHRONISED_LYRICS;
所属类型是:WMT_TYPE_BINARY
其中:
bTimeStampFormat: (时间戳标识)
Value | Description |
1 | Time stamps are 32-bit values containing the absolute time of the lyric in frame numbers. |
2 | Time stamps are 32-bit values containing the absolute time of the lyric in milliseconds. |
bContentType: (内容类型)
BYTE specifying the type of synchronized strings that are in the lyrics data. Set to one of the following values.
Value | Description |
0 | Synchronized strings other than the types listed in this table |
1 | Song lyrics |
2 | Text transcription |
3 | Names of parts of the content. For example, movements of classical pieces, like "Adagio" |
4 | Events, such as stage directions in operas |
5 | Chord notations |
6 | Trivia information |
7 | URLs to Web pages |
8 | URLs to images |
pwszContentDescriptor :(内容说明)
指针,指向宽字符,以 null 结尾。
dwLyricsLen :(歌词内容的长度)
pbLyrics: (歌词)
调用函数取得所返回值得到如图所示:
其他的很清楚,不多说,这里只说其中 pwszContentDescriptor 的长度的计算:
假设其长度为:Len
Len = 70 27 AD 00 (转为十进制整数) - 5E 27 AD 00 (转为十进制整数)
就是pwszContentDescriptor 长度了。这里的值是:
Len = 11347824 - 11347806
结果为:18 , 与图正确对应!
类推直接得出dwLyricsLen 的数值。
下面说 pbLyrics ,如图所示:
浅黄色代表的是歌词,
红色是时间:
bTimeStampFormat=2 的话 毫秒为单位,
bTimeStampFormat=1 的话,帧数号为单位,
如此不断的依次排列,只要得到这两个值就可以得到同步歌词了。