public void GetTags() { if (Program.mainWindow == null) { return; } try { if (Program.mainWindow.supportedModuleTypes.Contains(Path.GetExtension(filename).ToLower())) { Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); int track = Bass.BASS_MusicLoad(filename, 0, 0, BASSFlag.BASS_MUSIC_NOSAMPLE | BASSFlag.BASS_MUSIC_PRESCAN, 0); title = Bass.BASS_ChannelGetMusicName(track); artist = Bass.BASS_ChannelGetMusicMessage(track); length = (int)Bass.BASS_ChannelBytes2Seconds(track, (int)Bass.BASS_ChannelGetLength(track)); Bass.BASS_Free(); } else if (Program.mainWindow.supportedMidiTypes.Contains(Path.GetExtension(filename).ToLower())) { Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); int track = BassMidi.BASS_MIDI_StreamCreateFile(filename, 0, 0, BASSFlag.BASS_DEFAULT, 0); title = Path.GetFileName(filename); length = (int)Bass.BASS_ChannelBytes2Seconds(track, (int)Bass.BASS_ChannelGetLength(track)); Bass.BASS_Free(); } else { TagLib.File tagFile = TagLib.File.Create(filename); title = tagFile.Tag.Title; if (tagFile.Tag.Performers.Length > 0) { artist = tagFile.Tag.Performers[0]; } album = tagFile.Tag.Album; //year = tagFile.Tag.Year+""; //comment = tagFile.Tag.Comment; length = (int)tagFile.Properties.Duration.TotalSeconds; bitrate = tagFile.Properties.AudioBitrate; tagFile.Dispose(); } } catch (Exception) { title = filename; length = 0; } if (String.IsNullOrWhiteSpace(title)) { title = Path.GetFileName(filename); } try { listened = Int32.Parse(Program.mainWindow.xmlCacher.GetListened(filename)); } catch (Exception) { listened = 0; } }
public string GetMusicName() { if (CurrentMusicHandle == 0) { Debug.LogError("No music loading"); return(null); } return(Bass.BASS_ChannelGetMusicName(CurrentMusicHandle)); }