コード例 #1
0
        async void GetMetadata()
        {
            Bar.IsIndeterminate = true;

            LocalMusicHelper localMusicHelper = new LocalMusicHelper();
            var localMusic = await localMusicHelper.GetFilesInMusicAsync();

            var failedCount = 0;

            Bar.IsIndeterminate = false;

            App.Locator.CollectionService.Songs.SuppressEvents   = true;
            App.Locator.CollectionService.Artists.SuppressEvents = true;
            App.Locator.CollectionService.Albums.SuppressEvents  = true;

            Bar.Maximum = localMusic.Count;
            App.Locator.SqlService.BeginTransaction();

            for (var i = 0; i < localMusic.Count; i++)
            {
                Bar.Value = i + 1;
                try
                {
                    await localMusicHelper.SaveTrackAsync(localMusic[i]);
                }
                catch
                {
                    failedCount++;
                }
            }
            App.Locator.SqlService.Commit();

            App.Locator.CollectionService.Songs.Reset();
            App.Locator.CollectionService.Artists.Reset();
            App.Locator.CollectionService.Albums.Reset();


            UiBlockerUtility.Unblock();
            ScreenTimeoutHelper.AllowTimeout();
            if (App.Locator.Setting.SpotifyArtworkSync)
            {
                await DownloadArtworks.DownloadArtistsArtworkAsyncFromSpotify();
            }
            else
            {
                await DownloadArtworks.DownloadArtistsArtworkAsync();
            }

            await DownloadArtworks.DownloadAlbumsArtworkAsync();

            localSettings.Values[Core.PlayerConstants.UpdateAppString] = true;

            isDone = true;
            ButtonClick(null, null);
        }
コード例 #2
0
        private async void Import()
        {
            using (var handle = Insights.TrackTime("Import Music"))
            {
                UiBlockerUtility.Block("Scanning...");
                var localMusic = await LocalMusicHelper.GetFilesInMusicAsync();

                handle.Data.Add("TotalCount", localMusic.Count.ToString());
                var failedCount = 0;

                App.Locator.CollectionService.Songs.SuppressEvents   = true;
                App.Locator.CollectionService.Artists.SuppressEvents = true;
                App.Locator.CollectionService.Albums.SuppressEvents  = true;

                App.Locator.SqlService.BeginTransaction();
                for (var i = 0; i < localMusic.Count; i++)
                {
                    StatusBarHelper.ShowStatus(
                        string.Format("Importing {0} of {1} items", i + 1, localMusic.Count),
                        (double)i / localMusic.Count);
                    try
                    {
                        await LocalMusicHelper.SaveTrackAsync(localMusic[i]);
                    }
                    catch
                    {
                        failedCount++;
                    }
                }

                App.Locator.SqlService.Commit();

                App.Locator.CollectionService.Songs.Reset();
                App.Locator.CollectionService.Artists.Reset();
                App.Locator.CollectionService.Albums.Reset();

                UiBlockerUtility.Unblock();

                if (failedCount > 0)
                {
                    CurtainPrompt.ShowError("Couldn't import {0} song(s).", failedCount);
                    handle.Data.Add("Failed", failedCount.ToString());
                }
            }

            await CollectionHelper.DownloadAlbumsArtworkAsync();

            await CollectionHelper.DownloadArtistsArtworkAsync();
        }
コード例 #3
0
        async void ImportMusic(bool importVideo = false)
        {
            ScreenTimeoutHelper.PreventTimeout();

            Bar.IsIndeterminate = true;

            Message.Text = "Collecting information about music.";

            LocalMusicHelper localMusicHelper = new LocalMusicHelper();
            var localMusic = await localMusicHelper.GetFilesInMusicAsync();

            var failedCount = 0;

            Bar.IsIndeterminate = false;

            App.Locator.CollectionService.Songs.SuppressEvents   = true;
            App.Locator.CollectionService.Artists.SuppressEvents = true;
            App.Locator.CollectionService.Albums.SuppressEvents  = true;

            await Task.Delay(10);

            Message.Text = "Working on music files.";

            Bar.Maximum = localMusic.Count;

            App.Locator.SqlService.BeginTransaction();
            for (var i = 0; i < localMusic.Count; i++)
            {
                Bar.Value = i + 1;
                try
                {
                    await localMusicHelper.SaveTrackAsync(localMusic[i]);
                }
                catch
                {
                    failedCount++;
                }
            }
            App.Locator.SqlService.Commit();

            App.Locator.CollectionService.Songs.Reset();
            App.Locator.CollectionService.Artists.Reset();
            App.Locator.CollectionService.Albums.Reset();

            if (importVideo)
            {
                if (App.Locator.Setting.SpotifyArtworkSync)
                {
                    await DownloadArtworks.DownloadArtistsArtworkAsyncFromSpotify();
                }
                else
                {
                    await DownloadArtworks.DownloadArtistsArtworkAsync();
                }
                await DownloadArtworks.DownloadAlbumsArtworkAsync();

                ImportVideos();
            }
            else
            {
                if (App.Locator.Setting.SpotifyArtworkSync)
                {
                    await DownloadArtworks.DownloadArtistsArtworkAsyncFromSpotify();
                }
                else
                {
                    await DownloadArtworks.DownloadArtistsArtworkAsync();
                } await DownloadArtworks.DownloadAlbumsArtworkAsync();

                ScreenTimeoutHelper.AllowTimeout();
                SheetUtility.CloseImportRefreshPage();
            }

            App.Locator.HomePage.SongColletionChanged();
        }