Exemple #1
0
        public async static Task <List <AudioFile> > GetTracks()
        {
            var folderMusicX = await KnownFolders.MusicLibrary.GetFolderAsync("Music X");

            List <AudioFile> audios = new List <AudioFile>();
            var files = await folderMusicX.GetFilesAsync(CommonFileQuery.OrderByName);

            foreach (var f in files)
            {
                if (f.FileType == ".mp3" || f.FileType == ".wav" || f.FileType == ".flac")
                {
                    AudioFile track;
                    track = await FindMetadataService.ConvertToAudioFile(f);

                    if (track != null)
                    {
                        audios.Add(track);
                    }
                }
            }
            return(audios);
        }
Exemple #2
0
        protected async override void OnFileActivated(FileActivatedEventArgs args)
        {
            var files = args.Files;


            var playlist = new PlaylistFile()
            {
                Artist      = "Music X",
                Cover       = "/Assets/Images/now.png",
                Id          = 1000,
                Name        = "Сейчас играет",
                TracksFiles = new List <AudioFile>()
            };

            foreach (var file in files)
            {
                var audio = await FindMetadataService.ConvertToAudioFile((StorageFile)file);

                playlist.TracksFiles.Add(audio);
            }


            StaticContent.OpenFiles  = true;
            StaticContent.OpenTracks = playlist;
            OnLaunched(null);


            //if (Window.Current.Visible)
            //{
            //    HomeLocalViewModel.Instanse.Page_Loaded(null, null);
            //}
            //else
            //{
            //    DispatcherHelper.Initialize();
            //    var rootFrame = new Frame();
            //    rootFrame.NavigationFailed += OnNavigationFailed;
            //    CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
            //    if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView"))
            //    {
            //        var appView = ApplicationView.GetForCurrentView();
            //        appView.TitleBar.ButtonBackgroundColor = Colors.Transparent;
            //        appView.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
            //    }

            //    StaticContent.LocalFolder = ApplicationData.Current.LocalFolder;
            //    if (await StaticContent.LocalFolder.TryGetItemAsync("Playlists") != null)
            //    {
            //        StaticContent.PlaylistsFolder = await StaticContent.LocalFolder.GetFolderAsync("Playlists");
            //    }

            //    if (await StaticContent.LocalFolder.TryGetItemAsync("Covers") != null)
            //    {
            //        StaticContent.CoversFolder = await StaticContent.LocalFolder.GetFolderAsync("Covers");

            //    }

            //    if (await StaticContent.LocalFolder.TryGetItemAsync("ConfigApp.json") != null)
            //    {
            //        var file = await StaticContent.LocalFolder.GetFileAsync("ConfigApp.json");
            //        var fileString = await FileIO.ReadTextAsync(file);
            //        var config = JsonConvert.DeserializeObject<ConfigApp>(fileString);
            //        StaticContent.Config = config;
            //    }

            //    Window.Current.Content = rootFrame;

            //    if (await StaticContent.LocalFolder.TryGetItemAsync("RunApp.json") == null)
            //    {
            //        var runFile = await StaticContent.LocalFolder.CreateFileAsync("RunApp.json");
            //        var model = new RunApp()
            //        {
            //            CodeName = "Test",
            //            FirstStart = true,
            //            RunUpdate = true
            //        };

            //        var json = JsonConvert.SerializeObject(model);
            //        await FileIO.WriteTextAsync(runFile, json);

            //        rootFrame.Navigate(typeof(Views.WelcomeView), null);
            //    }
            //    else
            //    {
            //        rootFrame.Navigate(typeof(Views.ProVersionView), null);
            //    }

            //    Window.Current.Activate();
            //    SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
            //}
        }