示例#1
0
        internal async void SetUpVM(IMediaPlayerElementController musicPlayerView)
        {
            ShowLoadingPanel(LoadingPanelText);

            try
            {
                MusicPlayerController = musicPlayerView;
                MusicPlayerController.ClearPlaylist();

                MediaFileCollection.Clear();

                // Set index to -1 to indicate no selection
                SelectedMediaIndex = -1;

                var filesLoaded = await GetMediaFiles();

                if (filesLoaded && MediaFileCollection.Count > 0)
                {
                    MusicPlayerVisibility = true;
                    SelectedMediaIndex    = 0;
                    UpdateMusicPlayer();
                }
                else
                {
                    MusicPlayerVisibility = false;
                }
            }
            catch (Exception ex)
            {
                LogService.Write(ex.Message, LoggingLevel.Error);
            }

            HideLoadingPanel();
        }
        internal async void SetUpVM(IMediaPlayerElementController musicPlayerView)
        {
            bool reload = true;

            while (reload)
            {
                reload = false;
                MusicPlayerVisibility = false;
                ShowLoadingPanel(LoadingPanelText);

                try
                {
                    MusicPlayerController = musicPlayerView;
                    MusicPlayerController.ClearPlaylist();

                    MediaFileCollection.Clear();

                    // Set index to -1 to indicate no selection
                    SelectedMediaIndex = -1;

                    var filesLoaded = await GetMediaFiles();

                    if (filesLoaded && MediaFileCollection.Count > 0)
                    {
                        MusicPlayerVisibility = true;
                        SelectedMediaIndex    = 0;
                        UpdateMusicPlayer();
                    }
                    else
                    {
                        // Alert the user if no media files found and wait for input to reload the page or close the prompt
                        reload = await AppService.YesNoAsync(NoMusicFoundText, InstructionsText, ReloadButtonText, CloseButtonText);
                    }
                }
                catch (Exception ex)
                {
                    LogService.Write(ex.Message, LoggingLevel.Error);
                }

                HideLoadingPanel();
            }
        }