国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

利用C#顯示MP3的標簽信息

2024-07-21 02:19:04
字體:
來源:轉載
供稿:網友
//目的:列出mp3的一些標簽信息
//作者:李艷慶
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("參數不正確,只能跟一個參數");
}
}
}
}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 波密县| 新余市| 藁城市| 昭平县| 上饶市| 龙海市| 澄城县| 武定县| 柞水县| 彝良县| 苍溪县| 平和县| 平利县| 南宁市| 集贤县| 眉山市| 滦南县| 龙井市| 隆昌县| 雅江县| 靖州| 汨罗市| 刚察县| 合作市| 新巴尔虎右旗| 彭水| 长泰县| 临夏县| 桑日县| 嘉兴市| 化德县| 准格尔旗| 巴林右旗| 丹棱县| 宝坻区| 乡宁县| 玉环县| 信丰县| 宜丰县| 邹城市| 海阳市|