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

所属分类: 软件编程 / C 语言 阅读数: 48
收藏 0 赞 0 分享

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

/**
 * 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++程序设计有所帮助。

更多精彩内容其他人还在看

C++广播通信实例

这篇文章主要介绍了C++实现广播通信的方法,实例讲述了C++ socket广播通信的原理与实现方法,需要的朋友可以参考下
收藏 0 赞 0 分享

C++计算ICMP头的校验和实例

这篇文章主要介绍了C++计算ICMP头的校验和的方法,代码简单实用,对于校验ICMP报文来说有不错的实用价值,需要的朋友可以参考下
收藏 0 赞 0 分享

C++设置超时时间的简单实现方法

这篇文章主要介绍了C++设置超时时间的简单实现方法,涉及系统函数setsockopt对套接口的操作,具有一定的实用价值,需要的朋友可以参考下
收藏 0 赞 0 分享

C++实现ping程序实例

这篇文章主要介绍了C++实现ping程序实例,涉及C++对于ICMP数据包的发送与回显处理,具有一定的实用价值,需要的朋友可以参考下
收藏 0 赞 0 分享

C++之boost::array的用法

这篇文章主要介绍了C++之boost::array的用法,以实例的形式简单讲述了静态数组的容器boost::array的使用技巧,具有一定的参考借鉴价值,需要的朋友可以参考下
收藏 0 赞 0 分享

C++之Boost::array用法简介

这篇文章主要介绍了C++之Boost::array用法简介,较为详细的分析了Boost::array中的常见用法,并用实例的形式予以总结归纳,需要的朋友可以参考下
收藏 0 赞 0 分享

VC文件目录常见操作实例汇总

这篇文章主要介绍了VC文件目录常见操作实例汇总,总结了VC针对文件目录的各种常用操作,非常具有实用价值,需要的朋友可以参考下
收藏 0 赞 0 分享

VC打印word,excel文本文件的方法

这篇文章主要介绍了VC打印word,excel文本文件的方法,是VC操作文本文件中非常实用的技巧,需要的朋友可以参考下
收藏 0 赞 0 分享

VC++获得当前进程运行目录的方法

这篇文章主要介绍了VC++获得当前进程运行目录的方法,可通过系统函数实现该功能,是非常实用的技巧,需要的朋友可以参考下
收藏 0 赞 0 分享

VC中SendMessage和PostMessage的区别

这篇文章主要介绍了VC中SendMessage和PostMessage的区别,较为全面的分析了SendMessage和PostMessage运行原理及用法上的不同之处,非常具有实用价值,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多