/// <summary> /// Tells the music player to play the song with the specific id /// </summary> /// <param name="id">Id of the song to play</param> /// <returns></returns> public async Task PlayID(string id) { Song song = SongList.First(x => x.id == id); if (song?.path == null) { throw new ApiError("Song has no path"); } await PlayFile(song.path); }
/// <summary> /// Removes and returns the first song in the playlist /// </summary> /// <returns>The first song in the playlist, or null if there are no new songs</returns> public Song PopNextSong() { if (SongList.Count() <= 0) { return(null); } else { Song popped = SongList.First(); SongList.RemoveAt(0); return(popped); } }
/// <summary> /// Tells the music player to play the song with the specific id /// </summary> /// <param name="id">Id of the song to play</param> /// <returns></returns> public async Task PlayID(string id) { Song song = SongList.First(x => x.id == id); if (song?.path == null) { throw new ApiError("Song has no path"); } await PlayFile(song.path); if (Cooldowns.TryGetValue(id, out Timer timer2)) { timer2.Dispose(); Cooldowns.Remove(id); } Timer timer = new Timer(6.48e+7); timer.Elapsed += delegate { CooldownElapsed(id); }; song.canBePlayed = false; song.cooldownExpiry = DateTime.UtcNow.AddMilliseconds(6.48e+7); timer.AutoReset = false; timer.Start(); Cooldowns.Add(id, timer); }