1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
Public Class Form1
Dim mouseOffset As Point
Dim commandfile As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AxWindowsMediaPlayer1.settings.volume = My.Settings.LastVolume 'Loads the last volume value
Pot1.Value = My.Settings.LastVolume
'commandfile = Command$() 'gets the file
If Not commandfile = "" Then
commandfile = Replace(commandfile, Chr(34), "")
AxWindowsMediaPlayer1.URL = commandfile 'Sets the title
My.Settings.LastSongPlayed = commandfile 'Save the media location in settings
AxWindowsMediaPlayer1.Ctlcontrols.play() 'Play the media
Timer1.Start() 'starts the timer
Else
If Not My.Settings.LastSongPlayed = "" Then
AxWindowsMediaPlayer1.URL = My.Settings.LastSongPlayed 'Load the last song
AxWindowsMediaPlayer1.Ctlcontrols.currentPosition = My.Settings.LastSongDuration 'Play the song from the last time
AxWindowsMediaPlayer1.Ctlcontrols.play() 'This will play the media
Timer1.Start() 'this timer updates the duration or progress of the song played
Else
OpenFileDialog1.ShowDialog() 'Show the media to play of theres no song
AxWindowsMediaPlayer1.URL = OpenFileDialog1.FileName 'Sets the selected file in widows mediua player
AxWindowsMediaPlayer1.Ctlcontrols.play() 'Plays the file
Timer1.Start() 'Starts the timer
End If
End If
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)
End Sub
Private Sub Settings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SettingsB.Click
Settings.Show()
End Sub
Dim paths As String()
Dim filename As String()
Private Sub AddSong_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddSong.Click
If (OpenFileDialog1.ShowDialog = DialogResult.OK) Then
filename = OpenFileDialog1.SafeFileNames
paths = OpenFileDialog1.FileNames
For i As Integer = 0 To filename.Length - 1
ListBox1.Items.Add(filename(i))
Next
End If
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
AxWindowsMediaPlayer1.URL = paths(ListBox1.SelectedIndex)
End Sub
#Region "Moving Form By Mouse"
Private Sub Me_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown
mouseOffset = New Point(-e.X, -e.Y)
End Sub
Private Sub Me_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove
If e.Button = MouseButtons.Left Then
Dim mousePos = Control.MousePosition
mousePos.Offset(mouseOffset.X, mouseOffset.Y)
Location = mousePos
End If
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPlaying Then
Button1.Text = "Play"
AxWindowsMediaPlayer1.Ctlcontrols.pause()
Else
Button1.Text = "Pause"
AxWindowsMediaPlayer1.Ctlcontrols.play()
End If
End Sub
Private Sub Stop1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Stop1.Click
AxWindowsMediaPlayer1.Ctlcontrols.stop() 'For stop button
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Forward.Click
AxWindowsMediaPlayer1.Ctlcontrols.fastForward() 'For Forward button
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Rewind.Click
AxWindowsMediaPlayer1.Ctlcontrols.fastReverse() 'For reverse button
End Sub
Private Sub Pot1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Pot1.ValueChanged
Pot1.BackColor = Color.DimGray 'Changes the backcolor if muted
AxWindowsMediaPlayer1.settings.volume = Pot1.Value 'Sets the volume value in the axwmp
My.Settings.LastVolume = Pot1.Value 'Saves the volume in the settings
End Sub
Private Sub Pot1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
GTrackBar1.MaxValue = AxWindowsMediaPlayer1.currentMedia.duration 'Sets the max value for the trackbar for each media
GTrackBar1.Value = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition 'sets the current position in the trackbar
If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPlaying Then 'check
Button1.Text = "Pause"
Else
Button1.Text = "Play"
End If
End Sub
Private Sub GTrackBar1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GTrackBar1.MouseDown
Timer1.Stop()
End Sub
Private Sub GTrackBar1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GTrackBar1.MouseUp
AxWindowsMediaPlayer1.Ctlcontrols.currentPosition = GTrackBar1.Value
Timer1.Start()
End Sub
Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
My.Settings.LastSongPlayed = AxWindowsMediaPlayer1.URL
My.Settings.LastSongDuration = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition
My.Settings.LastVolume = AxWindowsMediaPlayer1.settings.volume
End Sub
Private Sub Pot1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Pot1.DoubleClick
If AxWindowsMediaPlayer1.settings.mute = False Then
Pot1.BackColor = Color.Red
AxWindowsMediaPlayer1.settings.mute = True
Else
Pot1.BackColor = Color.DimGray
AxWindowsMediaPlayer1.settings.mute = False
End If
End Sub
Private Sub More_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles More.Click
If SettingsB.Visible = False Then
SettingsB.Visible = True
Else
SettingsB.Visible = False
End If
End Sub
End Class |
Partager