示例#1
0
        public static PlayList LoadM3U(string filename)
        {
            try
            {
                PlayList pl = new PlayList();

                using (StreamReader sr = new StreamReader(filename, Encoding.GetEncoding(932)))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        line = line.Trim();
                        if (line == "")
                        {
                            continue;
                        }
                        if (line[0] == '#')
                        {
                            continue;
                        }

                        if (!Path.IsPathRooted(line))
                        {
                            line = Path.Combine(Path.GetDirectoryName(filename), line);
                        }
                        music ms = new music();
                        ms.fileName = line;
                        pl.lstMusic.Add(ms);
                    }
                }


                return(pl);
            }
            catch (Exception ex)
            {
                log.ForcedWrite(ex);
                return(new PlayList());
            }
        }
示例#2
0
文件: M3U.cs 项目: hiroshica/MDPlayer
        private static PlayList LoadM3U(ZipArchiveEntry entry, string zipFileName)
        {
            try
            {
                PlayList pl = new PlayList();

                using (StreamReader sr = new StreamReader(entry.Open(), Encoding.GetEncoding(932)))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        line = line.Trim();
                        if (line == "")
                        {
                            continue;
                        }
                        if (line[0] == '#')
                        {
                            continue;
                        }

                        PlayList.music ms = analyzeLine(line, "");
                        ms.format      = common.CheckExt(ms.fileName);
                        ms.arcFileName = zipFileName;
                        if (ms != null)
                        {
                            pl.lstMusic.Add(ms);
                        }
                    }
                }

                return(pl);
            }
            catch (Exception ex)
            {
                log.ForcedWrite(ex);
                return(new PlayList());
            }
        }
示例#3
0
文件: M3U.cs 项目: hiroshica/MDPlayer
        public static PlayList LoadM3U(string filename, string rootPath)
        {
            try
            {
                PlayList pl = new PlayList();

                using (StreamReader sr = new StreamReader(filename, Encoding.GetEncoding(932)))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        line = line.Trim();
                        if (line == "")
                        {
                            continue;
                        }
                        if (line[0] == '#')
                        {
                            continue;
                        }

                        PlayList.music ms = analyzeLine(line, rootPath);
                        ms.format = common.CheckExt(ms.fileName);
                        if (ms != null)
                        {
                            pl.lstMusic.Add(ms);
                        }
                    }
                }

                return(pl);
            }
            catch (Exception ex)
            {
                log.ForcedWrite(ex);
                return(new PlayList());
            }
        }
示例#4
0
文件: M3U.cs 项目: hiroshica/MDPlayer
        private static PlayList LoadM3U(string archiveFile, string fileName, string zipFileName)
        {
            try
            {
                PlayList           pl   = new PlayList();
                UnlhaWrap.UnlhaCmd cmd  = new UnlhaWrap.UnlhaCmd();
                byte[]             buf  = cmd.GetFileByte(archiveFile, fileName);
                string[]           text = Encoding.GetEncoding(932).GetString(buf).Split(new string[] { "\r\n" }, StringSplitOptions.None);

                foreach (string txt in text)
                {
                    string line = txt.Trim();
                    if (line == "")
                    {
                        continue;
                    }
                    if (line[0] == '#')
                    {
                        continue;
                    }

                    PlayList.music ms = analyzeLine(line, "");
                    ms.format      = common.CheckExt(ms.fileName);
                    ms.arcFileName = zipFileName;
                    if (ms != null)
                    {
                        pl.lstMusic.Add(ms);
                    }
                }

                return(pl);
            }
            catch (Exception ex)
            {
                log.ForcedWrite(ex);
                return(new PlayList());
            }
        }
