Exemplo n.º 1
0
        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"));
                }
            }
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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));
            }
        }
Exemplo n.º 6
0
        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)
            {
            }
        }
Exemplo n.º 7
0
        public IActionResult Index()
        {
            var lyricModel = new LyricModel();

            return(View(lyricModel));
        }
Exemplo n.º 8
0
        async static public Task Populate(LyricModel lyric)
        {
            var simpleLyric = await WebController.FetchSimpleLyricByTrackId(lyric.TrackId);

            lyric.OriginalLyric = simpleLyric.lyric;
        }