private async Task saveRichPresenceInfo() { //var storageFolder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync(@"Assets"); //var f = new StorageFolder(new Uri("ms - appx:///Assets/discordrpc")); //Windows.Storage.ApplicationData.Current. //KnownFolders.MusicLibrary.CreateFileAsync var localfolder = Windows.Storage.ApplicationData.Current.LocalFolder; var file = await localfolder.CreateFileAsync("RichPresenceInfo.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting); while (true) { await Task.Delay(500); //var musicLibrary = await StorageLibrary.GetLibraryAsync(KnownLibraryId.Music); //musicLibrary. //Debug.WriteLine(musicLibrary.SaveFolder.Path); //var file = await KnownFolders.MusicLibrary.CreateFileAsync("RichPresenceInfo.txt", Windows.Storage.CreationCollisionOption.ReplaceExisting); long timeleft = 0; var song = SongListStorage.GetCurrentSong(); if (song != null) { timeleft = song.Duration.Subtract(mediaPlayer.PlaybackSession.Position).Ticks; } await FileIO.WriteTextAsync(file, currentartist + "\n" + currenttitle + "\n" + timeleft + "\n" + DateTime.UtcNow.Ticks + "\n" + mediaPlayer.PlaybackSession.PlaybackState); Debug.WriteLine("Hopefully wrote to file at " + DateTime.Now.ToString()); } }
private void PlaybackSession_PositionChanged(MediaPlaybackSession sender, object args) { var totalticks = SongListStorage.GetCurrentSong().Duration.TotalSeconds * 4; if (++Listeneventcount > totalticks / 2 && !SongListenInDB) { AddListenToDB(SongListStorage.GetCurrentSong().ID); SongListenInDB = true; } SongListStorage.SaveDBInfo(Listeneventcount, SongListenInDB); }
private void CurrentArtistsTextBlock_Tapped(object sender, TappedRoutedEventArgs e) { var songfile = SongListStorage.GetCurrentSong(); //Navigates to the artist if it exists, otherwise the albumartist. if (SongListStorage.ArtistDict.ContainsKey(songfile.ArtistKey)) { ContentFrame.Navigate(typeof(ArtistPage), songfile.ArtistKey); } else { if (SongListStorage.ArtistDict.ContainsKey(songfile.AlbumArtist)) { ContentFrame.Navigate(typeof(ArtistPage), songfile.AlbumArtist); } } }
private void AlbumArtImage_Tapped(object sender, TappedRoutedEventArgs e) { var songfile = SongListStorage.GetCurrentSong(); ContentFrame.Navigate(typeof(AlbumPage), songfile.AlbumKey); }