Chocolate player lyrics

Source: Internet
Author: User

The chocolate player completed some days ago,

It is called "No lyrics are displayed, so the ghost will use yours !",

I was deeply touched, so I just made some effort to complete the lyrics function,

In fact, the lyrics are quite simple, just reading files,

Then try to synchronize the player with the lyrics page,

However, you still need to pay attention to many aspects in reading the. LRC file,

First, you should be familiar with the composition of the lyrics,

Each line of the lyrics file generally starts with a line like [. 45,

For example

Therefore, you only need to read one line of the lyrics,

Using (streamreader myreader = new streamreader (lrcpath,

System. Text. encoding. getencoding ("gb2312 ")))
{
While (myreader. Read ()! =-1)
{
String myline = myreader. Readline ();
}
}

Then, each row read is stored in a generic set list <string>, and the lyrics are read,

However, as shown above, the time and lyrics cannot be distinguished,

Only when time and lyrics are differentiated can a specific lyrics be displayed at a specific time,

That is, the lyrics are synchronized to mediaplayer playback,

Therefore, the above generic set must be parsed to parse the lyrics and time,

If parsing is performed, it mainly relies on traversing each item in the generic set, and then parsing each item,

Separates time and text, and saves the corresponding time and text to the newly created list <string> generic set,

In addition, the index table of the corresponding time and text in their generic sets is the same,

In this way, you can conveniently obtain the subscript of the time closest to the current playback time stored in the generic set,

In this way, the corresponding time in the text generic set can be obtained based on the subscript,

In this way, you can synchronize the playback and lyrics.

Let's see the results.

 

 

Controls a button for displaying the lyrics

If you want a player or source code, you can leave an email to me,

Yes. This is also the example.CodeWriting is a bit messy,

Be careful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.