本文实例讲述了C++实现显示MP3文件信息的方法。分享给大家供大家参考。具体实现方法如下:
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/**
* This is small example how to use libZPlay library to play files.
* This example is using OpenFile functions to open disk files and play.
*/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <olectl.h>
#include <ole2.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <dos.h>
#include <conio.h>
#include "../include/libzplay.h"
using namespace libZPlay;
ZPlay* player;
int __stdcall CallbackFunc(void* instance, void *user_data, TCallbackMessage message, unsigned int param1, unsigned int param2);
int main(int argc, char **argv)
{
// clear screen
system("CLS");
// create class instance
player = CreateZPlay();
// chek if we have class instance
if(player == 0)
{
printf("Error: Can't create class instance !nPress key to exit.n");
getch();
return 0;
}
// get library version
int ver = player->GetVersion();
// check if we have version 2.00 and above
if(ver < 200)
{
printf("Error: Need library version 2.00 and above !nPress key to exit.\\r\\n");
getch();
player->Release();
return 0;
}
// display version info
printf("libZPlay v.%i.%02i\\r\\n\\r\\n", ver / 100, ver % 100);
if(argc > 1)
{
TID3InfoEx id3_info;
if(player->LoadFileID3Ex(argv[1], sfAutodetect, &id3_info, 1)) // loading ID3v2
{
printf("Title: %s\\r\\n", id3_info.Title);
printf("Artist: %s\\r\\n", id3_info.Artist);
printf("Album: %s\\r\\n", id3_info.Album);
printf("Year: %s\\r\\n", id3_info.Year);
printf("Comment: %s\\r\\n", id3_info.Comment);
printf("Genre: %s\\r\\n", id3_info.Genre);
printf("Track: %s\\r\\n\\r\\n", id3_info.TrackNum);
printf("Artist1 : %s\\r\\n", id3_info.AlbumArtist );
printf("Composer: %s\\r\\n", id3_info.Composer );
printf("Original: %s\\r\\n", id3_info.OriginalArtist );
printf("Copyright: %s\\r\\n", id3_info.Copyright );
printf("URL: %s\\r\\n", id3_info.URL );
printf("Encoder: %s\\r\\n", id3_info.Encoder );
printf("Publisher: %s\\r\\n", id3_info.Publisher );
printf("BPM: %u\\r\\n", id3_info.BPM);
printf("MIME: %s\\r\\n", id3_info.Picture.MIMEType);
printf("TYPE: %u\\r\\n", id3_info.Picture.PictureType);
printf("Desc: %s\\r\\n", id3_info.Picture.Description);
printf("Size: %u\\r\\n", id3_info.Picture.PictureDataSize);
// draw picture on desktop window
player->DrawBitmapToHWND(NULL, 0, 0, 0, 0, id3_info.Picture.hBitmap);
}
else
{
printf("No ID3 data\\r\\n\\r\\n");
}
}
else
{
// no filename in argument
player->Release(); // delete ZPlay class
char *end = strrchr(argv[0], '\\');
if(end && *(end + 1) != 0)
end++;
else
end = argv[0];
printf("Usage: %s filename\\r\\n\\r\\nPress key to exit\\r\\n", end);
getch();
return 0;
}
getch();
}
|
希望本文所述对大家的C++程序设计有所帮助。
相关文章
猜你喜欢
- ASP.NET自助建站系统的数据库备份与恢复操作指南 2025-06-10
- 个人网站服务器域名解析设置指南:从购买到绑定全流程 2025-06-10
- 个人网站搭建:如何挑选具有弹性扩展能力的服务器? 2025-06-10
- 个人服务器网站搭建:如何选择适合自己的建站程序或框架? 2025-06-10
- 64M VPS建站:能否支持高流量网站运行? 2025-06-10
TA的动态
- 2025-07-10 怎样使用阿里云的安全工具进行服务器漏洞扫描和修复?
- 2025-07-10 怎样使用命令行工具优化Linux云服务器的Ping性能?
- 2025-07-10 怎样使用Xshell连接华为云服务器,实现高效远程管理?
- 2025-07-10 怎样利用云服务器D盘搭建稳定、高效的网站托管环境?
- 2025-07-10 怎样使用阿里云的安全组功能来增强服务器防火墙的安全性?
快网idc优惠网
QQ交流群
您的支持,是我们最大的动力!
热门文章
-
2025-05-25 29
-
2025-05-29 64
-
2025-06-04 75
-
2025-05-25 93
-
2025-05-29 38
热门评论

