Esempio n. 1
0
        private void App_UnhandledException(Object sender, UnhandledExceptionEventArgs e)
        {
            CassetteTapeState cts = new CassetteTapeState();

            cts.ClearTapeState();

            walkman.Reset();
        }
Esempio n. 2
0
 private void App_Suspending(Object sender, Windows.ApplicationModel.SuspendingEventArgs e)
 {
     if (walkman != null && cassetteTape != null)
     {
         Debug.WriteLine("Saving tape state on exit...");
         CassetteTapeState cts = new CassetteTapeState(walkman, cassetteTape);
         cts.SaveTapeState();
     }
 }
Esempio n. 3
0
        private async void OpenCassetteButton_ClickAsync(object sender, RoutedEventArgs e)
        {
            // Eject tape. Clear cassette and reset walkman state.
            if (cassetteTape != null && walkman != null)
            {
                CassetteTapeState tapeState = new CassetteTapeState();
                tapeState.ClearTapeState();

                walkman.PlaySound("eject");
                walkman.Reset();
                cassetteTapeGif.Stop();

                DisableFlyoutButtons();

                if (cassetteNameScrollTimer != null)
                {
                    cassetteNameScrollTimer.Stop();
                }

                cassetteTitleLabel.Text = string.Empty;
            }

            walkman = new Models.Walkman();
            walkman.Volume(DEFAULT_MEDIAPLAYER_VOLUME_LEVEL);
            walkman.PlaySound("open");

            FolderPicker fp = new FolderPicker
            {
                CommitButtonText       = "Load Cassette Tape",
                SuggestedStartLocation = PickerLocationId.MusicLibrary,
                ViewMode = PickerViewMode.Thumbnail
            };

            fp.FileTypeFilter.Add(".");
            StorageFolder directoryPath = await fp.PickSingleFolderAsync();

            if (directoryPath != null)
            {
                string _ = Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(directoryPath);

                cassetteTape            = new Models.CassetteTape();
                cassetteTape.DirPath    = directoryPath;
                cassetteTitleLabel.Text = cassetteTape.Title;
                await walkman.LoadCassetteTape(cassetteTape);

                // Populate Track listview:
                CassetteTrackListView.ItemsSource = await cassetteTape.Tracks();

                cassetteTrackListButton.IsEnabled = true;

                await DisplayAlbumArtAsync();

                EnableUIButtons(false);
            }

            EnableUIButtons(true);
        }
Esempio n. 4
0
        private void PauseButton_Click(object sender, RoutedEventArgs e)
        {
            if (walkman != null && cassetteNameScrollTimer != null)
            {
                walkman.ChangeLightIndicator(lightIndicator, "pause");
                walkman.Pause();
                cassetteNameScrollTimer.Stop();
                this.cassetteTapeGif.Stop();

                CassetteTapeState tapeState = new CassetteTapeState(walkman, cassetteTape);
                tapeState.SaveTapeState();
            }
        }
Esempio n. 5
0
        private void StopButton_Click(object sender, RoutedEventArgs e)
        {
            if (walkman != null && cassetteNameScrollTimer != null)
            {
                walkman.ChangeLightIndicator(lightIndicator, "stop");
                cassetteTape = null;
                walkman.Reset();
                cassetteTapeGif.Stop();
                cassetteNameScrollTimer.Stop();
                cassetteTitleLabel.Text = string.Empty;

                DisableFlyoutButtons();

                CassetteTapeState tapeState = new CassetteTapeState();
                tapeState.ClearTapeState();
            }
        }
Esempio n. 6
0
        private async void ResumeTape()
        {
            CassetteTapeState tapeState = new CassetteTapeState();

            if (tapeState.GetTapeSaved())
            {
                /*
                 * I f music directory moved, or external drive not mounted anymore reset Tape state.
                 *
                 * Also we can't run the Directory check from the UI thread:
                 */
                bool tapePathExists = await Task.Run(() => { return(Directory.Exists(tapeState.GetTapePath())); });

                if (!tapePathExists)
                {
                    tapeState.ClearTapeState();
                    return;
                }

                DisableFlyoutButtons();
                EnableUIButtons(false);

                walkman = new Models.Walkman();
                walkman.Volume(DEFAULT_MEDIAPLAYER_VOLUME_LEVEL);

                cassetteTape         = new Models.CassetteTape();
                cassetteTape.DirPath = await StorageFolder.GetFolderFromPathAsync(tapeState.GetTapePath());

                cassetteTitleLabel.Text = cassetteTape.Title;

                await walkman.LoadCassetteTape(cassetteTape);

                walkman.MediaPlaybackList.MoveTo(tapeState.GetTapeTrackIndex());

                walkman.MediaPlayer.PlaybackSession.Position = tapeState.GetTapePostion();

                CassetteTrackListView.ItemsSource = await cassetteTape.Tracks();

                cassetteTrackListButton.IsEnabled = true;

                await DisplayAlbumArtAsync();

                EnableUIButtons(true);
            }
        }