PlayerControl.vb 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. 
  2. Imports WMPLib 'Media Player in virtual form
  3. Public Class PlayerControl
  4. Dim Player As WindowsMediaPlayer = New WindowsMediaPlayer
  5. Public Sub LoadSong(ByVal songname As String)
  6. Dim urls() As String = {songname} ' create the playlist
  7. For Each u In urls
  8. Player.URL = u
  9. Player.controls.play()
  10. Next
  11. End Sub
  12. Public Sub Pause()
  13. Player.controls.pause()
  14. End Sub
  15. Public Sub Play()
  16. Player.controls.play()
  17. End Sub
  18. Public Sub NextSong()
  19. Player.controls.next()
  20. End Sub
  21. Public Sub PreviousSong()
  22. Player.controls.previous()
  23. End Sub
  24. Public Sub StopPlaying()
  25. Player.controls.stop()
  26. End Sub
  27. Public Function GetSongName()
  28. Return Player.currentMedia.name.ToString()
  29. End Function
  30. Public Function GetCurrentPos()
  31. Return Player.controls.currentPosition.ToString
  32. End Function
  33. Public Function GetTotalDuration()
  34. On Error Resume Next
  35. Return Player.currentMedia.duration
  36. End Function
  37. Public Sub VolUp()
  38. Player.settings.volume = Player.settings.volume + 12.5
  39. End Sub
  40. Public Sub VolDown()
  41. Player.settings.volume = Player.settings.volume - 12.5
  42. End Sub
  43. Public Sub initiateVol()
  44. Player.settings.volume = My.Settings.Vol
  45. End Sub
  46. Public Function GetVol()
  47. Return Player.settings.volume.ToString()
  48. End Function
  49. Public Sub initiateLoopSetting()
  50. If My.Settings.LoopMode = "End Stop" Then
  51. ElseIf My.Settings.LoopMode = "Single Loop" Then
  52. Main.PictureBox10_Click(Nothing, Nothing)
  53. ElseIf My.Settings.LoopMode = "Playlist Loop" Then
  54. Main.PictureBox9_Click(Nothing, Nothing)
  55. End If
  56. End Sub
  57. Public Sub SetVol(ByVal num As Integer)
  58. Player.settings.volume = num
  59. End Sub
  60. Public Sub SoundFadeIn()
  61. For x As Integer = 0 To My.Settings.Vol Step 1
  62. SetVol(x)
  63. Threading.Thread.Sleep(18)
  64. Next
  65. End Sub
  66. Public Sub SoundFadeOut()
  67. For x As Integer = GetVol() To 0 Step -1
  68. SetVol(x)
  69. Threading.Thread.Sleep(20)
  70. Next
  71. End Sub
  72. Public Sub SetPos(ByVal Setto As Double)
  73. Player.controls.currentPosition = Setto
  74. End Sub
  75. End Class