Self-find fun through karaoke application with HTML5 Audio

Tram Ho

In life, sometimes you find some fun things to do with your work, maybe it will help you reduce stress and find work a bit more meaningful.

In the past few days, I also wrote down one (I don’t know what to call it, so called app), which has the function to highlight the text according to the lyrics (also called ca ra o). . It is also nothing special, but I also feel happy when the code is finished and sometimes stressed, open that application and listen to music, while watching my results also see a little more motivation. I am also free to share my bad, messy code and many bugs, maybe there is a friend who needs to get it and fix it. Because of all the code and a bit of processing algorithm, I just talked about my idiotic idea, and the code readers should understand somewhat.

Idea

Simply because I want to write a web application, I can highlight the text according to a song.

Try making photo coloring apps with Deep Learning network
Commemoration of Hung Vuong Group 2019: Providing IT applications for Hung Temple on smartphones
  • First, I need something to load the song and control it (play, pause, seeked). So on HTML 5, there is an audio component that supports all the requirements I want so I’ll use this guy.
  • Next I need a set of lyrics in the song, this I have to create by hand, I create an array of sub-arrays, each sub-array contains the information of a paragraph of lyrics including [ lyrics , time start time , end time ]. Creating the array type ntn is easier to control.

  • When you play or rewind the music to different time periods, I will need to calculate which words will be displayed, then I write a temporary function named findWordIndex to do this task.

  • And when play music, then I will run a continuous interval function to update the current time and calculate track between the start time, the end of the lyrics to update for the text highlight effect.

  • As for the highlight text effect, just create the same two text, one under it, one on top, the top will have color and change the length to create a highlight effect from left to right.

Wish you can do more cool things like this and love your work more!
The secret cheat sheet of HTML is for you to make the web
This masterpiece is completely built using HTML and CSS code
Share the news now

Source : viblo .u22422fd2e797222350ed6c21ecc7a29e { padding:0px; margin: 0; padding-top:1em!important; padding-bottom:1em!important; width:100%; display: block; font-weight:bold; background-color:#eaeaea; border:0!important; border-left:4px solid #34495E!important; text-decoration:none; } .u22422fd2e797222350ed6c21ecc7a29e:active, .u22422fd2e797222350ed6c21ecc7a29e:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; text-decoration:none; } .u22422fd2e797222350ed6c21ecc7a29e { transition: background-color 250ms; webkit-transition: background-color 250ms; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; } .u22422fd2e797222350ed6c21ecc7a29e .ctaText { font-weight:bold; color:inherit; text-decoration:none; font-size: 16px; } .u22422fd2e797222350ed6c21ecc7a29e .postTitle { color:#000000; text-decoration: underline!important; font-size: 16px; } .u22422fd2e797222350ed6c21ecc7a29e:hover .postTitle { text-decoration: underline!important; } Bí kíp cheat sheet của HTML dành cho anh em muốn làm web .ud8cd018d59a3017f24e7ca0272ba88e8 { padding:0px; margin: 0; padding-top:1em!important; padding-bottom:1em!important; width:100%; display: block; font-weight:bold; background-color:#eaeaea; border:0!important; border-left:4px solid #34495E!important; text-decoration:none; } .ud8cd018d59a3017f24e7ca0272ba88e8:active, .ud8cd018d59a3017f24e7ca0272ba88e8:hover { opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; text-decoration:none; } .ud8cd018d59a3017f24e7ca0272ba88e8 { transition: background-color 250ms; webkit-transition: background-color 250ms; opacity: 1; transition: opacity 250ms; webkit-transition: opacity 250ms; } .ud8cd018d59a3017f24e7ca0272ba88e8 .ctaText { font-weight:bold; color:inherit; text-decoration:none; font-size: 16px; } .ud8cd018d59a3017f24e7ca0272ba88e8 .postTitle { color:#000000; text-decoration: underline!important; font-size: 16px; } .ud8cd018d59a3017f24e7ca0272ba88e8:hover .postTitle { text-decoration: underline!important; } Kiệt tác này được dựng lên hoàn toàn nhờ code HTML và CSS