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

本文实例讲述了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++程序设计有所帮助。

(0)

相关推荐

  • Asp.Net 音频文件上传和播放代码

    一.音频文件上传和播放 在网上找到一个名叫AspNetPager的第三方控件,将AspNetPager.dll文件引用到项目的Bin中.在网页中可直接调用.引用命名空间 using Telerik.WebControls; >>上传 复制代码 代码如下: protected void Button1_Click(object sender, EventArgs e) { foreach (UploadedFile file in RadUploadContext.Current.Uploade

  • python实现定时播放mp3

    程序很简单,主要是 mp3play 模块的应用 import mp3play, time filename = "Should It Matter.mp3" clip = mp3play.load(filename) while 1: if time.localtime().tm_min % 30 == 0: clip.play() print "\nStart to play" time.sleep(clip.seconds()) clip.stop() prin

  • java实现mp3合并的方法

    本文实例讲述了java实现mp3合并的方法.分享给大家供大家参考.具体实现方法如下: 复制代码 代码如下: package test; import java.io.*; import java.util.*; public class Test6 {     public static void main(String[] args) throws Exception     {         String s = "D:/out.mp3"; // 输出目录 & 文件名  

  • python使用urllib模块开发的多线程豆瓣小站mp3下载器

    复制代码 代码如下: #! /usr/bin/python2.7# -- coding:utf-8 -- import os, urllib,urllib2, thread,threadingimport re #匹配音乐urlreg=re.compile('{"name":"(.+?)".+?"rawUrl":"(.+?)",.+?}', re.I) class downloader(threading.Thread):  

  • Python读取mp3中ID3信息的方法

    本文实例讲述了Python读取mp3中ID3信息的方法.分享给大家供大家参考.具体分析如下: pyid3不好用,常常有不认识的. mutagen不错,不过默认带的easyid3不会读取注释,需要手工hack一下 Python代码如下: from mutagen.mp3 import MP3 import mutagen.id3 from mutagen.easyid3 import EasyID3 EasyID3.valid_keys["comment"]="COMM::'X

  • C#实现简单播放mp3的方法

    本文实例讲述了C#实现简单播放mp3的方法.分享给大家供大家参考.具体实现方法如下: /// <summary> /// 测试 /// </summary> class TestDemo { public void Test() { clsMCI cm = new clsMCI(); cm.FileName = "alarm.mp3"; cm.play(); } } /// <summary> /// clsMci 的摘要说明. /// </s

  • C#定义的MP3播放类实例

    本文实例讲述了C#定义的MP3播放类.分享给大家供大家参考.具体分析如下: 这里使用C#定义一个MP3播放类,将Mp3文件作为资源文件包含到项目中,就可以播放mp3了 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using System.Runtime.InteropService

  • asp.net音频转换之.amr转.mp3(利用七牛转换法)

    前言 相信大家应该都知道吧,.amr格式用于移动设备的音频,压缩比比较大,多用于人声.通话,效果还行!所以,移动设备多采用amr格式来进行录存!比较常见的例子:通话录音,微信语音以及录音等! 但是这个鬼,用两个字来形容,就是"蛋疼":因为HTML5压根就不支持它(amr:我是个<孤儿> ,导演:佐米·希尔拉):所以,试听效果也就很难实现了!虽然微信是提供试听的,但一旦离开了页面,那就意味着,你再也无法播放你的录音了! 所以你不得不将文件转换下格式! 目前,小编掌握的转换格式

  • java实现酷狗音乐临时缓存文件转换为MP3文件的方法

    本文实例讲述了java实现酷狗音乐临时缓存文件转换为MP3文件的方法.分享给大家供大家参考,具体如下: 酷狗临时缓存文件,其实已经是吧MP3文件下载好了,只是名字看上去好像是通过md5算法重命名的. 酷狗在缓存文件的时候会同时缓存歌词.这个程序就是根据md5管理对应的歌词文件和缓存文件,然后把缓存文件改成 歌曲名+.mp3格式. 原谅我取这么长也不知道对不对的类名. package com.zhou.run; import java.io.File; import java.util.HashM

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

    本文实例讲述了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

  • python获取mp3文件信息的方法

    本文实例讲述了python获取mp3文件信息的方法.分享给大家供大家参考.具体如下: 将代码生成.py文件放在目录下运行,可以获取该目录的所有mp3文件的信息,需要使用ID3库 import os, sys from ID3 import * files = os.listdir(os.getcwd()) for f in files: x = os.path.splitext(f) if x[1] == '.mp3': n = x[0].split(' - ') author = n[0] t

  • JS实现隐藏同级元素后只显示JS文件内容的方法

    本文实例讲述了JS实现隐藏同级元素后只显示JS文件内容的方法.分享给大家供大家参考,具体如下: 这里的demo.html文件在打开后会短暂显示与js文件同级的元素后马上隐藏这些元素,并显示同级的demo.js文件内容.具体代码如下: demo.html: <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <title><

  • C#实现获取mp3 Tag信息的方法

    本文实例讲述了C#实现获取mp3 Tag信息的方法.分享给大家供大家参考,具体如下: using System; using System.Collections.Generic; using System.Text; using System.IO; namespace Foxer_Player_1._1 { public struct Mp3Info { public string identify; //TAG,三个字节 public string Title; //歌曲名,30个字节 p

  • Python3读取zip文件信息的方法

    本文实例讲述了Python3读取zip文件信息的方法.分享给大家供大家参考.具体实现方法如下: 该程序接受一个字符串,其内容是一个zip文件,需要读取这个zip文件中的信息 import zipfile class zip_string(zipfile.ZipFile): def __init__(self, data_string): zipfile.ZipFile.__init__(self, data_string) zstr = zip_string('d:/中华十大名帖.zip') f

  • Python实现给文件添加内容及得到文件信息的方法

    本文实例讲述了Python实现给文件添加内容及得到文件信息的方法.分享给大家供大家参考.具体分析如下: 经常会遇到给文件添加内容的时候,如果只是添加在文件的末尾,就比较简单了: file = open(filename,'a') file.write('hello') file.close() 使用'a'模式打开文件后,指针默认指向文件末尾,即使你: file.seek(0) file.write('world') 字符串'world'还是会加在文件的末尾,而不会是你想要的开始位置. 而我遇到的

  • Python编程修改MP3文件名称的方法

    本文实例讲述了Python编程修改MP3文件名称的方法.分享给大家供大家参考,具体如下: 最近刚刚开始学习Python,顺便锻炼思维写的一个小函数,专门用来修改那些网上下载的mp3歌曲后名称不正确时候,使用该函数,使用方法 ModifyMp3FileInfo(r'E:/音乐/12345.mp3') Python代码: #!修改下载的Mp3文件名称为正确的Mp3文件 def ModifyMp3FileInfo(filename): mp3Id3V1 = { "tag":{"va

  • JSP实现简单的用户登录并显示出用户信息的方法

    本文实例讲述了JSP实现简单的用户登录并显示出用户信息的方法.分享给大家供大家参考.具体实现方法如下: login.jsp 复制代码 代码如下: <%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>  <%  String path = request.getContextPath();  String basePath = request.

  • Python写入数据到MP3文件中的方法

    本文实例讲述了Python写入数据到MP3文件中的方法.分享给大家供大家参考.具体分析如下: 通过Mp3的Id3V1数据段的数据来修正Mp3文件的正确名字,但是,有时候这个数据断中的数据是空的,所以这里写一个修改Id3V1数据段的数据的函数,同样是练习. 使用方法: writeMp3Header[ SongName] = '测试歌曲名称' writeMp3Header[ SongPeople] = '不得闲' writeMp3Header[ ZhuanJi] = '专辑' writeMp3Hea

  • php获取文件类型和文件信息的方法

    本文实例讲述了php获取文件类型和文件信息的方法.分享给大家供大家参考.具体实现方法如下: <?php $file = "php.txt"; //打开文件,r表示以只读方式打开 $handle = fopen($file,"r"); //获取文件的统计信息 $fstat = fstat($handle); echo "文件名:".basename($file)."<br>"; //echo "文件大

随机推荐