public HttpResponseMessage AddLyric([FromUri] long id, [FromBody] LyricModel lyricModel) { using (var db = new OnlineMusicEntities()) { var query = dto.GetSongQuery(db); var song = (from s in db.Songs where s.Id == id select s).FirstOrDefault(); if (song == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Không tìm thấy bài hát id=" + id)); } if (song.Resource.Type == (int)ResourceTypeManager.Audio) { Lyric lyric = new Lyric(); lyricModel.UpdateEntity(lyric); db.Lyrics.Add(lyric); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.Created)); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Chỉ có thể thêm lời bài hát cho audio")); } } }
public async Task <IActionResult> Search(string SongTitle, string BandName) { var lyricModel = new LyricModel(); lyricModel.Title = SongTitle; lyricModel.BandName = BandName; lyricModel.Lyric = await _lyricsSearchEngine.RetrieveLyricAsync(SongTitle, BandName); return(View("Index", lyricModel)); }
private async Task <string> ParseLyricsAsync(string trackId) { string resJson = await httpClient.GetStringAsync(String.Format(apiLyricsFormat, trackId)); LyricModel res = JsonConvert.DeserializeObject <LyricModel>(resJson); if (res.tlyric == null || string.IsNullOrEmpty(res.tlyric.lyric) || !this.enableTLyric) { return(res.lrc.lyric); } else { return(res.tlyric.lyric); } }
public LyricModel Analyze(string text) { var parser = new WordParser(); var model = new LyricModel(); ParsedTexts = parser.Parse(text); RhymeGroups = new RhymeBuilder().Apply(ParsedTexts.ToArray()).RhymeGroups.ToList(); model.Lines = ParsedTexts.GroupBy(each => each.Line) .Select((group, index) => new LyricLineModel { Index = index, Words = group.Select(word => new WordModel(word)).ToList() }) .ToList(); return(model); }
public HttpResponseMessage UpdateLyric([FromUri] long id, [FromBody] LyricModel lyricModel) { using (var db = new OnlineMusicEntities()) { var query = dto.GetSongQuery(db); var lyric = (from l in db.Lyrics where l.Id == lyricModel.Id select l).FirstOrDefault(); if (lyric == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Không tìm thấy lời bài hát id=" + lyricModel.Id)); } lyric.Lyric1 = lyricModel.Lyric; lyric.Verified = lyricModel.Verified; db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } }
private void NowPlayingSong_ChangeLyric(LyricModel lyric, string nextLyric) { //tb_lyric2_static.Text = tb_lyric1_static.ActualWidth.ToString(); try { switch (nextTextBlock) { case 1: tb_lyric1_static.Text = lyric.Content; tb_lyric1_run.Text = lyric.Content; nextTextBlock = 2; //set up lyric 2; if (nextLyric != "") { tb_lyric2_static.Text = nextLyric; tb_lyric2_run.Text = ""; tb_lyric1_run.Width = 0; } animationLyric1.From = 0; //animationLyric1.To = lyric.Content.Length * 11; animationLyric1.To = MeasureString(lyric.Content, tb_lyric1_static); duration = TimeSpan.FromMilliseconds(lyric.TimeEnd - lyric.TimeStart); if (duration.TotalMilliseconds <= 0) { duration = TimeSpan.FromMilliseconds(1); } animationLyric1.Duration = new Duration(duration); storyboard_lyric1 = new Storyboard(); storyboard_lyric1.Children.Add(animationLyric1); storyboard_lyric1.Begin(this); break; case 2: tb_lyric2_static.Text = lyric.Content; tb_lyric2_run.Text = lyric.Content; nextTextBlock = 1; animationLyric2.From = 0; //animationLyric2.To = lyric.Content.Length * 10; animationLyric2.To = MeasureString(lyric.Content, tb_lyric2_static); duration = TimeSpan.FromMilliseconds(lyric.TimeEnd - lyric.TimeStart); if (duration.TotalMilliseconds <= 0) { duration = TimeSpan.FromMilliseconds(1); } animationLyric2.Duration = new Duration(duration); storyboard_lyric2 = new Storyboard(); storyboard_lyric2.Children.Add(animationLyric2); storyboard_lyric2.Begin(this); break; default: break; } } catch (Exception) { } }
public IActionResult Index() { var lyricModel = new LyricModel(); return(View(lyricModel)); }
async static public Task Populate(LyricModel lyric) { var simpleLyric = await WebController.FetchSimpleLyricByTrackId(lyric.TrackId); lyric.OriginalLyric = simpleLyric.lyric; }