ultrastar-songpicker/UltraStarSongPicker/ctrlAudioVideoPlayer.vb
2023-11-23 19:34:52 +01:00

77 lines
2.2 KiB
VB.net

Imports System.IO
Imports AxWMPLib
Friend Class AudioVideoPlayer
Private Sub AudioVideoPlayer_Load(sender As Object, e As EventArgs) Handles Me.Load
lblSongArtist.Text = Nothing
lblSongTitle.Text = Nothing
If DesignMode = False Then
axVideo.uiMode = "none"
axVideo.settings.volume = 0
End If
End Sub
Private Sub axAudio_PlayStateChange(sender As Object, e As _WMPOCXEvents_PlayStateChangeEvent) Handles axAudio.PlayStateChange
With axVideo.Ctlcontrols
Select Case e.newState
Case 0 ' Undefined
Case 1 ' Stopped
.stop()
Case 2 ' Paused
.pause()
Case 3 ' Playing
.play()
Case 4 ' ScanForward
.currentPosition = axAudio.Ctlcontrols.currentPosition
Case 5 ' ScanReverse
.currentPosition = axAudio.Ctlcontrols.currentPosition
Case 6 ' Buffering
.pause()
Case 7 ' Waiting
.pause()
Case 8 ' MediaEnded
.stop()
Case 9 ' Transitioning
Case 10 ' Ready
Case 11 ' Reconnecting
Case 12 ' Last
Case Else
End Select
End With
End Sub
Private Sub axMediaPlayer_PositionChange(sender As Object, e As _WMPOCXEvents_PositionChangeEvent) Handles axAudio.PositionChange
axVideo.Ctlcontrols.currentPosition = axAudio.Ctlcontrols.currentPosition
End Sub
Friend Sub Play(song As Song)
If File.Exists(song.Videofile) Then
axVideo.URL = song.Videofile
axAudio.URL = song.Songfile
ElseIf File.Exists(song.Songfile) Then
axVideo.URL = Nothing
axAudio.URL = song.Songfile
Else
Exit Sub
End If
lblSongArtist.Text = song.Artist
lblSongTitle.Text = song.Title
axAudio.Ctlcontrols.currentPosition = song.Previewstart
End Sub
Friend Sub [Stop]()
axVideo.URL = Nothing
axAudio.URL = Nothing
End Sub
End Class