示例#1
0
        public async Task <List <PlaylistItem> > PopulateFromOsuDb(string filePath)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();

            OsuDb db = OsuDb.Read(filePath);

            List <PlaylistItem> Songs = new List <PlaylistItem>();

            await Task.Run(() =>
            {
                PlaylistItem currentFile;

                int currId = 1;

                string currentFileName = "";

                foreach (var item in db.Beatmaps)
                {
                    if (item.FolderName != currentFileName)
                    {
                        if (item.TotalTime >= 1000)
                        {
                            currentFile = new PlaylistItem();

                            var file = $@"{filePath.Replace("osu!.db", string.Empty)}Songs\{item.FolderName}\{item.AudioFileName}";

                            currentFile.fileLength = currentFile.setFormattedTimeSpan(TimeSpan.FromMilliseconds(item.TotalTime));

                            currentFile.Id = currId;
                            currId++;

                            currentFile.fileName = $"{item.Title}";
                            currentFileName      = item.FolderName;

                            currentFile.artist = item.Artist;

                            currentFile.filePath = file;
                            currentFile.origin   = "osu!";

                            Songs.Add(currentFile);
                        }
                    }
                }
            });

            sw.Stop();

            return(Songs);
        }