Exemplo n.º 1
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            var file   = (StorageFile)e.Parameter;
            var parent = await file.GetParentAsync();

            var list = await parent.GetFilesAsync();

            var videolist = VideoHelper.getVideosFromFolder(list, false);

            foreach (var item in videolist)
            {
                FolderVideoModel model = new FolderVideoModel()
                {
                    title             = item.DisplayName,
                    duration          = await VideoHelper.GetVideoDuration(item),
                    imageSource       = await ThumbnailHelper.getThumbnailForVideo(item),
                    subtitle          = null,
                    videoPath         = item.Path,
                    mediaPlaybackItem = new MediaPlaybackItem(MediaSource.CreateFromStorageFile(item))
                };

                videoFiles.Add(model);
                playbackList.Items.Add(model.mediaPlaybackItem);
            }
        }
Exemplo n.º 2
0
        public async static Task <ObservableCollection <FolderVideoModel> > populateGrid(IReadOnlyList <IStorageItem> files)
        {
            var watch = Stopwatch.StartNew();

            list.Clear();

            if (files.Count > 0)
            {
                var model = new FolderVideoModel();

                foreach (var item in files)
                {
                    if (item is StorageFolder)
                    {
                        var folder = (StorageFolder)item;
                        Debug.WriteLine($"{folder.DisplayName} is a folder");
                        var count = await VideoHelper.GetVideoCountFromFolder(folder);

                        var bitmap = new BitmapImage(new Uri("ms-appx:///Assets/folder-icon.png"));
                        model = new FolderVideoModel(folder.DisplayName, count.ToString(), folder.Path, bitmap, null, null);
                    }

                    else if (item is StorageFile)
                    {
                        var file = (StorageFile)item;

                        if (VideoHelper.isVideo(file))
                        {
                            var duration = await VideoHelper.GetVideoDuration(file);

                            var bitmap = await ThumbnailHelper.getThumbnailForVideo(file);

                            model = new FolderVideoModel(file.DisplayName, duration, file.Path, bitmap, null, null);
                        }
                    }


                    list.Add(model);
                    //list.Add(Task.Run(() => model));
                }

                /* var results = await Task.WhenAll(list);
                 *
                 * foreach (var item in results)
                 * {
                 *   videoFiles.Add(item);
                 * }*/
            }

            return(list);

            watch.Stop();
            var time = watch.ElapsedMilliseconds;

            Debug.WriteLine($" Time -----------  {time}");
        }
Exemplo n.º 3
0
        private async void PopulateGrid(StorageFolder folder)
        {
            if (folder != null)
            {
                var image       = new Image();
                var bitmapImage = new BitmapImage();

                files = await folder.GetFilesAsync();

                var videoList = VideoHelper.getVideosFromFolder(files, true);

                if (videoList.Count > 0)
                {
                    Debug.WriteLine("Trying to generate video thumbnail");
                    bitmapImage = await ThumbnailHelper.getThumbnailForVideo(videoList[0]);

                    image.Source = bitmapImage;
                    Debug.WriteLine("Thumbnail set");
                }
                else
                {
                    bitmapImage.UriSource = new Uri("ms-appx:///Assets/folder-icon.png");
                    image.Source          = bitmapImage;
                }

                var count = await VideoHelper.GetVideoCountFromFolder(folder);

                var model = new FolderModel()
                {
                    title = folder.DisplayName, path = folder.Path, fileCount = count, imgSource = image.Source
                };

                Debug.WriteLine(model.title + model.path + model.fileCount);
                folders.Add(model);



                Debug.WriteLine("********************");

                foreach (var path in pathTree)
                {
                    Debug.WriteLine(path);
                }
                Debug.WriteLine("********************");
            }
        }