private List <ID3Frame> ReadId3(int stream) { IntPtr q = Bass.BASS_ChannelGetTags(stream, BASSTag.BASS_TAG_ID3V2); if ((int)q == 0) { return(null); } byte[] header = new byte[10]; Marshal.Copy(q, header, 0, 10); if (header[3] < 3 || header[3] > 4) { return(null); } bool unsync = (header[5] & 128) > 0; bool extheader = (header[5] & 64) > 0; int size = header[9] + header[8] * 128 + header[7] * 16384 + header[6] * 2097152; q += 10; if (extheader) { byte[] ehsize = new byte[4]; Marshal.Copy(q, ehsize, 0, 4); q += 4 + ehsize[3] + ehsize[2] * 256 + ehsize[1] * 65536 * ehsize[0] * 16777216; } var fr = GetFrames(q, size); return(fr); }
void SyncMetaCallback(int handle, int channel, int data, IntPtr user) { if (TagInfo.tagType == BASSTag.BASS_TAG_WMA) { string[] tags = Un4seen.Bass.Utils.IntPtrToArrayNullTermUtf8(Bass.BASS_ChannelGetTags(channel, BASSTag.BASS_TAG_WMA_META)); foreach (string tag in tags) { if (tag.StartsWith("Title=")) { TagInfo.title = tag.Replace("Title=", string.Empty); break; } } } else { // BASS_SYNC_META is triggered on meta changes of SHOUTcast streams bool isUpdated = TagInfo.UpdateFromMETA(Bass.BASS_ChannelGetTags(channel, BASSTag.BASS_TAG_META), true, TagInfo.tagType == BASSTag.BASS_TAG_META); } if (TagInfo.title.Equals(";StreamUrl='';")) { TagInfo.title = String.Empty; } //this._currentTrack.UpdateTrackFromTagInfo(tagInfo); OnMetaUpdated(TagInfo); }
public static void GetTagsFromCurrentURLStream(int stream) { TAG_INFO tagInfo = new TAG_INFO(); IntPtr tagsIntPtr = Bass.BASS_ChannelGetTags(stream, BASSTag.BASS_TAG_META); BassTags.BASS_TAG_GetFromURL(stream, tagInfo); }
private void MetaSync(int handle, int channel, int data, IntPtr user) { // BASS_SYNC_META is triggered on meta changes of SHOUTcast streams if (tagInfo.UpdateFromMETA(Bass.BASS_ChannelGetTags(channel, BASSTag.BASS_TAG_META), false, true)) { UpdatePlayList(); } }
private void MetaSync(int handle, int channel, int data, IntPtr user) { // BASS_SYNC_META is triggered on meta changes of SHOUTcast streams if (_tagInfo.UpdateFromMETA(Bass.BASS_ChannelGetTags(channel, BASSTag.BASS_TAG_META), false, true)) { this.Invoke(new UpdateTagDelegate(UpdateTagDisplay)); } }
private void MetaSync(int handle, int channel, int data, IntPtr user) { if (tagInfo != null) { if (tagInfo.UpdateFromMETA(Bass.BASS_ChannelGetTags(channel, BASSTag.BASS_TAG_META), false, false)) { getTagsFromURL(); } } }
public static int BASS_MIDI_StreamGetTrackCount(int handle) { int num = 0; while (Bass.BASS_ChannelGetTags(handle, BASSTag.BASS_TAG_MIDI_TRACK + num) != IntPtr.Zero) { num++; } Bass.BASS_GetCPU(); return(num); }
public static TAG_INFO GetMP3Tags() { TAG_INFO tagInfo = new TAG_INFO(); var tag = Bass.BASS_ChannelGetTags(_stream, BASSTag.BASS_TAG_META); if (tag != null) { BassTags.BASS_TAG_GetFromURL(_stream, tagInfo); } return(tagInfo); }
private string[] BASS_ChannelGetTagsID3V2(int handle) { IntPtr ptr = Bass.BASS_ChannelGetTags(handle, BASSTag.BASS_TAG_ID3V2); if (ptr != IntPtr.Zero) { try { List <string> list = new List <string>(); ID3V2 ID3V2Tag = new ID3V2(ptr); int num = 0; while (ID3V2Tag.k()) { string str = ID3V2Tag.m(); object obj2 = ID3V2Tag.j(); short num2 = ID3V2Tag.i(); if (string.IsNullOrEmpty(str)) {//可能会有问题 break; } if ((str.Length > 0) && (obj2 is string)) { list.Add(string.Format("{0}={1}", str, obj2)); } else if (((str == "POPM") || (str == "POP")) && (obj2 is byte)) { if (num == 0) { list.Add(string.Format("POPM={0}", obj2)); } num++; continue; } } ID3V2Tag.Dispose(); if (list.Count > 0) { return(list.ToArray()); } return(null); } catch { return(null); } } return(null); }
/// <summary> /// This Callback Procedure is called by BASS, once a song changes. /// </summary> /// <param name="handle"></param> /// <param name="channel"></param> /// <param name="data"></param> /// <param name="user"></param> private void MetaTagSyncProc(int handle, int channel, int data, IntPtr user) { new Thread(() => { Thread.CurrentThread.Name = "BASS MetaSync"; // BASS_SYNC_META is triggered on meta changes of SHOUTcast streams if (_tagInfo.UpdateFromMETA(Bass.BASS_ChannelGetTags(channel, BASSTag.BASS_TAG_META), false, false)) { GetMetaTags(); } } ).Start(); }
private static void MetaSync(int handle, int channel, int data, IntPtr user) { // BASS_SYNC_META is triggered on meta changes of SHOUTcast streams if (_tagInfo.UpdateFromMETA(Bass.BASS_ChannelGetTags(channel, BASSTag.BASS_TAG_META), false, true)) { if (track != null) { track.Album = _tagInfo.album; track.Artist = _tagInfo.artist; track.Title = _tagInfo.title; track.Genre = _tagInfo.genre; track.Bitrate = (uint)_tagInfo.bitrate; } } }
private bool GetPictureFromID3V2() { IntPtr ptr = Bass.BASS_ChannelGetTags(stream, BASSTag.BASS_TAG_ID3V2); if (ptr != IntPtr.Zero) { try { List <string> list = new List <string>(); ID3V2 ID3V2Tag = new ID3V2(ptr); while (ID3V2Tag.k()) { string str = ID3V2Tag.m(); object obj2 = ID3V2Tag.j(); short num2 = ID3V2Tag.i(); if (string.IsNullOrEmpty(str)) { break; } //读取图片 if (((str == "APIC") || (str == "PIC")) && (obj2 is byte[])) { if (bytesToImage(obj2 as byte[])) { return(true); } } } ID3V2Tag.Dispose(); } catch { return(false); } } return(false); }
private void MetaSync(int handle, int channel, int data, IntPtr user) { if (_tagInfo.UpdateFromMETA(Bass.BASS_ChannelGetTags(channel, BASSTag.BASS_TAG_META), false, true)) { tooltipText = _tagInfo.artist + "\r\n" + _tagInfo.title + "\r\n" + stationTitle; string logText = GetTimestamp(DateTime.Now) + ": " + _tagInfo.artist + " - " + _tagInfo.title + " - " + stationTitle; if (enableLogging.Checked == true) { logFile = path + "\\WinRadioTray.log"; TextWriter t = new StreamWriter(logFile, true); t.Close(); if (new FileInfo(logFile).Length == 0) { t = new StreamWriter(logFile, true); t.WriteLine(logText); t.Close(); t.Dispose(); } else { String last = File.ReadLines(@logFile).Last(); if (last == null || logText != last) { t = new StreamWriter(logFile, true); t.WriteLine(logText); t.Close(); t.Dispose(); } } } } else { tooltipText = stationTitle; } Fixes.Fixes.SetNotifyIconText(trayIcon, GetTooltipText(tooltipText)); }
/// <summary> /// Получить метаданные /// </summary> /// <returns></returns> public String DoMeta() { String RDS_1 = ""; String RDS_2 = ""; IntPtr meta = Bass.BASS_ChannelGetTags(stream, BASSTag.BASS_TAG_META); if (meta != IntPtr.Zero) { string str = Utils.IntPtrAsStringUtf8(meta); if (str.Length > 15) { RDS_2 = str.Substring(13, str.Length - 15); if (String.Compare(RDS_2, RDS_2.Length - 2, "='", 0, 2) == 0) { string str2 = RDS_2.Substring(0, RDS_2.Length - 13); RDS_2 = str2; } if (RDS_2.Length > 0 && RDS_2.Length < 64) { return(RDS_2); } else { return(RDS_1); } } else { return(RDS_1); } } else { return(RDS_1); } }
private static void metaSync(int handle, int channel, int data, IntPtr user) { user = Bass.BASS_ChannelGetTags(channel, BASSTag.BASS_TAG_META); _tags.UpdateFromMETA(user, TAGINFOEncoding.Ansi, false); Application.Current.Dispatcher.Invoke(new updateTagDelegate(updateTags)); }