Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- #Region "Color Settings"
- Dim CurrentTrackColor As System.Drawing.Color = Color.Red
- Dim PausedTrackColor As System.Drawing.Color = Color.LightYellow
- #End Region
- Dim WithEvents Player As New WMPLib.WindowsMediaPlayer
- Dim WithEvents Player2 As New WMPLib.WindowsMediaPlayer
- Dim WithEvents Player3 As New WMPLib.WindowsMediaPlayer
- Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
- ' Dispose of player
- Player = Nothing
- Player2 = Nothing
- Player3 = Nothing
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Volume1.Value = Player.settings.volume
- Volume1.Value = Player2.settings.volume
- Volume1.Value = Player3.settings.volume
- Player.settings.autoStart = False
- Player2.settings.autoStart = False
- Player3.settings.autoStart = False
- Player.URL = "rain.mp3"
- Player2.URL = "fire.mp3"
- Player3.URL = "jazz.mp3"
- Player.enableContextMenu = False
- Player2.enableContextMenu = False
- Player3.enableContextMenu = False
- With Me.Timer1
- .Interval = 500
- .Start()
- .Enabled = True
- End With
- End Sub
- Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
- ' Form is closing, so shutdown player
- Player.close()
- Player2.close()
- Player3.close()
- End Sub
- Private Sub ScrollingVolume(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Volume1.Scroll
- ' Change the player's volume
- Player.settings.volume = Volume1.Value
- End Sub
- Private Sub ScrollingVolume2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Volume2.Scroll
- ' Change the player's volume
- Player2.settings.volume = Volume2.Value
- End Sub
- Private Sub ScrollingVolume3(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Volume3.Scroll
- ' Change the player's volume
- Player3.settings.volume = Volume3.Value
- End Sub
- Private Sub Player_MediaError(ByVal pMediaObject As Object) Handles Player.MediaError
- MessageBox.Show("Unrecoverable Problem. Shutting Down", "MyMusic Player")
- Me.Close()
- End Sub
- Private Sub Player2_MediaError(ByVal pMediaObject As Object) Handles Player2.MediaError
- MessageBox.Show("Unrecoverable Problem. Shutting Down", "MyMusic Player")
- Me.Close()
- End Sub
- Private Sub Player3_MediaError(ByVal pMediaObject As Object) Handles Player3.MediaError
- MessageBox.Show("Unrecoverable Problem. Shutting Down", "MyMusic Player")
- Me.Close()
- End Sub
- Private Sub Player_PlayStateChange(ByVal NewState As Integer) Handles Player.PlayStateChange
- 'Static Dim PlayAllowed As Boolean = True
- Select Case CType(NewState, WMPLib.WMPPlayState)
- Case WMPLib.WMPPlayState.wmppsReady
- 'If PlayAllowed Then
- Player.controls.play()
- 'End If
- Case WMPLib.WMPPlayState.wmppsMediaEnded
- ' Start protection (without it next wouldn't play
- 'PlayAllowed = False
- ' Play track
- Player.controls.play()
- ' End Protection
- 'PlayAllowed = True
- updatePlayer()
- End Select
- End Sub
- Private Sub Player2_PlayStateChange(ByVal NewState As Integer) Handles Player2.PlayStateChange
- Static Dim PlayAllowed As Boolean = True
- Select Case CType(NewState, WMPLib.WMPPlayState)
- Case WMPLib.WMPPlayState.wmppsReady
- If PlayAllowed Then
- Player2.controls.play()
- End If
- Case WMPLib.WMPPlayState.wmppsMediaEnded
- ' Start protection (without it next wouldn't play
- PlayAllowed = False
- ' Play track
- Player2.controls.play()
- ' End Protection
- PlayAllowed = True
- updatePlayer()
- End Select
- End Sub
- Private Sub Player3_PlayStateChange(ByVal NewState As Integer) Handles Player3.PlayStateChange
- Static Dim PlayAllowed As Boolean = True
- Select Case CType(NewState, WMPLib.WMPPlayState)
- Case WMPLib.WMPPlayState.wmppsReady
- If PlayAllowed Then
- Player3.controls.play()
- End If
- Case WMPLib.WMPPlayState.wmppsMediaEnded
- ' Start protection (without it next wouldn't play
- PlayAllowed = False
- ' Play track
- Player3.controls.play()
- ' End Protection
- PlayAllowed = True
- updatePlayer()
- End Select
- End Sub
- Private Sub updatePlayer()
- ' Set Volume slide to match current volume
- Volume1.Value = Player.settings.volume
- Volume2.Value = Player2.settings.volume
- Volume3.Value = Player3.settings.volume
- End Sub
- Private Sub UpdatePlayerTimer(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- updatePlayer()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement