C#显示MP3的标签信息
来源:互联网 发布:朝阳教育网络视频平台 编辑:程序博客网 时间:2024/04/29 15:16
using System;
using System.IO;
namespace mp3infons
{
class MP3Info
{
struct MP3InfoStruct
{
public string MP3Flag;
public string Title;
public string Singer;
public string Album;
public string Year;
public string Comment;
}
private string MP3File;
MP3InfoStruct mp3struct;
public MP3Info(string MP3Name)
{
MP3File = MP3Name;
mp3struct = new MP3InfoStruct();
}
public bool readMP3Info()
{
bool isSet=false;
byte[] b = new byte[128];
try
{
FileStream fs = new FileStream(MP3File, FileMode.Open);
fs.Seek(-128, SeekOrigin.End);
fs.Read(b, 0, 128);
mp3struct.MP3Flag = System.Text.Encoding.Default.GetString(b, 0, 3);
if (mp3struct.MP3Flag.CompareTo("TAG")==0)
{
//检查是否设置了标签
isSet=true;
mp3struct.Title = System.Text.Encoding.Default.GetString (b,3,30);
mp3struct.Singer = System.Text.Encoding.Default.GetString (b,33,30);
mp3struct.Album = System.Text.Encoding.Default.GetString (b,63,30);
mp3struct.Year = System.Text.Encoding.Default.GetString (b,93,4);
mp3struct.Comment = System.Text.Encoding.Default.GetString (b,97,30);
}
fs.Close();
}
catch(Exception e)
{
System.Console.WriteLine(e.Message);
}
return isSet;
}
public void printMP3Info()
{
System.Console.WriteLine("MP3附加信息:");
System.Console.WriteLine("-----------------------------");
System.Console.WriteLine("标 题: " + mp3struct.Title);
System.Console.WriteLine("歌 手: " + mp3struct.Singer);
System.Console.WriteLine("唱片集: " + mp3struct.Album);
System.Console.WriteLine("出版期: " + mp3struct.Year);
System.Console.WriteLine("备 注: " + mp3struct.Comment);
}
}
public class MainMP3
{
static void Main(string[] args)
{
if (args.Length == 1)
{
MP3Info mp3 = new MP3Info(args[0]);
bool f = mp3.readMP3Info();
if (f)
{
mp3.printMP3Info();
}
else
{
System.Console.WriteLine("该MP3没有标注");
}
}
else
{
System.Console.WriteLine("参数不正确,只能跟一个参数");
}
}
}
}
using System.IO;
namespace mp3infons
{
class MP3Info
{
struct MP3InfoStruct
{
public string MP3Flag;
public string Title;
public string Singer;
public string Album;
public string Year;
public string Comment;
}
private string MP3File;
MP3InfoStruct mp3struct;
public MP3Info(string MP3Name)
{
MP3File = MP3Name;
mp3struct = new MP3InfoStruct();
}
public bool readMP3Info()
{
bool isSet=false;
byte[] b = new byte[128];
try
{
FileStream fs = new FileStream(MP3File, FileMode.Open);
fs.Seek(-128, SeekOrigin.End);
fs.Read(b, 0, 128);
mp3struct.MP3Flag = System.Text.Encoding.Default.GetString(b, 0, 3);
if (mp3struct.MP3Flag.CompareTo("TAG")==0)
{
//检查是否设置了标签
isSet=true;
mp3struct.Title = System.Text.Encoding.Default.GetString (b,3,30);
mp3struct.Singer = System.Text.Encoding.Default.GetString (b,33,30);
mp3struct.Album = System.Text.Encoding.Default.GetString (b,63,30);
mp3struct.Year = System.Text.Encoding.Default.GetString (b,93,4);
mp3struct.Comment = System.Text.Encoding.Default.GetString (b,97,30);
}
fs.Close();
}
catch(Exception e)
{
System.Console.WriteLine(e.Message);
}
return isSet;
}
public void printMP3Info()
{
System.Console.WriteLine("MP3附加信息:");
System.Console.WriteLine("-----------------------------");
System.Console.WriteLine("标 题: " + mp3struct.Title);
System.Console.WriteLine("歌 手: " + mp3struct.Singer);
System.Console.WriteLine("唱片集: " + mp3struct.Album);
System.Console.WriteLine("出版期: " + mp3struct.Year);
System.Console.WriteLine("备 注: " + mp3struct.Comment);
}
}
public class MainMP3
{
static void Main(string[] args)
{
if (args.Length == 1)
{
MP3Info mp3 = new MP3Info(args[0]);
bool f = mp3.readMP3Info();
if (f)
{
mp3.printMP3Info();
}
else
{
System.Console.WriteLine("该MP3没有标注");
}
}
else
{
System.Console.WriteLine("参数不正确,只能跟一个参数");
}
}
}
}
- 利用C#显示MP3的标签信息
- 利用C#显示MP3的标签信息
- C#显示MP3的标签信息
- C#显示MP3的标签信息
- C#获取mp3 Tag信息
- C#读mp3歌曲信息
- c# wince 读取MP3信息
- C#获取mp3 Tag信息
- C#获取文件详细备注信息,MP3的Tag等等
- C# 获取 mp3文件信息(tag信息)
- [MP3学习]MP3标签信息之ID3v1,IDv2
- [MP3学习]MP3标签信息之IDv2.3
- C# 获得MP3 TaG等信息
- C# 获取MP3/WMA音频数据信息
- 如何读取MP3的信息
- android的MP3信息获取
- java读取MP3的信息
- <s:fielderror>标签指定要显示字段的信息显示
- Lua脚本语言入门(目前魔兽使用的可以写在宏内的语言)
- C#设计模式(1)
- InfoWorld 2008年的“开源软件大奖”完整名单
- 开源ERP的红旗能扛多久
- 最近想搞明白这次的金融海啸是怎么回事,突然想到一个软件和经济体系的共性:复杂性边缘
- C#显示MP3的标签信息
- 在HTML页面中实现点击数统计
- 四种解析xml文件的方式
- 工作满一年半了
- C#设计模式(2)
- Using Graphics Filters to Extend Basic Components
- 地心游记3D 在线观看
- SOA中的数据联邦技术解密
- 熟悉java.launcher包