Exemplo n.º 1
0
            public async Task LoadTracks(IReadOnlyList <StorageFile> tracks)
            {
                if (tracks == null)
                {
                    return;
                }
                int i = 0;

                foreach (var track in tracks)
                {
                    i++;
                    var trackItem = await GetInformationsFromMusicFile.GetTrackItemFromFile(track, Artist, Name, i, ArtistId, Id);

                    var databaseTrack = await _trackDataRepository.LoadTrack(ArtistId, Id, trackItem.Name);

                    if (databaseTrack == null)
                    {
                        await _trackDataRepository.Add(trackItem);

                        Tracks.Add(trackItem);
                    }
                    await DispatchHelper.InvokeAsync(() =>
                    {
                        Locator.MusicLibraryVM.Track.Add(trackItem);
                        OnPropertyChanged("Track");
                    });
                }
            }
Exemplo n.º 2
0
        async Task ManageOpeningFiles(FileActivatedEventArgs args)
        {
            var         mediaServce = Container.Resolve <MediaService>();
            StorageFile file        = (StorageFile)args.Files[0];

            if (file.FileType == ".mp3" || file.FileType == ".wma")
            {
                if (Window.Current.Content == null)
                {
                    await LaunchTheApp();
                }

                Locator.MusicPlayerVM.TrackCollection.TrackCollection.Clear();
                MusicLibraryViewModel.TrackItem trackItem = await GetInformationsFromMusicFile.GetTrackItemFromFile(file);

                Locator.MusicPlayerVM.TrackCollection.TrackCollection.Add(trackItem);
                await Locator.MusicPlayerVM.PlayFromExplorer(file);
            }
            else if (file.FileType == ".mkv" ||
                     file.FileType == ".avi" ||
                     file.FileType == ".mp4" ||
                     file.FileType == ".wmv" ||
                     file.FileType == ".mov")
            {
                TemporaryFileName = file.Name;
                TemporaryMRL      = StorageApplicationPermissions.FutureAccessList.Add(file);
                if (Window.Current.Content == null)
                {
                    await LaunchTheApp();
                }
                else
                {
                    RootPage.MainFrame.Navigate(typeof(MainPage));
                    (ApplicationFrame.Content as MainPage).OpenVideoFromFileExplorer();
                }
            }
        }
Exemplo n.º 3
0
            private async Task LoadAlbums(StorageFolderQueryResult albumQueryResult, int artistId)
            {
                IReadOnlyList <StorageFolder> albumFolders = null;

                try
                {
                    albumFolders = await albumQueryResult.GetFoldersAsync();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.ToString());
                }
                if (albumFolders != null)
                {
                    foreach (var item in albumFolders)
                    {
                        AlbumItem albumItem = await GetInformationsFromMusicFile.GetAlbumItemFromFolder(item, albumQueryResult, artistId);

                        await albumItem.GetCover();

                        // Album is in database, update with cover.
                        await _albumDataRepository.Update(albumItem);

                        await DispatchHelper.InvokeAsync(() =>
                        {
                            Albums.Add(albumItem);
                            if (Locator.MusicLibraryVM.RandomAlbums.Count < 12)
                            {
                                Locator.MusicLibraryVM.RandomAlbums.Add(albumItem);
                            }
                        });

                        Locator.MusicLibraryVM.AlbumCover.Add(albumItem.Picture);
                    }
                }
            }