国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

KTV點歌系統

2019-11-17 02:13:29
字體:
來源:轉載
供稿:網友

KTV點歌系統

KTV點歌系統————北大青鳥 指導老師:原玉明

 1  public enum SongPlayState 2     { 3         //未播放,播放,重播,切歌 4         unplayed, played, again, cut 5     } 6     public class Song 7     { 8         public string SongName { get; set; }//歌曲名稱 9 10         public string SongURL { get; set; }//歌曲路徑11 12        13         public  SongPlayState playState = SongPlayState.unplayed;//默認未播放14         internal SongPlayState PlayState { get; set; }15 16         //狀態為已播17         public  void SetSongPlayed()18         {19             this.PlayState = SongPlayState.played;20         }21         //重唱22         public void SetPlayAgain()23         {24             this.playState = SongPlayState.again;25         }26        //切歌27         public void SetSongCut()28         {29             this.playState = SongPlayState.cut;30         }

PlayList類中實現切歌 重唱 下一首 等.....

  1 public class PlayList  2     {  3         //定義一個長度為、50的歌曲數組,默認存儲50首歌曲  4         public static Song[] SongList = new Song[50];  5         public static int SongIndex = 0;//當前播放的歌曲在數組中的索引  6         //點播一首歌曲,其實是將歌曲對象添加到歌曲數組中  7         public static bool AddSong(Song song)  8         {  9             bool success = false;//記錄添加歌曲是否成功 10             for (int i = 0; i < SongList.Length; i++) 11             { 12                 //找到數組中第一個為null的位置 13                 if (SongList[i] == null) 14                 { 15                     SongList[i] = song; 16                     success = true; 17                     break; 18                 } 19             } 20             return success; 21         } 22         //獲取當前播放的歌曲::既然是獲取當前播放的歌曲,返回值肯定是Song類型 23         public static Song GetPlaySong() 24         { 25             if (SongList[SongIndex] != null) 26             { 27                 return SongList[SongIndex]; 28             } 29             else 30             { 31                 return null; 32             } 33         } 34         /// <summary> 35         /// 播放下一首 36         /// </summary> 37         public static void MoveOn() 38         { 39             if (SongList[SongIndex] != null && SongList[SongIndex].PlayState == SongPlayState.again) 40             { 41                 SongList[SongIndex].SetSongPlayed(); 42             } 43             else 44             { 45                 SongIndex++; 46             } 47         } 48         /// <summary> 49         /// 當前播放的歌曲名稱 50         /// </summary> 51         /// <returns>歌曲名稱</returns> 52         public static string PlayingSongName() 53         { 54             string songName = ""; // 歌曲名稱 55             if (SongList[SongIndex] != null) 56             { 57                 songName = SongList[SongIndex].SongName; 58             } 59  60             return songName; 61         } 62         /// <summary> 63         /// 下一首要播放的歌曲名稱 64         /// </summary> 65         /// <returns>歌曲名稱</returns> 66         public static string NextSongName() 67         { 68             string songName = ""; // 歌曲名稱 69             if (SongList[SongIndex + 1] != null) 70             { 71                 songName = SongList[SongIndex + 1].SongName; 72             } 73  74             return songName; 75         } 76         //重放當前歌曲 77         public static void PlayAgain() 78         { 79             if (SongList[SongIndex] != null) 80             { 81                 SongList[SongIndex].SetPlayAgain(); 82             } 83         } 84         //切歌 85         public static void CutSong(int index) 86         { 87             int i;//循環變量,代表切歌的位置 88             if (index == -1)//循環變量,代表切割的位置 89             { 90                 i = SongIndex; 91             } 92             else 93             { 94                 i = index;//從切歌的位置開始,將歌曲逐個向前移一個位置 95             } 96             SongList[i].SetSongCut(); 97             while (SongList[i] != null) 98             { 99                 SongList[i] = SongList[i + 1];100                 i++; 101                 //如果達到數組最后一個元素,就將最后一個元素指向空102                 if (i == SongList.Length)103                 {104                     SongList[i] = null;105                 }106             }107         }108     }

實現歌手點歌

  1  public FrmMain frmMain;  2         string connectionStr = "server=.;database=MyKTV;uid=sa";  3         DBHelp db = new DBHelp();  4         PRivate SqlConnection con;  5         //首先要查出數據庫中的圖片路徑和歌曲路徑  6         private void FrmCountry_Load(object sender, EventArgs e)  7         {  8               9             con = new SqlConnection(connectionStr); 10             con.Open(); 11             string sql = "select resource_path from resource_path where resource_id=1"; 12  13             string sqlsongpath = "select resource_path from resource_path where resource_id=2"; 14             SqlCommand cmd = new SqlCommand(sql,con); 15  16             SqlCommand cmd2 = new SqlCommand(sqlsongpath, con); 17             KtvUnit.ImagePath = cmd.ExecuteScalar().ToString(); 18             KtvUnit.SongPath = cmd2.ExecuteScalar().ToString(); 19             con.Close(); 20         } 21         //點擊歌手男女或組合時 22         private void LvOne_Click(object sender, EventArgs e) 23         { 24             25             LoadSingerArea(); 26         } 27         public string singer_type { get; set; } 28         private void LoadSingerArea() 29         { 30             if (this.LvOne.SelectedItems[0] != null) 31             { 32                 LvOne.Visible = false; 33                 LvTwo.Location = LvOne.Location; 34                 LvTwo.Dock = DockStyle.Fill; 35                 LvTwo.Visible = true; 36                 this.singer_type=Convert.ToString(LvOne.SelectedItems[0].Text); 37             } 38             39             con = new SqlConnection(connectionStr); 40             string sql = "select singertype_id,singertype_name from singer_type"; 41             SqlCommand cmd = new SqlCommand(sql, con); 42             SqlDataReader dr; 43             try 44             { 45                 con.Open(); 46                 LvTwo.Items.Clear(); 47                 dr = cmd.ExecuteReader();              48                 if (dr.HasRows) 49                 { 50                     int index = 0; 51                     while (dr.Read()) 52                     { 53                         ListViewItem lvItem = new ListViewItem(); 54                         int typeid = Convert.ToInt32(dr["singertype_id"]); 55                          string typename = Convert.ToString(dr["singertype_name"]); 56                         lvItem.Text = typename; 57                         lvItem.Tag = typeid; 58                         lvItem.ImageIndex = index; 59                         LvTwo.Items.Add(lvItem); 60                         index++; 61                     } 62                 } 63                 dr.Close(); 64             } 65             catch (Exception ex) 66             { 67  68                 MessageBox.Show("系統出現異常" + ex.Message); 69             } 70             finally  71             { 72                 con.Close(); 73             } 74         } 75         public string singertype_id { get; set; } 76         /// <summary> 77         /// 點擊地區類型時 78         /// </summary> 79         /// <param name="sender"></param> 80         /// <param name="e"></param> 81         private void LvTwo_Click(object sender, EventArgs e) 82         { 83             if (this.LvTwo.SelectedItems[0] != null) 84             { 85                 LvTwo.Visible = false; 86                 Lvthree.Location = LvTwo.Location; 87                 Lvthree.Dock = DockStyle.Fill; 88                 Lvthree.Visible = true; 89                 this.singertype_id = Convert.ToString(LvTwo.SelectedItems[0].Tag); 90             } 91             string result = singer_type; 92             if (result != "組合") 93             { 94                 result
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 张掖市| 云安县| 河西区| 颍上县| 文登市| 涟水县| 兴海县| 桑日县| 共和县| 长宁县| 乡宁县| 航空| 图们市| 盱眙县| 鄂伦春自治旗| 临泉县| 江川县| 柘荣县| 建昌县| 梁平县| 宜兰市| 临泽县| 彭水| 临武县| 黄大仙区| 马鞍山市| 平顶山市| 冕宁县| 华阴市| 瑞丽市| 临猗县| 赫章县| 平泉县| 英超| 镇坪县| 美姑县| 曲阜市| 阿拉善右旗| 景东| 柳江县| 都昌县|