如何让 directx 媒体播放器在 vb.net 中连续循环播放一个或多个视频?当我尝试时出现错误
错误:
mscorlib.dll 中出现“System.ArgumentOutOfRangeException”类型的未处理异常
附加信息:索引超出范围。必须是非负数且小于集合的大小。
到目前为止,这是我的代码:
Imports Microsoft.DirectX
Imports Microsoft.DirectX.AudioVideoPlayback
Imports System.Text.RegularExpressions
Imports System.Net
Imports System.IO
Public Class Form1
Dim PlayorPause As Integer = 0
Dim MovieN As Integer = 0
Dim NowPlaying As List(Of String) = New List(Of String)
Friend WithEvents videoFile As Video
Sub Pause()
If PlayorPause = 0 Then
videoFile.Play()
PlayorPause = 1
Else
videoFile.Pause()
PlayorPause = 0
End If
End Sub
Sub Nextvid()
videoFile.Dispose()
Dim WindowSize As Size = Panel1.Size
If MovieN > NowPlaying.Count - 1 Then
MovieN = 0
Nextvid()
Else
videoFile = New Video(NowPlaying(MovieN))
videoFile.Owner = Panel1
Panel1.Size = WindowSize
videoFile.Play()
End If
End Sub
Private Sub Video_End(ByVal sender As Object, ByVal e As EventArgs) Handles videoFile.Ending
Dim WindowSize As Size = Panel1.Size
If MovieN > NowPlaying.Count Then
MovieN = 0
Else
Dim CurrenN As Integer = MovieN - 1
MovieN = MovieN + 1
videoFile = New Video(NowPlaying(MovieN))
End If
videoFile.Owner = Panel1
Panel1.Size = WindowSize
videoFile.Play()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
NowPlaying.Add(" C:\Users\Adminx\Downloads\ShortestVid.avi")
Dim WindowSize As Size = Panel1.Size
videoFile = New Video(NowPlaying(0))
videoFile.Owner = Panel1
Panel1.Size = WindowSize
Me.KeyPreview = True
Me.MinimumSize = New Size(319, 444)
Me.Size = Me.MinimumSize
Me.DoubleBuffered = True
End Sub
Sub NextPress()
MovieN = MovieN + 1
Nextvid()
End Sub
Sub PrePress()
MovieN = MovieN - 1
Nextvid()
End Sub
Sub Watchbtn()
Me.MinimumSize = New Size(660, 444)
Panel1.Visible = True
Panel1.Focus()
End Sub
End Class