I'm trying to get a number of frames from video using windows media player control. It was placed on Panel control.
Public Class Form1
Private b As New System.Drawing.Bitmap(160, 120)
Private rct As New Rectangle(0, 0, 160, 120)
Private pb As PictureBox
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
wm.URL = TextBox1.Text
wm.Ctlcontrols.play()
End Sub
Private Sub wm_OpenStateChange(sender As Object, e As AxWMPLib._WMPOCXEvents_OpenStateChangeEvent) Handles wm.OpenStateChange
If e.newState = 13 And wm.playState = 3 Then
Dim g As Graphics = Graphics.FromImage(b)
g.CopyFromScreen(PointToScreen(Panel1.Location), New Drawing.Point(0, 0), b.Size, CopyPixelOperation.SourceCopy)
pb = New PictureBox With {.Width = 160, .Height = 120, .Image = b}
FlowLayoutPanel1.Controls.Add(pb)
Try
While True
wm.Ctlcontrols.currentPosition += 20
Application.DoEvents()
If wm.Ctlcontrols.currentPosition > wm.currentMedia.duration - 20 Then
Exit Sub
End If
b = New Bitmap(160, 120)
g = Graphics.FromImage(b)
g.CopyFromScreen(PointToScreen(Panel1.Location), New Drawing.Point(0, 0), b.Size, CopyPixelOperation.SourceCopy)
pb = New PictureBox With {.Width = 160, .Height = 120, .Image = b}
FlowLayoutPanel1.Controls.Add(pb)
End While
Catch ex As Exception
End Try
End If
End Sub
End Class
As a result I want to get a number of frames in FlowLayoutPanel Control. But there are some 'Black Boxes' (repeated first frame). Any ideas?.. How can I make WMP to Update it's position and layout? My imagine is over.