KTV play important code parsing the first step:
Set up the KTV song interface, and then to achieve is the singer song, click on the form of the Load event to write the following code:
private void Frmzhu_load (object sender, EventArgs e)
{
Read the picture path in the MyResource table and put it into the ImagePath variable
String sql = "Select Resource_path from Resource_path where resource_id=1";
SqlConnection con = new SqlConnection (SQLHELPER.STR);
SqlCommand com = new SqlCommand (Sql,con);
Con. Open ();
Ktvutil.singerphoto = com. ExecuteScalar (). ToString ();
Con. Close ();
Read the singer Path
sql = "Select Resource_path from Resource_path where resource_id=2";
Com.commandtext = SQL;
Try
{
Con. Open ();
Ktvutil.songlu = com. ExecuteScalar (). ToString ();
}
catch (Exception ex)
{
MessageBox.Show ("System resource Error!" +ex. Message);
}
Finally
{
Con. Close ();
}
}
Note: How the player is getting
Start by opening the toolbox, then right-click the watch, select "Select items", then click on the COM component above, then
Just click OK!
The purpose of the above code is to read the slices and paths in the database, and then save them in the Songlu of the Ktvutil class that has been built.
Clicking on a pop song will show the following form:
Here you want to choose the songs of your favorite singers, and click on the appropriate type to appear on the third form you need to load the picture dynamically
Step One: Hide the third form that appears on the two form: Remember, this is a three-table connection! There are three of the ListView;
if (lvtwo.selecteditems[0]! = NULL)
{
Lvtwo.visible = false;
Lvthree.location = lvtwo.location;
Lvlb.dock = DockStyle.Fill;
Lvthree.size = lvlb.size;
Lvthree.visible = true;
Singid = Convert.ToInt32 (Lvtwo.selecteditems[0]. TAG); Save the selected region number second step: Connect to the database and then follow the type you want to click to find the type of male singer, female singer, or group in the database, read the path of the photo, and then display the picture in the corresponding name.
while (Dr. Read ())
{
Put the singer's avatar in the Iamgelist control
String photourl = Ktvutil.singerphoto + "\ \" + convert.tostring (dr["Singer_poto_url"]);
IMASINGERNAME.IMAGES.ADD (Image.FromFile (Photourl));
Add a singer to the ListView
ListViewItem list = new ListViewItem ();
List. Text = convert.tostring (dr["Singer_name"]);
List. Tag = convert.tostring (dr["singer_id"]);
List. ImageIndex = ImageIndex;
LVTHREE.ITEMS.ADD (list);
imageindex++;
}
Dr. Close ();
}
In the third Listviewd Clik event, the artist's ID was read from the singer's photo and then displayed
private void Lvthree_click (object sender, EventArgs e)
{
SqlConnection con = new SqlConnection (SQLHELPER.STR);
StringBuilder sb = new StringBuilder ();
Sb. AppendFormat ("Select Song_id,song_name,singer_name= '" +lvthree.selecteditems[0]. Text+ "', Song_url from Song_info where singer_id=" +convert.toint32 (Lvthree.selecteditems[0]. TAG) + "");
Fslgeyu Eyu = new Fslgeyu ();
Eyu.name = sb. ToString ();
Eyu. Previous = execute.singer;//Specifies that the returned form is song by singer
Eyu. Show ();
This. Close ();
The next form that appears is the singer's song list:
When you click on a song: It will appear in the list of songs that have been clicked, and all we have to do is
Speak songs set to null: Then call the Mon () method
- public static void MOn ()
{
if (Songlist[songindex]! = null && Songlist[songindex]. Son = = Alreadyson.repeatsong)//If there is a value in Songindex, then it means that the current song is in the state of broadcast
{
Songlist[songindex]. Yib (); We'll give it a way of sowing.
}
Else
{
songindex++;
}
2.//then adds the selected song object to the array
private void Dgvlist_cellclick (object sender, DataGridViewCellEventArgs e)
{
Creates a song object and assigns the currently selected song name and path to the object
Songa song = new Songa ();
Song. Songname = Dgvlist.selectedrows[0]. cells["Column1"]. Value.tostring (); Songname is the name of the column in DGV
Song. Songway = Dgvlist.selectedrows[0]. cells["Column3"]. Value.tostring ();
Add a selected song to an array
Dyshu.addsong (song); assigning to arrays
}
3.//define an array of length 50, save 50 song by default
public static songa[] SongList = new SONGA[50];
public static int songindex = 0; The index of the currently playing song in the array
if (player1.playstate = = WMPLib.WMPPlayState.wmppsStopped)
{
song = null;
Dyshu.mon ();
}
4. Then add a Timer control to the playback window
private void Tmer_tick (object sender, EventArgs e)
{
if (song = = null)
{
Playsong ();
}
4.1 Determines whether the Playsong () method is called when the position of the array is empty in the Timer control's Tick event
private void Tmer_tick (object sender, EventArgs e)
{
if (song = = null)
{
Playsong ();
}
if (player1.playstate = = WMPLib.WMPPlayState.wmppsStopped)
{
Song = null;//Set the songs to empty
Dyshu.mon ();
}
if (song! = null && song. Son = = Alreadyson.repeatsong)
{
Playsong ();
}
}
Do not do a lot of advice to everyone!!!
KTV Play Important Code parsing