栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

C++实现显示MP3文件信息的方法

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

C++实现显示MP3文件信息的方法

本文实例讲述了C++实现显示MP3文件信息的方法。分享给大家供大家参考。具体实现方法如下:


#define WIN32_LEAN_AND_MEAN
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#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.rn");
    getch();
    player->Release();
    return 0;
  }
  // display version info
  printf("libZPlay v.%i.%02irnrn", ver / 100, ver % 100);
  if(argc > 1) 
  {
    TID3InfoEx id3_info;
    if(player->LoadFileID3Ex(argv[1], sfAutodetect, &id3_info, 1)) // loading ID3v2
    {
      printf("Title:  %srn", id3_info.Title);
      printf("Artist: %srn", id3_info.Artist);
      printf("Album:  %srn", id3_info.Album);
      printf("Year:  %srn", id3_info.Year);
      printf("Comment: %srn", id3_info.Comment);
      printf("Genre:  %srn", id3_info.Genre);
      printf("Track:  %srnrn", id3_info.TrackNum);
      printf("Artist1 : %srn", id3_info.AlbumArtist );
      printf("Composer: %srn", id3_info.Composer );
      printf("Original: %srn", id3_info.OriginalArtist );
      printf("Copyright: %srn", id3_info.Copyright );
      printf("URL:    %srn", id3_info.URL );
      printf("Encoder:  %srn", id3_info.Encoder );
      printf("Publisher: %srn", id3_info.Publisher );
      printf("BPM:    %urn", id3_info.BPM);
      printf("MIME:   %srn", id3_info.Picture.MIMEType);
      printf("TYPE:   %urn", id3_info.Picture.PictureType);
      printf("Desc:   %srn", id3_info.Picture.Description);
      printf("Size:   %urn", id3_info.Picture.PictureDataSize);
      // draw picture on desktop window
      player->DrawBitmapToHWND(NULL, 0, 0, 0, 0, id3_info.Picture.hBitmap);
    }
    else
    {
      printf("No ID3 datarnrn");
    }
   }
   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 filenamernrnPress key to exitrn", end);
    getch();
    return 0;
   }
  getch();
}

希望本文所述对大家的C++程序设计有所帮助。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/65142.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号