C++實(shí)現(xiàn)顯示MP3文件信息的方法
更新時(shí)間:2015年06月15日 09:55:03 作者:紅薯
這篇文章主要介紹了C++實(shí)現(xiàn)顯示MP3文件信息的方法,可實(shí)現(xiàn)顯示如作者、專輯等(libZPlay)信息的功能,需要的朋友可以參考下
本文實(shí)例講述了C++實(shí)現(xiàn)顯示MP3文件信息的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
/**
* 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();
}
希望本文所述對(duì)大家的C++程序設(shè)計(jì)有所幫助。
相關(guān)文章
C語(yǔ)言實(shí)現(xiàn)經(jīng)典24點(diǎn)算法
這篇文章主要為大家詳細(xì)介紹了C語(yǔ)言實(shí)現(xiàn)經(jīng)典24點(diǎn)算法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-10-10
C語(yǔ)言實(shí)現(xiàn)牛頓迭代法解方程詳解
這篇文章主要介紹了C語(yǔ)言實(shí)現(xiàn)牛頓迭代法解方程詳解的相關(guān)資料,需要的朋友可以參考下2017-03-03
VS2022 無(wú)法打開源文件“stdio.h”問題解決
本文主要介紹了VS2022 無(wú)法打開源文件“stdio.h”問題解決,文中通過圖文的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2024-06-06
基于Matlab實(shí)現(xiàn)有雪花飄落的圣誕樹的繪制
圣誕節(jié)快到了(雖然還有十天),一起來(lái)用MATLAB畫個(gè)簡(jiǎn)單圣誕樹叭~代碼幾乎取消了全部的循環(huán),因此至少需要17b之后的版本,僅存的循環(huán)用來(lái)讓樹旋轉(zhuǎn)起來(lái),讓雪花飄落起來(lái),讓樹頂上的星光搖曳起來(lái)~感興趣的可以試一試2022-12-12

