Advertisement
Guest User

Untitled

a guest
Dec 7th, 2012
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Class Form1
  2. #Region "Color Settings"
  3.     Dim CurrentTrackColor As System.Drawing.Color = Color.Red
  4.     Dim PausedTrackColor As System.Drawing.Color = Color.LightYellow
  5. #End Region
  6.     Dim WithEvents Player As New WMPLib.WindowsMediaPlayer
  7.     Dim WithEvents Player2 As New WMPLib.WindowsMediaPlayer
  8.     Dim WithEvents Player3 As New WMPLib.WindowsMediaPlayer
  9.  
  10.     Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
  11.         ' Dispose of player
  12.        Player = Nothing
  13.         Player2 = Nothing
  14.         Player3 = Nothing
  15.     End Sub
  16.  
  17.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  18.         Volume1.Value = Player.settings.volume
  19.         Volume1.Value = Player2.settings.volume
  20.         Volume1.Value = Player3.settings.volume
  21.  
  22.         Player.settings.autoStart = False
  23.         Player2.settings.autoStart = False
  24.         Player3.settings.autoStart = False
  25.  
  26.         Player.URL = "rain.mp3"
  27.         Player2.URL = "fire.mp3"
  28.         Player3.URL = "jazz.mp3"
  29.  
  30.         Player.enableContextMenu = False
  31.         Player2.enableContextMenu = False
  32.         Player3.enableContextMenu = False
  33.  
  34.         With Me.Timer1
  35.             .Interval = 500
  36.             .Start()
  37.             .Enabled = True
  38.         End With
  39.     End Sub
  40.  
  41.     Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  42.         ' Form is closing, so shutdown player
  43.        Player.close()
  44.         Player2.close()
  45.         Player3.close()
  46.     End Sub
  47.  
  48.     Private Sub ScrollingVolume(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Volume1.Scroll
  49.         ' Change the player's volume
  50.        Player.settings.volume = Volume1.Value
  51.     End Sub
  52.  
  53.     Private Sub ScrollingVolume2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Volume2.Scroll
  54.         ' Change the player's volume
  55.        Player2.settings.volume = Volume2.Value
  56.     End Sub
  57.  
  58.     Private Sub ScrollingVolume3(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Volume3.Scroll
  59.         ' Change the player's volume
  60.        Player3.settings.volume = Volume3.Value
  61.     End Sub
  62.  
  63.     Private Sub Player_MediaError(ByVal pMediaObject As Object) Handles Player.MediaError
  64.         MessageBox.Show("Unrecoverable Problem. Shutting Down", "MyMusic Player")
  65.         Me.Close()
  66.     End Sub
  67.  
  68.     Private Sub Player2_MediaError(ByVal pMediaObject As Object) Handles Player2.MediaError
  69.         MessageBox.Show("Unrecoverable Problem. Shutting Down", "MyMusic Player")
  70.         Me.Close()
  71.     End Sub
  72.  
  73.     Private Sub Player3_MediaError(ByVal pMediaObject As Object) Handles Player3.MediaError
  74.         MessageBox.Show("Unrecoverable Problem. Shutting Down", "MyMusic Player")
  75.         Me.Close()
  76.     End Sub
  77.  
  78.     Private Sub Player_PlayStateChange(ByVal NewState As Integer) Handles Player.PlayStateChange
  79.         'Static Dim PlayAllowed As Boolean = True
  80.        Select Case CType(NewState, WMPLib.WMPPlayState)
  81.             Case WMPLib.WMPPlayState.wmppsReady
  82.                 'If PlayAllowed Then
  83.                Player.controls.play()
  84.                 'End If
  85.            Case WMPLib.WMPPlayState.wmppsMediaEnded
  86.                 ' Start protection (without it next wouldn't play
  87.                'PlayAllowed = False
  88.                ' Play track
  89.                Player.controls.play()
  90.                 ' End Protection
  91.                'PlayAllowed = True
  92.                updatePlayer()
  93.         End Select
  94.     End Sub
  95.  
  96.     Private Sub Player2_PlayStateChange(ByVal NewState As Integer) Handles Player2.PlayStateChange
  97.         Static Dim PlayAllowed As Boolean = True
  98.         Select Case CType(NewState, WMPLib.WMPPlayState)
  99.             Case WMPLib.WMPPlayState.wmppsReady
  100.                 If PlayAllowed Then
  101.                     Player2.controls.play()
  102.                 End If
  103.             Case WMPLib.WMPPlayState.wmppsMediaEnded
  104.                 ' Start protection (without it next wouldn't play
  105.                PlayAllowed = False
  106.                 ' Play track
  107.                Player2.controls.play()
  108.                 ' End Protection
  109.                PlayAllowed = True
  110.                 updatePlayer()
  111.         End Select
  112.     End Sub
  113.  
  114.     Private Sub Player3_PlayStateChange(ByVal NewState As Integer) Handles Player3.PlayStateChange
  115.         Static Dim PlayAllowed As Boolean = True
  116.         Select Case CType(NewState, WMPLib.WMPPlayState)
  117.             Case WMPLib.WMPPlayState.wmppsReady
  118.                 If PlayAllowed Then
  119.                     Player3.controls.play()
  120.                 End If
  121.             Case WMPLib.WMPPlayState.wmppsMediaEnded
  122.                 ' Start protection (without it next wouldn't play
  123.                PlayAllowed = False
  124.                 ' Play track
  125.                Player3.controls.play()
  126.                 ' End Protection
  127.                PlayAllowed = True
  128.                 updatePlayer()
  129.         End Select
  130.     End Sub
  131.  
  132.     Private Sub updatePlayer()
  133.         ' Set Volume slide to match current volume
  134.        Volume1.Value = Player.settings.volume
  135.         Volume2.Value = Player2.settings.volume
  136.         Volume3.Value = Player3.settings.volume
  137.     End Sub
  138.  
  139.     Private Sub UpdatePlayerTimer(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  140.         updatePlayer()
  141.     End Sub
  142.  
  143. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement