Beispiel #1
0
        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());
            }
        }
Beispiel #2
0
        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());
            }
        }
Beispiel #3
0
        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());
            }
        }
Beispiel #4
0
        private static PlayList.music analyzeLine(string line, string rootPath)
        {
            PlayList.music ms = new PlayList.music();

            try
            {
                // ::が無い場合は全てをファイル名として処理終了
                if (line.IndexOf("::") < 0)
                {
                    ms.fileName = line;
                    if (!Path.IsPathRooted(ms.fileName) && rootPath != "")
                    {
                        ms.fileName = Path.Combine(rootPath, ms.fileName);
                    }

                    return(ms);
                }

                string[] buf = line.Split(new string[] { "::" }, StringSplitOptions.None);

                ms.fileName = buf[0].Trim();
                if (!Path.IsPathRooted(ms.fileName) && rootPath != "")
                {
                    ms.fileName = Path.Combine(rootPath, ms.fileName);
                }
                if (buf.Length < 1)
                {
                    return(ms);
                }

                buf = buf[1].Split(new string[] { "," }, StringSplitOptions.None);
                List <string> lbuf = new List <string>();
                for (int i = 0; i < buf.Length;)
                {
                    string s   = "";
                    bool   flg = false;
                    do
                    {
                        flg = false;
                        s  += buf[i];
                        if (buf[i].Length != 0 && buf[i].LastIndexOf('\\') == buf[i].Length - 1)
                        {
                            s  += ",";
                            flg = true;
                        }
                        i++;
                    } while (flg);
                    lbuf.Add(s.Replace("\\", ""));
                }
                buf = lbuf.ToArray();

                string fType = buf[0].Trim().ToUpper();
                if (buf.Length < 2)
                {
                    return(ms);
                }

                ms.songNo = analyzeSongNo(buf[1].Trim()) - (fType == "NSF" ? 1 : 0);
                if (buf.Length < 3)
                {
                    return(ms);
                }

                ms.title  = buf[2].Trim();
                ms.titleJ = buf[2].Trim();
                if (buf.Length < 4)
                {
                    return(ms);
                }

                ms.time = buf[3].Trim();
                if (buf.Length < 5)
                {
                    return(ms);
                }

                analyzeLoopTime(buf[4], ref ms.loopStartTime, ref ms.loopEndTime);
                if (buf.Length < 6)
                {
                    return(ms);
                }

                ms.fadeoutTime = buf[5].Trim();
                if (buf.Length < 7)
                {
                    return(ms);
                }

                if (!int.TryParse(buf[6].Trim(), out ms.loopCount))
                {
                    ms.loopCount = -1;
                }
            }
            catch (Exception ex)
            {
                log.ForcedWrite(ex);
                return(null);
            }

            return(ms);
        }
Beispiel #5
0
        private void AddFileSID(music mc, object entry = null)
        {
            try
            {
                byte[] buf = null;
                if (entry == null)
                {
                    buf = File.ReadAllBytes(mc.fileName);
                }
                else
                {
                    if (entry is ZipArchiveEntry)
                    {
                        using (BinaryReader reader = new BinaryReader(((ZipArchiveEntry)entry).Open()))
                        {
                            buf = reader.ReadBytes((int)((ZipArchiveEntry)entry).Length);
                        }
                    }
                    else
                    {
                        UnlhaWrap.UnlhaCmd cmd = new UnlhaWrap.UnlhaCmd();
                        buf = cmd.GetFileByte(((Tuple <string, string>)entry).Item1, ((Tuple <string, string>)entry).Item2);
                    }
                }

                List <PlayList.music> musics;
                if (entry == null)
                {
                    musics = Audio.getMusic(mc.fileName, buf);
                }
                else
                {
                    musics = Audio.getMusic(mc.fileName, buf, mc.arcFileName, entry);
                }

                if (mc.songNo != -1)
                {
                    PlayList.music music = null;
                    if (musics.Count > 0)
                    {
                        music        = musics[0];
                        music.songNo = mc.songNo;
                        music.title  = mc.title;
                        music.titleJ = mc.titleJ;

                        musics.Clear();
                        musics.Add(music);
                    }
                    else
                    {
                        musics.Clear();
                    }
                }

                List <DataGridViewRow> rows = makeRow(musics);
                foreach (DataGridViewRow row in rows)
                {
                    dgvList.Rows.Add(row);
                }
                foreach (PlayList.music music in musics)
                {
                    lstMusic.Add(music);
                }
            }
            catch (Exception ex)
            {
                log.ForcedWrite(ex);
            }
        }