private async void LoadSongs(string collectId) { try { pr_Load.Visibility = Visibility.Visible; string url = "https://api.bilibili.com/audio/music-service-c/collections/{0}/songs?access_key={1}&appkey={2}&build=5250000&collection_id={0}&mid={3}&mobi_app=android&page_index=1&page_size=500&platform=android&sort=1&ts={4}"; url = string.Format(url, collectId, ApiHelper.access_key, ApiHelper.AndroidKey.Appkey, ApiHelper.GetUserId(), ApiHelper.GetTimeSpan); url += "&sign=" + ApiHelper.GetSign(url); var results = await WebClientClass.GetResults(new Uri(url)); SongInfoModel m = JsonConvert.DeserializeObject <SongInfoModel>(results); if (m.code == 0) { list_songs.ItemsSource = m.data.list; } else { Utils.ShowMessageToast(m.msg); } } catch (Exception) { Utils.ShowMessageToast("加载收藏夹失败"); } finally { pr_Load.Visibility = Visibility.Collapsed; } }
/// <summary> /// All actions needed for deleting a song /// </summary> /// <param name="path"></param> /// <returns></returns> private async Task DeleteFromPlaylist(SongInfoModel song) { bool deleteResponse = await DisplayAlert("Delete song from playlist", "Are you sure you want to delete this song from your playlist?", "Delete", "Cancel"); if (deleteResponse) { database.RemoveSongFromPlayList(song); } }
/// <summary> /// Force Select a song /// </summary> /// <param name="song"></param> /// <param name="standardQueue"></param> public static async void SelectSong(SongInfoModel song, List <SongInfoModel> standardQueue) { //Get the queue MainPage mainPage = (MainPage)App.Current.MainPage; var queue = mainPage.QueueService; queue.ForcePlayItem(song, standardQueue); await Constants.MediaPlayer.Play(song.Path); }
public void ForcePlayItem(SongInfoModel song, List <SongInfoModel> queue) { if (_queue._CustomSelectedSong >= 0) { _queue._CustomQueue[_queue._CustomSelectedSong] = song; } else { _queue._StandardQueue = queue; _queue._StandardSelectedSong = queue.IndexOf(song); } }
private void QueueItemRemove_Clicked(object sender, EventArgs e) { SongInfoModel songInfo = (SongInfoModel)((ImageButton)sender).CommandParameter; var songIndex = _queueService._queue._CustomQueue.IndexOf(songInfo); _queueService.RemoveCustomQueueItem(songInfo); InitQueue(); if (songIndex == _queueService._queue._CustomSelectedSong) { var newSong = _queueService.GetQueueItem(); _mediaPlayerService.Play(newSong.Path); } }
/// <summary> /// Event for options of a song /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void PlaylistItemOption_Clicked(object sender, EventArgs e) { SongInfoModel songInfo = (SongInfoModel)((ImageButton)sender).CommandParameter; var response = await DisplayActionSheet("Song Options", "Cancel", null, "Delete file", "Add To Queue"); if (response.ToLower() == "delete file") { await DeleteFromPlaylist(songInfo); } else if (response.ToLower() == "add to queue") { } GetSongsFromPlayList(); }
/// <summary> /// Write the given level/difficulty out to file /// </summary> /// <param name="level">Beat Saber level data</param> /// <param name="difficulty">Difficulty of song</param> public static async void WriteToOutputFile(IBeatmapLevel level, IDifficultyBeatmap difficultyBeatmap) { // get song cover sprite var sprite = await level.GetCoverImageAsync(System.Threading.CancellationToken.None); // get the texture from the sprite var tex = sprite.texture; // resize to thumbnail size tex = tex.ResizeTexture(Plugin.cfg.ThumbnailSize, Plugin.cfg.ThumbnailSize); // encode to base64 var base64Image = $"data:image/jpg;base64,{Convert.ToBase64String(tex.EncodeToJPG())}"; // build song info model var songInfo = new SongInfoModel { SongName = level.songName, SongSubName = level.songSubName, SongAuthorName = level.songAuthorName, LevelAuthorName = level.levelAuthorName, Difficulty = difficultyBeatmap.difficulty, Base64Thumbnail = base64Image, SongBPM = level.beatsPerMinute, NoteJumpSpeed = difficultyBeatmap.noteJumpMovementSpeed, NotesCount = difficultyBeatmap.beatmapData.numberOfLines, BombsCount = difficultyBeatmap.beatmapData.bombsCount, ObstaclesCount = difficultyBeatmap.beatmapData.obstaclesCount }; // check if we are using a template file if (string.IsNullOrEmpty(Plugin.cfg.SongTemplate)) { // write out song information using SongFormat template WriteToOutputFile(DynamicText.Parse(Plugin.cfg.SongFormat, songInfo)); } else { // build template full path var templatePath = Path.Combine(Plugin.DataPath, Plugin.cfg.SongTemplate); // read template file var songFormat = File.ReadAllText(templatePath); // write out song information using template file WriteToOutputFile(DynamicText.Parse(songFormat, songInfo)); } }
public void RemoveSongFromPlayList(SongInfoModel playlist) { _connection.Delete(playlist); }
public void AddSongToPlayList(SongInfoModel playlist) { _connection.Insert(playlist); }
public void RemoveCustomQueueItem(SongInfoModel song) { _queue._CustomQueue.Remove(song); }
public void StoreQueueItem(SongInfoModel song) { _queue._CustomQueue.Add(song); }