Example #1
0
        public async Task AddFiles(EventHandler <TrackImportProgressChangedEventArgs> progresschanged, IEnumerable <string> paths)
        {
            var index     = 0;
            var filePaths = paths as IList <string> ?? paths.ToList();
            var count     = filePaths.Count();

            foreach (var fi in filePaths.Select(path => new FileInfo(path)))
            {
                if (fi.Exists)
                {
                    try
                    {
                        progresschanged?.Invoke(this, new TrackImportProgressChangedEventArgs(index, count, fi.Name));
                        var t = new LocalTrack {
                            Path = fi.FullName
                        };
                        if (!await t.LoadInformation())
                        {
                            continue;
                        }
                        t.TimeAdded = DateTime.Now;
                        t.IsChecked = false;
                        AddTrack(t);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                ++index;
            }
            AsyncTrackLoader.Instance.RunAsync(this);
        }
Example #2
0
        public async Task AddFiles(EventHandler <TrackImportProgressChangedEventArgs> progresschanged, IEnumerable <string> paths)
        {
            int index = 0;
            var count = paths.Count();

            foreach (FileInfo fi in paths.Select(path => new FileInfo(path)))
            {
                if (fi.Exists)
                {
                    if (progresschanged != null)
                    {
                        progresschanged(this, new TrackImportProgressChangedEventArgs(index, count, fi.Name));
                    }
                    var t = new LocalTrack()
                    {
                        Path = fi.FullName
                    };
                    if (!await t.LoadInformation())
                    {
                        continue;
                    }
                    t.TimeAdded = DateTime.Now;
                    AddTrack(t);
                }
                ++index;
            }
            AsyncTrackLoader.Instance.RunAsync(new List <NormalPlaylist> {
                this
            });
        }