I play mp3 with VLC and Windows Media Player playlist . But I cannot check when the playlist end. This is my code.
First I check status field in DB, if have any row status = false Then read row from DB .
I Add mp3 to playlist like thisCode:public void check() { MySqlConnection conn = null; DateTime time = DateTime.Now; string date_started = String.Format("{0:yyyy-MM-dd}", time); string time_started = String.Format("{0:HH:mm:ss}", time); try { conn = new MySqlConnection(ConnectionString); conn.Open(); MySqlDataAdapter da = new MySqlDataAdapter(); string sql = "SELECT * FROM queue_data WHERE status = 0 ORDER BY last_time ASC LIMIT 0,3 "; da.SelectCommand = new MySqlCommand(sql, conn); da.SelectCommand.ExecuteNonQuery(); DataSet dt = new DataSet(); da.Fill(dt); if (dt.Tables[0].Rows.Count > 0) { num = dt.Tables[0].Rows[0].Field<int>(1); ch = dt.Tables[0].Rows[0].Field<int>(2); ReadTH(num, ch); // Play mp3 here. } } catch (MySqlException ex) { Console.WriteLine("Error: {0}", ex.ToString()); } finally { if (conn != null) { conn.Close(); } } }
I use time check DB every 1 secound.Code:public void ReadTH(int num, int ch) { List<string> list = new List<string>(); NumberToWords n2w = new NumberToWords(); string call; //wplayerList2.clear(); call += n2w.NumberToWordTH(num.ToString()); call += "at"; call += n2w.NumberToWordTH(ch.ToString()); call += "end"; list = cleanedString.Split(' ').ToList(); foreach (string i in list) { Console.WriteLine(i); //wplayerList2.appendItem(axWindowsMediaPlayer2.newMedia("voicesTH\\" + i + ".mp3")); axVLCPlugin21.playlist.add("file:///voicesTH/" + i + ".mp3"); } axVLCPlugin21.playlist.play(); //axWindowsMediaPlayer2.currentPlaylist = wplayerList2; //axWindowsMediaPlayer2.Ctlcontrols.play(); }
In VLC I try to check end of playlist like thisCode:private void timer1_Tick(object sender, EventArgs e) { check(); }
In Windows Media Player I try to check end of playlist like thisCode:private void axVLCPlugin21_MediaPlayerEndReached(object sender, EventArgs e) { Console.Write("OK"); update(); // If playlist end then update status in DB to true }
When I run this code playlist can play only first mp3 file and quickly update all status field in DB to true. How to update DB after playlist end ?Code:private void axWindowsMediaPlayer2_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e) { if (e.newState == 8) { Console.Write("OK"); update(); // If playlist end then update status in DB to true } }


Reply With Quote
