Use C # to display the label information of MP3

xiaoxiao2021-03-06  103

// Objective: To list some of the MP3 tag information // Author: Li Yanqing 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) {// Check if the label isset = true; mp3struct.title = system.text.encoding.default.getstring (b, 3, 30); mp3struct.singer = system.text.encoding. Default.getstring (B, 33, 30); MP3Struct.Album = S YSTEM.TEXT.EESTRING.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 Additional Information:"); System.Console.writeline ("-------------------------"); system. Console.writeline ("Title:" Mp3Struct.Title); System.Console.writeline ("Singer:" Mp3Struct.singer; System.Console.writeline

转载请注明原文地址:https://www.9cbs.com/read-103635.html

New Post(0)