The playing principle of the KTV karaoke System and the working principle of the ktv karaoke System
Playing principle of the karaoke song system of Beida qingniao
Instructor-former Yuming
1. First, we know there are two classes (PlayList Song)
There is a method in the PlayList class.
Public static bool AddSong (Song song)
{
Bool success = false; // record whether the song is successfully added
For (int I = 0; I <SongList. Length; I ++)
{
// Locate the first null position in the array
If (SongList [I] = null)
{
SongList [I] = song;
Success = true;
Break;
}
}
Return success;
}
2. Place the selected song object to an array in the PlayList class.
Song song = new Song ();
Song. SongName = dgvSong. SelectedRows [0]. Cells ["songName"]. Value. ToString (); record the current song
Song. SongURL = KtvUnit. SongPath + "\" + dgvSong. SelectedRows [0]. Cells ["songURL"]. Value. ToString ();
// MessageBox. Show (song. SongURL );
PlayList. AddSong (song );
3. Timer control 1 s Enable = true Tick Click Event in FrmMian
If (Player1.playstate = Vmpplayer. stopped)
{
Song = null;
PlayList. MoveOn (); // when the song is played to the last second, play the next one.
}
4. public static void MoveOn ()
{
If (SongList [SongIndex]! = Null & SongList [SongIndex]. PlayState = SongPlayState. again)
// If the current playing song is not empty and the status is Replay
{
SongList [SongIndex]. SetSongPlayed (); // The status is changed to played.
}
Else
{
SongIndex ++; // execute ++ to play the next video
}
}
5. public void SongList ()'
{
LvSong. Items. Clear ();
For (int I = 0; I <PlayList. SongList. Length; I ++)
{
If (PlayList. SongList [I]! = Null)
{
ListViewItem item = new ListViewItem ();
Item. Text = PlayList. SongList [I]. SongName;
Item. Tag = I;
String playstate = PlayList. SongList [I]. PlayState = SongPlayState. unplayed? "Not played": "played ";
Item. SubItems. Add (playstate );
LvSong. Items. Add (item );
}
}
}