c#实现KTV点歌系统

2019-12-26 13:10:24王旭
  • public static int SongIndex = ;//当前播放的歌曲在数组中的索引  //点播一首歌曲,其实是将歌曲对象添加到歌曲数组中 
  • public static bool AddSong(Song song)  { 
  • bool success = false;//记录添加歌曲是否成功  for (int i = ; i < SongList.Length; i++) 
  • {  //找到数组中第一个为null的位置 
  • if (SongList[i] == null)  { 
  • SongList[i] = song;  success = true; 
  • break;  } 
  • }  return success; 
  • }  //获取当前播放的歌曲::既然是获取当前播放的歌曲,返回值肯定是Song类型 
  • public static Song GetPlaySong()  { 
  • if (SongList[SongIndex] != null)  { 
  • return SongList[SongIndex];  } 
  • else  { 
  • return null;  } 
  • }  /// <summary> 
  • /// 播放下一首  /// </summary> 
  • public static void MoveOn()  { 
  • if (SongList[SongIndex] != null && SongList[SongIndex].PlayState == SongPlayState.again)  { 
  • SongList[SongIndex].SetSongPlayed();  } 
  • else  { 
  • SongIndex++;  } 
  • }  /// <summary> 
  • /// 当前播放的歌曲名称  /// </summary> 
  • /// <returns>歌曲名称</returns>  public static string PlayingSongName() 
  • {  string songName = ""; // 歌曲名称 
  • if (SongList[SongIndex] != null)  { 
  • songName = SongList[SongIndex].SongName;  } 
  • return songName;  } 
  • /// <summary>  /// 下一首要播放的歌曲名称 
  • /// </summary>  /// <returns>歌曲名称</returns> 
  • public static string NextSongName()  { 
  • string songName = ""; // 歌曲名称  if (SongList[SongIndex + ] != null)