// One session is one person // Has a list of playlists (or maybe just one, in the case of our MVP) // Each playlist is a list of songs // It has a OnSwitchedSong function public void SwitchCurrentPlayback(SwitchedSongEventArgs arg) { // This function is subscribed to the switchedsong event on our singleton // This function changes the variable that our HTML5 iframe is bound to throw new NotImplementedException(); }
public IActionResult EditSingleTrack(string switchedSongTimeTicks, int newStartTime, int newEndTime) { // We assume that endtime has been checked against the total length of the song, because we get actual youtube duration on backend SwitchedSongEventArgs lastEvent = _room.LastSwitchedSongEvent; if (lastEvent.SwitchedSongTime.Ticks != long.Parse(switchedSongTimeTicks)) { throw new Exception("Active song not found"); } if (lastEvent.NewTrackRequest.DJ.Name != User.Identity.Name) { throw new Exception("Wrong dj"); } if (lastEvent.NewTrackRequest.Song.StartTime < 0) { throw new Exception("Start time not allowed"); } if (lastEvent.NewTrackRequest.Song.StartTime >= newEndTime) { throw new Exception("End time must be larger than start time"); } // Change the running song in the current deserialized playlist lastEvent.NewTrackRequest.Song.StartTime = newStartTime; lastEvent.NewTrackRequest.Song.EndTime = newEndTime; // Change the song in the database var usr = _room.GetUser(User.Identity.Name); Playlist playlist = usr.GetPlaylist(lastEvent.NewTrackRequest.PlaylistName); List <Track> tracks = playlist.Tracks.FindAll(x => x.IsSameSong(lastEvent.NewTrackRequest.Song)); foreach (Track track in tracks) { track.StartTime = newStartTime; track.EndTime = newEndTime; } _room.UpdateUser(usr); return(Ok()); }
private void OnSwitchSong(object sender, SwitchedSongEventArgs e) { LastSwitchedSongEvent = e; }