VBnet音乐播放器加定时插播
软件运行后的主界面 源码如下:使用的是 AxWindowsMediaPlayer控件,定时器实现定时插播。 Imports System.IO Imports System.IO.Directory Imports System.Xml Public Class 1 #Region “变量定义“ Public chabo_on As Integer Public chabo_lasttime As Integer Public task_lasttime As Integer Public path1$ = Application.StartupPath + “/list1.txt“ Public path2$ = Application.StartupPath + “/list2.txt“ Public path3$ = Application.StartupPath + “/setting.txt“ Public path4$ = Application.StartupPath + “/setting1.txt“ Public mXmlDoc = New System.Xml.XmlDocument Public path As String #End Region #Region “自定义函数“ #Region “ini文件操作“ Public Function ReadXML(ByVal node_name As String) As Long Try Dim mXmlNode As System.Xml.XmlNode = mXmlDoc.SelectSingleNode(“//config“) Dim xmlNode As System.Xml.XmlNode = mXmlNode.SelectSingleNode(node_name) ReadXML = Val(xmlNode.InnerText.ToString) Catch ex As Exception MsgBox(“参数读取失败!“) ReadXML = 0 End Try End Function Sub WriteXML(ByVal node_name As String, ByVal node_value As String) Try Dim mXmlNode As System.Xml.XmlNode = mXmlDoc.SelectSingleNode(“//config“) Dim xmlNode As System.Xml.XmlNode = mXmlNode.SelectSingleNode(node_name) xmlNode.InnerText = node_value mXmlDoc.Save(Path) Catch ex As Exception MsgBox(“参数保存失败!“) MsgBox(ex.ToString) End Try End Sub Sub SetupXML_read() NT3.Text = ReadXML(“pre_time“) NT1.Text = ReadXML(“show_time“) NT2.Text = ReadXML(“hide_time“) NT4.Text = ReadXML(“run_time“) NT5.Text = ReadXML(“run_loop“) 激光发射间隔.NT3.Text = ReadXML(“shoot_time“) End Sub Sub SetupXML_write() WriteXML(“pre_time“, NT3.Text) WriteXML(“show_time“, NT1.Text) WriteXML(“hide_time“, NT2.Text) WriteXML(“run_time“, NT4.Text) WriteXML(“run_loop“, NT5.Text) WriteXML(“shoot_time“, 激光发射间隔.NT3.Text) End Sub #End Region Public music_path As String 设置所有文本控件的背景色 Private Sub Set_lable_BackColor() Dim ct As Control For Each ct In Me.Controls If (TypeOf ct Is Label) Then ct.BackColor = System.Drawing.Color.Transparent ct.ForeColor = Color.White End If Next PictureBox3.BackColor = System.Drawing.Color.Transparent End Sub Private Sub txt_hh(ByVal label_Length As Integer, ByVal label_txt As String) Dim MaxLen As Integer = label_Length Dim MyLen As Integer = 10 你定义每行最多的字数 Dim NewStr As String = ““ For i As Integer = 1 To MaxLen Step MyLen NewStr = NewStr & Mid(label_txt, i, MyLen) & ““ Next Label1.Text = NewStr End Sub Private Sub chabo(ByVal task_hour As Integer, ByVal task_minute As Integer, ByVal task_second As Integer, ByVal task_play_name As String) If (task_hour = DateTime.Now.Hour) And (task_minute = DateTime.Now.Minute) And (task_second = DateTime.Now.Second) Then If task_lasttime 0 Then chabo_on = 1 chabo_lasttime = task_lasttime * 2 AxWindowsMediaPlayer1.Ctlcontrols.stop() AxWindowsMediaPlayer1.URL = task_play_name AxWindowsMediaPlayer1.Ctlcontrols.play() End If End If End Sub #End Region PrivatAxWindowsMediaPlayer1.URL = ListBox1.SelectedItem.ToStringe Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.Se