Ejemplo n.º 1
0
        private async void AddContentButton_Click(object sender, RoutedEventArgs e)
        {
            var picker = new Windows.Storage.Pickers.FileOpenPicker();

            picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
            picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
            picker.FileTypeFilter.Add(".jpg");
            picker.FileTypeFilter.Add(".jpeg");
            picker.FileTypeFilter.Add(".png");
            picker.FileTypeFilter.Add(".mp4");
            picker.FileTypeFilter.Add(".mp3");
            //picker.FileTypeFilter.Add(".txt");

            StorageFile file = await picker.PickSingleFileAsync();

            if (file != null)
            {
                StorageItemThumbnail thumbnail = await file.GetThumbnailAsync(ThumbnailMode.VideosView, 100);

                BasicProperties basicProperties = await file.GetBasicPropertiesAsync();

                // if (!_storageFiles.Contains(file)) // Bug occurs (playing a wrong file), investigate ?

                SWatchFile swatchFile = new SWatchFile()
                {
                    Name                 = file.Name.Remove(file.Name.Length - 4),
                    Path                 = file.Path,
                    Size                 = basicProperties.Size,
                    Thumbnail            = thumbnail,
                    ThumbnailBitmapImage = await StorageItemThumbnailToBitmapImage(thumbnail),
                    DateCreated          = file.DateCreated.Date,
                    DateModified         = basicProperties.DateModified.Date,
                    Type                 = SWatchFile.GetFileTypeFromFileContentType(file.ContentType),
                };

                swatchFile.StorageFile = file;

                //if (!Files.Contains(swatchFile)) // Bug occurs (playing a wrong file), investigate ?
                Files.Add(swatchFile);
                MainContentList.SelectedItem = Files[Files.Count - 1]; // Select last added file
            }
            else
            {
                Console.WriteLine("[ERROR] Error when adding a file to GUI");
                UpdateStatusBar("Error while adding content");
            }
            UpdateStatusBar("Content was successfully added");
        }
Ejemplo n.º 2
0
        private void MainContentList_ItemClick(object sender, ItemClickEventArgs e)
        {
            GridView gridView = sender as GridView;

            if (gridView == null || gridView.SelectedIndex == -1)
            {
                return;
            }

            SWatchFile selectedFile = gridView?.SelectedItem as SWatchFile;
            SWatchFile clickedFile  = e.ClickedItem as SWatchFile;

            if (!selectedFile.Equals(clickedFile))
            {
                return; // When selection changes do not immediately navigate to player
            }
            IStorageFile storageFile = clickedFile.StorageFile;

            this.Frame.Navigate(typeof(PlayerPage), new object[] { storageFile, clickedFile }, new ContinuumNavigationTransitionInfo());
        }
Ejemplo n.º 3
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.Parameter == null && MediaPlayer.MediaPlayer.Source != null)
            {
                MediaPlayer.MediaPlayer.Play(); // Page is already cached, just continue playing
            }
            else
            {
                try
                {
                    StorageFile storageFile = ((object[])e.Parameter)?[0] as StorageFile;
                    SWatchFile  sWatchFile  = ((object[])e.Parameter)?[1] as SWatchFile;
                    MediaPlayer.Source = MediaSource.CreateFromStorageFile(storageFile);

                    // TODO: Choose approriate PosterSource
                    if (sWatchFile.Type == FileType.Audio)
                    {
                        MediaPlayer.PosterSource = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/mickey_playing.gif"));
                    }
                    else
                    {
                        MediaPlayer.PosterSource = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/loading.gif"));
                    }

                    //MediaPlayer.PosterSource = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/loading.gif"));
                    //MediaPlayer.PosterSource = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/rainbow-loading.gif"));
                    //MediaPlayer.PosterSource = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/loading gear icon.gif"));
                    //MediaPlayer.PosterSource = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/music_icon.png"));

                    MediaPlayer.MediaPlayer.Play();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("[ERROR] Error when setting media source\n" + ex.Message);
                }
            }
        }