示例#5
0
        private void AddFileLZH(music mc, object entry = null)
        {
            if (entry != null)
            {
                return;
            }

            UnlhaWrap.UnlhaCmd             cmd = new UnlhaWrap.UnlhaCmd();
            List <Tuple <string, UInt64> > res = cmd.GetFileList(mc.fileName, "*.*");

            mc.arcFileName = mc.fileName;
            mc.arcType     = EnmArcType.LZH;
            List <string> zipMember = new List <string>();
            List <music>  mMember   = new List <music>();

            foreach (Tuple <string, UInt64> ent in res)
            {
                if (Common.CheckExt(ent.Item1) != EnmFileFormat.M3U)
                {
                    zipMember.Add(ent.Item1);
                }
                else
                {
                    PlayList pl = M3U.LoadM3U(ent, mc.arcFileName);
                    foreach (music m in pl.lstMusic)
                    {
                        mMember.Add(m);
                    }
                }
            }

            foreach (string zm in zipMember)
            {
                bool found = false;
                foreach (music m in mMember)
                {
                    if (m.fileName == zm)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found && Common.CheckExt(zm) == EnmFileFormat.VGM)
                {
                    string vzm = "";
                    if (Path.GetExtension(zm).ToLower() == ".vgm")
                    {
                        vzm = Path.ChangeExtension(zm, ".vgz");
                    }
                    else
                    {
                        vzm = Path.ChangeExtension(zm, ".vgm");
                    }
                    foreach (music m in mMember)
                    {
                        if (m.fileName == vzm)
                        {
                            found = true;
                            break;
                        }
                    }
                }
                if (!found)
                {
                    music zmc = new music();
                    zmc.fileName    = zm;
                    zmc.arcFileName = mc.arcFileName;
                    zmc.arcType     = mc.arcType;
                    mMember.Add(zmc);
                }
            }

            foreach (Tuple <string, UInt64> ent in res)
            {
                foreach (music m in mMember)
                {
                    string vzm = "";
                    if (Path.GetExtension(m.fileName).ToLower() == ".vgm")
                    {
                        vzm = Path.ChangeExtension(m.fileName, ".vgz");
                    }
                    else if (Path.GetExtension(m.fileName).ToLower() == ".vgz")
                    {
                        vzm = Path.ChangeExtension(m.fileName, ".vgm");
                    }

                    if (ent.Item1 == m.fileName || ent.Item1 == vzm)
                    {
                        m.format      = Common.CheckExt(m.fileName);
                        m.arcFileName = mc.arcFileName;
                        m.arcType     = mc.arcType;
                        AddFileLoop(m, new Tuple <string, string>(m.arcFileName, ent.Item1));
                    }
                }
            }
        }
示例#6
0
        private void AddFileZIP(music mc, object entry = null)
        {
            if (entry != null)
            {
                return;
            }

            using (ZipArchive archive = ZipFile.OpenRead(mc.fileName))
            {
                mc.arcFileName = mc.fileName;
                mc.arcType     = EnmArcType.ZIP;
                List <string> zipMember = new List <string>();
                List <music>  mMember   = new List <music>();
                foreach (ZipArchiveEntry ent in archive.Entries)
                {
                    if (Common.CheckExt(ent.FullName) != EnmFileFormat.M3U)
                    {
                        zipMember.Add(ent.FullName);
                    }
                    else
                    {
                        PlayList pl = M3U.LoadM3U(ent, mc.arcFileName);
                        foreach (music m in pl.lstMusic)
                        {
                            mMember.Add(m);
                        }
                    }
                }

                foreach (string zm in zipMember)
                {
                    bool found = false;
                    foreach (music m in mMember)
                    {
                        if (m.fileName == zm)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found && Common.CheckExt(zm) == EnmFileFormat.VGM)
                    {
                        string vzm = "";
                        if (Path.GetExtension(zm).ToLower() == ".vgm")
                        {
                            vzm = Path.ChangeExtension(zm, ".vgz");
                        }
                        else
                        {
                            vzm = Path.ChangeExtension(zm, ".vgm");
                        }
                        foreach (music m in mMember)
                        {
                            if (m.fileName == vzm)
                            {
                                found = true;
                                break;
                            }
                        }
                    }
                    if (!found)
                    {
                        music zmc = new music();
                        zmc.fileName    = zm;
                        zmc.arcFileName = mc.arcFileName;
                        zmc.arcType     = mc.arcType;
                        mMember.Add(zmc);
                    }
                }

                foreach (ZipArchiveEntry ent in archive.Entries)
                {
                    foreach (music m in mMember)
                    {
                        string vzm = "";
                        if (Path.GetExtension(m.fileName).ToLower() == ".vgm")
                        {
                            vzm = Path.ChangeExtension(m.fileName, ".vgz");
                        }
                        else if (Path.GetExtension(m.fileName).ToLower() == ".vgz")
                        {
                            vzm = Path.ChangeExtension(m.fileName, ".vgm");
                        }

                        if (ent.FullName == m.fileName || ent.FullName == vzm)
                        {
                            m.format      = Common.CheckExt(m.fileName);
                            m.arcFileName = mc.arcFileName;
                            m.arcType     = mc.arcType;
                            AddFileLoop(m, ent);
                        }
                    }
                }
            }
        }
示例#7
0
        public PlayList Copy()
        {
            PlayList playList = new PlayList();

            return(playList);
        }