Flackerndes Video im Windows Media Player in VBA
12.02.2024 10:08:13
DesManX
ich habe folgendes Problem. Ich habe in eine UserForm in einen Frame einen WindowsMediaPlayer-Steuerelement eingebettet. Der Player soll sich beim Abspielen der Videos an die Größe des Frames orientieren. In einem größerem Frame (Height 504 Width 852) klappt das wunderbar. In dem kleineren Frame (Height 240 Width 400) hingegen flackert das Video zu Beginn stark, fährt aus allen Richtungen ins Bild und bleibt am Ende ca. 15-20% der Breite nach rechts versetzt stehen und spielt das Video ab.
Hat jemand eine Idee wie man das beheben könnte?
Anbei noch der Code mit dem ich das Video starte (PS: Der Code geht noch weiter, deswegen fehlt am Ende ein End if):
If PVAT_UI.Player1.Value = True Then
If Worksheets("Marker_DB").Cells(2, 2).Value > 0 Then
If PVAT_UI.Zoom.Value = True Then
Dim sourcemediaplayer As WindowsMediaPlayer
Dim targetMediaPlayer As WindowsMediaPlayer
Debug.Print "Zoom: " & PVAT_UI.Zoom.Value
Debug.Print "Player: " & PVAT_UI.Player1.Value
PVAT_UI.WindowsMediaPlayer1.Controls.currentPosition = Worksheets("Marker_DB").Cells(2, 2).Value
PVAT_UI.WindowsMediaPlayer5.Controls.currentPosition = Worksheets("Marker_DB").Cells(2, 2).Value
Set sourcemediaplayer = PVAT_UI.WindowsMediaPlayer1
Set targetMediaPlayer = PVAT_UI.WindowsMediaPlayer5
If Not sourcemediaplayer Is Nothing Then
targetMediaPlayer.Url = sourcemediaplayer.currentMedia.SourceUrl
Else
MsgBox "No Video available for Player 1"
End If
PVAT_UI.FrameZoom.Visible = True
PVAT_UI.WindowsMediaPlayer5.Width = PVAT_UI.FrameZoom.Width
PVAT_UI.WindowsMediaPlayer5.Height = PVAT_UI.FrameZoom.Height
PVAT_UI.WindowsMediaPlayer5.Visible = True
PVAT_UI.WindowsMediaPlayer1.Visible = False
PVAT_UI.WindowsMediaPlayer2.Visible = False
PVAT_UI.WindowsMediaPlayer3.Visible = False
PVAT_UI.WindowsMediaPlayer4.Visible = False
PVAT_UI.Frame_Player1.Visible = False
PVAT_UI.Frame_Player2.Visible = False
PVAT_UI.Frame_Player3.Visible = False
PVAT_UI.Frame_Player4.Visible = False
PVAT_UI.WindowsMediaPlayer5.Width = PVAT_UI.FrameZoom.Width
PVAT_UI.WindowsMediaPlayer5.Height = PVAT_UI.FrameZoom.Height
PVAT_UI.WindowsMediaPlayer5.Top = 0
PVAT_UI.WindowsMediaPlayer5.Left = 0
PVAT_UI.TextBox_Marker_t0_1.Value = Worksheets("Marker_DB").Cells(2, 2).Value
PVAT_UI.TextBox_Player_t0_1.Value = Worksheets("Marker_DB").Cells(2, 8).Value
PVAT_UI.TextBox_Marker_t0_1.Locked = True
PVAT_UI.TextBox_Player_t0_1.Locked = True
PVAT_UI.WindowsMediaPlayer1.Visible = False
PVAT_UI.WindowsMediaPlayer2.Controls.stop
PVAT_UI.WindowsMediaPlayer2.Visible = False
PVAT_UI.WindowsMediaPlayer3.Controls.stop
PVAT_UI.WindowsMediaPlayer3.Visible = False
PVAT_UI.WindowsMediaPlayer4.Controls.stop
PVAT_UI.WindowsMediaPlayer4.Visible = False
PVAT_UI.WindowsMediaPlayer1.Controls.Play
PVAT_UI.WindowsMediaPlayer1.Controls.pause
PVAT_UI.WindowsMediaPlayer2.Visible = False
PVAT_UI.WindowsMediaPlayer3.Visible = False
PVAT_UI.WindowsMediaPlayer4.Visible = False
PVAT_UI.WindowsMediaPlayer5.stretchToFit = True
PVAT_UI.WindowsMediaPlayer5.Controls.Play
ElseIf PVAT_UI.Zoom.Value = False Then
PVAT_UI.WindowsMediaPlayer1.Controls.currentPosition = Worksheets("Marker_DB").Cells(2, 2).Value
PVAT_UI.WindowsMediaPlayer5.Visible = False
PVAT_UI.TextBox_Marker_t0_1.Value = Worksheets("Marker_DB").Cells(2, 2).Value
PVAT_UI.TextBox_Player_t0_1.Value = Worksheets("Marker_DB").Cells(2, 8).Value
PVAT_UI.TextBox_Marker_t0_1.Locked = True
PVAT_UI.TextBox_Player_t0_1.Locked = True
PVAT_UI.WindowsMediaPlayer1.Visible = True
PVAT_UI.WindowsMediaPlayer2.Controls.stop
PVAT_UI.WindowsMediaPlayer2.Visible = True
PVAT_UI.WindowsMediaPlayer3.Controls.stop
PVAT_UI.WindowsMediaPlayer3.Visible = True
PVAT_UI.WindowsMediaPlayer4.Controls.stop
PVAT_UI.WindowsMediaPlayer4.Visible = True
PVAT_UI.WindowsMediaPlayer1.Height = PVAT_UI.Frame_Player1.Height
PVAT_UI.WindowsMediaPlayer1.Width = PVAT_UI.Frame_Player1.Width
PVAT_UI.WindowsMediaPlayer1.Controls.Play
PVAT_UI.WindowsMediaPlayer1.Controls.pause
PVAT_UI.WindowsMediaPlayer2.Visible = True
PVAT_UI.WindowsMediaPlayer3.Visible = True
PVAT_UI.WindowsMediaPlayer4.Visible = True
PVAT_UI.WindowsMediaPlayer1.Height = PVAT_UI.Frame_Player1.Height
PVAT_UI.WindowsMediaPlayer1.Width = PVAT_UI.Frame_Player1.Width
PVAT_UI.WindowsMediaPlayer1.Left = 0
PVAT_UI.WindowsMediaPlayer1.Top = 0
PVAT_UI.WindowsMediaPlayer1.stretchToFit = True
PVAT_UI.WindowsMediaPlayer1.Controls.Play
Else
MsgBox "No Video available for Player 1"
End If
Vielen Dank schonmal!