Пример #1
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);
        }
Пример #2
0
        public async Task LoadCassetteTape(CassetteTape ct)
        {
            CassetteTape = ct;

            foreach (StorageFile sf in await CassetteTape.MediaFiles)
            {
                var MediaPlaybackItem = new MediaPlaybackItem(MediaSource.CreateFromStorageFile(sf));
                MediaPlaybackItem.CanSkip = true;
                MediaPlaybackList.Items.Add(MediaPlaybackItem);
            }

            MediaPlayer.Source = MediaPlaybackList;
        }
Пример #3
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();
            }
        }
Пример #4
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);
            }
        }
Пример #5
0
        private async void Tape_DragDrop(object sender, DragEventArgs e)
        {
            if (cassetteTape != null)
            {
                return;
            }

            if (e.DataView.Contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.StorageItems))
            {
                var items = await e.DataView.GetStorageItemsAsync();

                if (items.Count > 0)
                {
                    walkman = new Models.Walkman();
                    walkman.Volume(DEFAULT_MEDIAPLAYER_VOLUME_LEVEL);
                    walkman.PlaySound("open");

                    StorageFolder directoryPath = (StorageFolder)items[0];

                    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();
                    }
                }
            }
        }
Пример #6
0
 public CassetteTapeState(Walkman walkman, CassetteTape cassette)
 {
     this.walkman      = walkman;
     this.cassetteTape = cassette;
     this.SavedState   = ApplicationData.Current.LocalSettings;
 }