Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }