VB.NET歌词同步

前端之家收集整理的这篇文章主要介绍了VB.NET歌词同步前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

代码如下:

Imports System.IO
Imports System.Threading.Thread
Public Class Form1
Dim j As Integer = 0
Dim s As Integer = 0
Dim s2 As Integer = 380
Dim so As String
Dim TT As String
Dim d1 As Integer
Dim s1 As Integer
Dim m1 As Integer
Dim hashtable As New Hashtable()
Public Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.ShowDialog()
Me.Panel2.ForeColor = Color.LightGreen
Dim s As String = OpenFileDialog1.FileName
Dim FR As FileStream
FR = New FileStream(s,FileMode.Open)
Dim SR As StreamReader
SR = New StreamReader(FR,System.Text.Encoding.Default)
Dim ST As String
Dim itms As Object
itms = SR.ReadLine()
While Not itms = Nothing
ST = itms.ToString().Substring(itms.ToString().LastIndexOf("]"))
TT = itms.ToString().Remove(itms.ToString().Length - ST.Length,ST.Length)
TT = TT.Remove(0,1)
Dim sh As String = TT.Substring(TT.LastIndexOf(":"))
TT = TT.Remove(TT.Length - sh.Length,sh.Length)

Me.ListBox1.Items.Add(TT)

Dim SS As String = itms.ToString().Substring(itms.ToString().LastIndexOf("]"))
itms = itms.ToString().Remove(0,itms.ToString().Length - SS.Length + 1)

Me.ListBox2.Items.Add(itms)

j += 1

so = so + itms & vbCrLf
Me.Label1.Text = so
Me.Label3.Text = so

itms = SR.ReadLine()
End While
SR.Close()
FR.Close()
Me.ListBox1.SetSelected(5,True)

ListBox2.SetSelected(5,True)
Timer2.Start()
End Sub
Public Function Song()

Return TT
End Function
Private Sub Button2_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button2.Click
ColorDialog1.ShowDialog()
Label1.ForeColor = ColorDialog1.Color
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Timer2.Tick
Timer1.Interval = 1
Static Ti As Integer = 0

Dim TS As String = Format(m1,"00") & ":" & Format(s1,"00")
Me.Label2.Text = TS

'If Ti = 100 Then
'Ti = 0
'Else
'Ti = Ti + 1
'End If
d1 = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition
m1 = d1 / 60 : s1 = d1 Mod 60
'Me.Label2.Text = ListBox1.SelectedItem & " " & Format(m1,"00")
If Format(m1,"00") = ListBox1.SelectedItem Then
Timer1.Start()
Label1.Text.IndexOf(ListBox2.SelectedItem).ToString().ToLower()
s -= 20
s2 -= 20
Me.Label3.SetBounds(Me.Label3.Location.X,s,Me.Label3.Width,Me.Label3.Height)
Me.Label1.SetBounds(Me.Label1.Location.X,s2,Me.Label1.Width,Me.Label1.Height)
Else

End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
Private Sub Button3_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button3.Click
OpenFileDialog1.ShowDialog()
AxWindowsMediaPlayer1.URL = OpenFileDialog1.FileName
End Sub
Private Sub Button4_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button4.Click
FontDialog1.ShowDialog()
Label1.Font = FontDialog1.Font
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Timer1.Tick
ListBox1.SelectedIndex = ListBox1.SelectedIndex + 1
Timer2.Start()
Timer3.Start()
Timer1.Stop()
End Sub
Private Sub Timer3_Tick(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Timer3.Tick
ListBox2.SelectedIndex = ListBox2.SelectedIndex + 1
Timer3.Stop()
End Sub
End Class

需要注意的是: 歌词的形式是怎样安排的

因此在你编写代码时要首先提出前面时间与歌曲当前运行的时间进行对比在往下跳一格.

猜你在找的VB相关文章