private static MP3Info StreamHandler(Stream stream) { byte[] b = new byte[128]; MP3Info mp3struct = new MP3Info(); stream.Read(b, 0, 10); string MP3Flag1 = System.Text.Encoding.GetEncoding("GBK").GetString(b, 0, 10); stream.Seek(-128, SeekOrigin.End); stream.Read(b, 0, 128); string MP3Flag = System.Text.Encoding.Default.GetString(b, 0, 3); if (MP3Flag == "TAG") { mp3struct.Title = System.Text.Encoding.GetEncoding("GBK").GetString(b, 3, 30); mp3struct.Singer = System.Text.Encoding.GetEncoding("GBK").GetString(b, 33, 30); mp3struct.Album = System.Text.Encoding.GetEncoding("GBK").GetString(b, 63, 30); mp3struct.Year = System.Text.Encoding.GetEncoding("GBK").GetString(b, 93, 4); mp3struct.Comment = System.Text.Encoding.GetEncoding("GBK").GetString(b, 97, 30); if (mp3struct.Singer.Contains("\0") || mp3struct.Album.Contains("\0")) { mp3struct = UseGbk(mp3struct, b); } } return(mp3struct); }
private void getFileInfo(Uri uri) { string path = uri.ToString(); MP3Info info = MP3Helper.ReadMP3Info(path); this.currmusic = info; }
private static MP3Info UseGbk(MP3Info input, byte[] b) { input.Title = System.Text.Encoding.GetEncoding("GBK").GetString(b, 3, 30); input.Singer = System.Text.Encoding.GetEncoding("GBK").GetString(b, 33, 30); input.Album = System.Text.Encoding.GetEncoding("GBK").GetString(b, 63, 30); input.Year = System.Text.Encoding.GetEncoding("GBK").GetString(b, 93, 4); input.Comment = System.Text.Encoding.GetEncoding("GBK").GetString(b, 97, 30); return(input); }