public IHttpActionResult PutSONG(int id, SONG sONG) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != sONG.ID) { return(BadRequest()); } db.Entry(sONG).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SONGExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
bool TransitionSong() { bool anyValueChange = false; float speed = Time.deltaTime * songTransitionSpeed; for (int i = 0; i < allSong.Count - 1; i--) { SONG song = allSong[i]; if (song == activeSong) { if (song.volume < song.maxVolume) { song.volume = smoothTransition ? Mathf.Lerp(song.volume, song.maxVolume, speed) : Mathf.MoveTowards(song.volume, song.maxVolume, speed); anyValueChange = true; } } else { if (song.volume > 0f) { song.volume = smoothTransition ? Mathf.Lerp(song.volume, 0f, speed) : Mathf.MoveTowards(song.volume, 0f, speed); anyValueChange = true; } else { allSong.RemoveAt(i); song.destroySong(); continue; } } } return(anyValueChange); }
public void PlaySong(AudioClip song, float maxVolume = 1f, float pitch = 1f, float startingVolume = 0f, bool playOnStart = true, bool loop = true) { if (song != null) { for (int i = 0; i < allSongs.Count; i++) { SONG s = allSongs[i]; if (s.clip == song) { activeSong = s; break; } } if (activeSong == null || activeSong.clip != song) { activeSong = new SONG(song, maxVolume, pitch, startingVolume, playOnStart, loop); } } else { activeSong = null; } StopAllCoroutines(); StartCoroutine(VolumeLeveling()); }
bool TransitionSongs() { bool anyValueChanged = false; float speed = songTransitionSpeed * Time.deltaTime; for (int i = allSongs.Count - 1; i >= 0; i--) { SONG song = allSongs[i]; if (song == activeSong) { if (song.volume < song.maxVolume) { song.volume = songSmoothTransitions ? Mathf.Lerp(song.volume, song.maxVolume, speed) : Mathf.MoveTowards(song.volume, song.maxVolume, speed); anyValueChanged = true; } } else { if (song.volume > 0.001f) { song.volume = songSmoothTransitions ? Mathf.Lerp(song.volume, 0f, speed) : Mathf.MoveTowards(song.volume, 0f, speed); anyValueChanged = true; } else { allSongs.RemoveAt(i); song.DestroySong(); continue; } } } return(anyValueChanged); }
public static bool TagsComplete(this SONG song) { bool ret = true; try { if (string.IsNullOrEmpty(song.ALBUM)) { ret = false; } if (string.IsNullOrEmpty(song.ARTIST)) { ret = false; } if (string.IsNullOrEmpty(song.GENRE)) { ret = false; } if (string.IsNullOrEmpty(song.LOCATION)) { ret = false; } if (string.IsNullOrEmpty(song.TITLE)) { ret = false; } } catch (Exception ex) { Debug.Write(ex.Message); } return(ret); }
public void SyncSongUploadedStatusWithBlobs() { AzureService azureService = new AzureService(Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey); MusicDao musicDao = GetMusicDao(); CloudBlobClient blobClient = azureService.GetCloudBlobContainer(); CloudBlobContainer container = blobClient.GetContainerReference(containerName); IEnumerable <IListBlobItem> blobs = container.ListBlobs(); foreach (IListBlobItem blob in blobs) { testContextInstance.WriteLine("{0}", blob.Uri); String[] s = blob.Uri.ToString().Split(new char[] { '/' }); String key = s[s.Length - 1]; s = key.Split(new char[] { '.' }); testContextInstance.WriteLine("{0}", s[0]); try { int id = Convert.ToInt32(s[0]); var song = new SONG() { ID = id, UPLOADED = true }; musicDao.UpdateSongUploadStatus(song); } catch (Exception ex) { testContextInstance.WriteLine("{0} {1}", ex.Message, ex.StackTrace); } } }
public void DeleteDuplicateSongs() { var dataContext = new MusicEntities1(); // Delete songs with the same hash code IQueryable <SONG> songQuery = from s in dataContext.SONG orderby s.HASH where s.HASH != null select s; SONG previousSong = null; foreach (SONG song in songQuery) { if ((previousSong != null) && (previousSong.HASH == song.HASH)) { testContextInstance.WriteLine("{0} : {1}", previousSong.LOCATION, song.LOCATION); if (previousSong.ID < song.ID) { dataContext.SONG.Remove(previousSong); dataContext.SaveChanges(); } else { dataContext.SONG.Remove(song); dataContext.SaveChanges(); } } previousSong = song; } // Delete songs with the same location songQuery = from s in dataContext.SONG orderby s.LOCATION where s.LOCATION != null select s; previousSong = null; foreach (SONG song in songQuery) { if ((previousSong != null) && (previousSong.LOCATION == song.LOCATION)) { testContextInstance.WriteLine("{0} : {1}", previousSong.LOCATION, song.LOCATION); if (previousSong.ID < song.ID) { dataContext.SONG.Remove(previousSong); dataContext.SaveChanges(); } else { dataContext.SONG.Remove(song); dataContext.SaveChanges(); } } previousSong = song; } dataContext.SaveChanges(); }
public static SONG CalculateModificationDate(this SONG song) { var fileInfo = new FileInfo(song.LOCATION); song.UPDATED = fileInfo.LastWriteTime; return(song); }
public void AddIdToFilename() { SONG song = new SONG(); song.LOCATION = @"E:\Gdrive\Music\Franz Ferdinand\Right Thoughts\Ulysses.mp3"; song.ID = 99; song.AddIdToFilename(); }
public bool Ambient(SONG song) { if (song.GENRE == null) { return(false); } return(song.GENRE.ToUpper().Contains("AMBIENT")); }
public void SetSong(SONG song) { this.song = song; this.Title = song.TITLE; this.Artist = song.ARTIST; this.Genre = song.GENRE; this.Rating = song.RATING; this.Location = song.LOCATION; }
public void DownloadAllSongBlobs() { AzureService azureService = new AzureService(Settings.Default.AzureAccountName, Settings.Default.AzureAccountKey); MusicDao musicDao = GetMusicDao(); CloudBlobClient blobClient = azureService.GetCloudBlobContainer(); CloudBlobContainer container = blobClient.GetContainerReference(containerName); IEnumerable <IListBlobItem> blobs = container.ListBlobs(); foreach (IListBlobItem blob in blobs) { testContextInstance.WriteLine("{0}", blob.Uri); String[] s = blob.Uri.ToString().Split(new char[] { '/' }); String key = s[s.Length - 1]; s = key.Split(new char[] { '.' }); testContextInstance.WriteLine("{0}", s[0]); try { int id = Convert.ToInt32(s[0]); SONG song = musicDao.GetSongById(id); FileInfo fileInfo = new FileInfo(song.LOCATION); s = song.LOCATION.Split(new char[] { '\\' }); String artistFolder = null; String name = fileInfo.Name; String fileName = null; if (s.Length > 3) { artistFolder = targetFolder; for (int i = 2; i < s.Length - 1; i++) { artistFolder = artistFolder + "\\" + s[i]; DirectoryInfo directoryInfo = new DirectoryInfo(artistFolder); if (!directoryInfo.Exists) { Directory.CreateDirectory(artistFolder); } } fileName = String.Format("{0}\\{1}", artistFolder, name); } else { fileName = String.Format("{0}\\{1}", targetFolder, name); } if (!File.Exists(fileName)) { string key1 = String.Format("{0}.mp3", song.ID); azureService.DownloadFile(containerName, fileName, key1); } } catch (Exception ex) { testContextInstance.WriteLine("{0} {1}", ex.Message, ex.StackTrace); throw; } } }
public void PopulateSongTable1() { var gDriveServiceContainer = new GDriveService(); var gdriveService = gDriveServiceContainer.GetService(); var songRepository = new SongRepository(new Repository("log")); int maxSongs = 10; int songCount = 0; string tempFolder = @"C:\temp2\"; FilesResource.ListRequest request = gdriveService.Files.List(); var fileList = new List <File>(); try { FileList files = request.Execute(); fileList.AddRange(files.Items); request.PageToken = files.NextPageToken; foreach (var file in fileList) { try { testContextInstance.WriteLine("{0}", file.WebContentLink); WebClient webClient = new WebClient(); string filename = tempFolder + file.OriginalFilename; webClient.DownloadFile(file.WebContentLink, filename); // Extract mp3 tags SONG song = new SONG(); song.LOCATION = filename; if (song.IsMp3File()) { song.Populate(); testContextInstance.WriteLine(song.GENRE); songRepository.Add(file.Id, file.WebContentLink, file.OriginalFilename, file.FileSize, song.TITLE, song.ARTIST, song.ALBUM, song.GENRE, song.LOCATION, song.RATING, song.TrackNumber); } System.IO.File.Delete(filename); } catch (Exception ex1) { testContextInstance.WriteLine("Error: {0}", ex1.Message); } /* songCount++; * if (songCount>maxSongs) * { * return; * } */ } } catch (Exception e) { testContextInstance.WriteLine("Error: {0}", e.Message); } }
internal GenericMusicItem(SONG s) { InnerType = MediaType.Song; ContextualID = s.ID; Title = s.Title; Description = s.Album; Addtional = s.Performers.IsNullorEmpty() ? Consts.UnknownArtists : string.Join(Consts.CommaSeparator, s.Performers.Split(new string[] { Consts.ArraySeparator }, StringSplitOptions.RemoveEmptyEntries)); IDs = new int[] { s.ID }; PicturePath = s.PicturePath; }
public IHttpActionResult GetSONG(int id) { SONG sONG = db.SONGS.Find(id); if (sONG == null) { return(NotFound()); } return(Ok(sONG)); }
public IHttpActionResult PostSONG(SONG sONG) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.SONGS.Add(sONG); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = sONG.ID }, sONG)); }
public void SetSong(MellowSongs mellowSong) { this.song = new SONG(); this.song.TITLE = mellowSong.TITLE; this.song.ARTIST = mellowSong.ARTIST; this.song.GENRE = mellowSong.GENRE; this.Title = mellowSong.TITLE; this.Artist = mellowSong.ARTIST; this.Genre = mellowSong.GENRE; this.Rating = song.RATING; this.Location = song.LOCATION; }
public void PopulateSongTable2() { var gDriveServiceContainer = new GDriveService(); var gdriveService = gDriveServiceContainer.GetService(); List <File> fileList = new List <File>(); FilesResource.ListRequest request = gdriveService.Files.List(); string tempFolder = @"E:\MusicTemp\"; var songRepository = new SongRepository(new Repository("log")); do { try { FileList files = request.Execute(); fileList.AddRange(files.Items); request.PageToken = files.NextPageToken; foreach (var file in fileList) { try { testContextInstance.WriteLine("{0}", file.WebContentLink); WebClient webClient = new WebClient(); string filename = tempFolder + file.OriginalFilename; webClient.DownloadFile(file.WebContentLink, filename); // Extract mp3 tags SONG song = new SONG(); song.LOCATION = filename; if (song.IsMp3File()) { song.Populate(); testContextInstance.WriteLine(song.GENRE); songRepository.Add(file.Id, file.WebContentLink, file.OriginalFilename, file.FileSize, song.TITLE, song.ARTIST, song.ALBUM, song.GENRE, song.LOCATION, song.RATING, song.TrackNumber); } System.IO.File.Delete(filename); } catch (Exception ex1) { testContextInstance.WriteLine("Error: {0}", ex1.Message); } } } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); request.PageToken = null; } } while (!String.IsNullOrEmpty(request.PageToken)); }
static void DownloadSong(string filename, SONG song) { Trace.WriteLine(String.Format("Downloading {0}", filename)); try { String key = String.Format("{0}.mp3", song.ID); azureService.DownloadFile("public", filename, key); } catch (Exception) { Trace.TraceError("Unable to download blob {0} {1}", song.ID, filename); } }
public IList <SONG> GetSongs(string genre, string sequence, int skip, string artist, string location) { var songList = new List <SONG>(); var song = new SONG(); song.TITLE = "Test title"; song.ARTIST = "Test artist"; song.GENRE = "Test genre"; song.LOCATION = "Test location"; songList.Add(song); return(songList); }
public static int GetFilenameId(this SONG song) { int ret = -1; var re = new Regex(@"\\s\d*s"); var matches = re.Matches(song.LOCATION); if (matches.Count > 0) { ret = Convert.ToInt32(matches[0].Value); } return(ret); }
public void PlayMusic(SONG songToplay) { if ((int)songToplay < Songs.Count) { if (Songs[(int)songToplay] != null) { Speaker.Stop(); Speaker.clip = Songs[(int)songToplay]; Speaker.loop = true; Speaker.Play(); } } }
public SongDto(SONG song) { Id = song.ID; Title = song.NAME; Artist = song.ARTIST_NAME; TitleArtist = Title + "/" + Artist; Album = song.ALBUM_NAME; foreach (var songGenre in song.SONG_GENRES) { Genre = Genre != null ? Genre + "/" + songGenre.GENRE.DESCRIPTION : songGenre.GENRE.DESCRIPTION; } Year = song.YEAR; }
public SongView(SONG song) { this.ALBUM = song.ALBUM; this.ARTIST = song.ARTIST; this.COMMENTS = song.COMMENTS; this.GENRE = song.GENRE; this.ID = song.ID; this.LOCATION = song.LOCATION; this.TITLE = song.TITLE; this.RATING = song.RATING; this.Location = musicBlobUrl + "/" + song.ID + ".mp3"; }
public static bool HasIdInFilename(this SONG song) { bool ret = false; var re = new Regex(@"\\s\d*s"); var matches = re.Matches(song.LOCATION); if (matches.Count > 0) { ret = true; string matchValue = matches[0].Value; } return(ret); }
public SONG ConvertToSong() { SONG song = new SONG(); song.ALBUM = this.ALBUM; song.ARTIST = this.ARTIST; song.COMMENTS = this.COMMENTS; song.GENRE = this.GENRE; song.ID = this.ID; song.LOCATION = this.LOCATION; song.TITLE = this.TITLE; song.RATING = this.RATING; return(song); }
public IHttpActionResult DeleteSONG(int id) { SONG sONG = db.SONGS.Find(id); if (sONG == null) { return(NotFound()); } db.SONGS.Remove(sONG); db.SaveChanges(); return(Ok(sONG)); }
internal Song(SONG song) { ID = song.ID; LastModified = song.LastModified; IsOnedrive = song.IsOneDrive; Duration = song.Duration; BitRate = song.BitRate; Rating = song.Rating; FilePath = song.FilePath; MusicBrainzArtistId = song.MusicBrainzArtistId; MusicBrainzDiscId = song.MusicBrainzDiscId; MusicBrainzReleaseArtistId = song.MusicBrainzReleaseArtistId; MusicBrainzReleaseCountry = song.MusicBrainzReleaseCountry; MusicBrainzReleaseId = song.MusicBrainzReleaseId; MusicBrainzReleaseStatus = song.MusicBrainzReleaseStatus; MusicBrainzReleaseType = song.MusicBrainzReleaseType; MusicBrainzTrackId = song.MusicBrainzTrackId; MusicIpId = song.MusicIpId; BeatsPerMinute = song.BeatsPerMinute; Album = song.Album; AlbumArtists = song.AlbumArtists.Split(new string[] { Consts.ArraySeparator }, StringSplitOptions.RemoveEmptyEntries); AlbumArtistsSort = song.AlbumArtistsSort.Split(new string[] { Consts.ArraySeparator }, StringSplitOptions.RemoveEmptyEntries); AlbumSort = song.AlbumSort; AmazonId = song.AmazonId; Title = song.Title; TitleSort = song.TitleSort; Track = song.Track; TrackCount = song.TrackCount; ReplayGainTrackGain = song.ReplayGainTrackGain; ReplayGainTrackPeak = song.ReplayGainTrackPeak; ReplayGainAlbumGain = song.ReplayGainAlbumGain; ReplayGainAlbumPeak = song.ReplayGainAlbumPeak; Comment = song.Comment; Disc = song.Disc; Composers = song.Composers.Split(new string[] { Consts.ArraySeparator }, StringSplitOptions.RemoveEmptyEntries); ComposersSort = song.ComposersSort.Split(new string[] { Consts.ArraySeparator }, StringSplitOptions.RemoveEmptyEntries); Conductor = song.Conductor; DiscCount = song.DiscCount; Copyright = song.Copyright; Genres = song.Genres.Split(new string[] { Consts.ArraySeparator }, StringSplitOptions.RemoveEmptyEntries); Grouping = song.Grouping; Lyrics = song.Lyrics; Performers = song.Performers.Split(new string[] { Consts.ArraySeparator }, StringSplitOptions.RemoveEmptyEntries); PerformersSort = song.PerformersSort.Split(new string[] { Consts.ArraySeparator }, StringSplitOptions.RemoveEmptyEntries); Year = song.Year; PicturePath = song.PicturePath; SampleRate = song.SampleRate; AudioChannels = song.AudioChannels; }
public void PickRandomSong() { try { MusicDao musicDao = new MusicDao(); musicDao.Initialize(); SONG song = musicDao.PickRandomSong(); Console.WriteLine(song.TITLE); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } }
public static SONG AddIdToFilename(this SONG song) { try { FileInfo fileInfo = new FileInfo(song.LOCATION); song.FILESIZE = fileInfo.Length; string newFilename = string.Format("{0}\\s{1}s {2}", fileInfo.DirectoryName, song.ID, fileInfo.Name); fileInfo.CopyTo(newFilename, true); File.Delete(song.LOCATION); song.LOCATION = newFilename; } catch (Exception ex) { Debug.WriteLine(string.Format("Error: {0}", ex.Message)); } return(song); }