Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 如何使用MCISendString在特定文件夹中播放所有视频?_Vb.net_Video_Mcisendstring - Fatal编程技术网

Vb.net 如何使用MCISendString在特定文件夹中播放所有视频?

Vb.net 如何使用MCISendString在特定文件夹中播放所有视频?,vb.net,video,mcisendstring,Vb.net,Video,Mcisendstring,我需要一种方法,使我的所有视频文件,我与我的特定文件夹保存播放和循环播放后再次视频 我已经有了一些来自互联网上MCISendstring基本教程的代码,但是只有一个视频正在播放我的文件夹路径,我认为我的代码有问题。任何帮助都将不胜感激 到目前为止,这是我的代码: Public Class Form1 Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal _

我需要一种方法,使我的所有视频文件,我与我的特定文件夹保存播放和循环播放后再次视频

我已经有了一些来自互联网上MCISendstring基本教程的代码,但是只有一个视频正在播放我的文件夹路径,我认为我的代码有问题。任何帮助都将不胜感激

到目前为止,这是我的代码:

Public Class Form1

    Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal _
        lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As _
             Integer, ByVal hwndCallback As Integer) As Integer

    Dim filename As String = "D:\Movielist\*.*"
    Dim filename As String = "D:\Movielist\Cronos.wmv"
    Dim retVal As Integer
    Dim playing As Boolean = False

    Private Sub Panel1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel1.SizeChanged
        If playing Then
            SizeVideoWindow(Panel1.Size)
        End If
    End Sub

    Private Sub SizeVideoWindow(ByVal maxSize As Size)
        Dim ActualMovieSize As Size = getDefaultSize()
        Dim AspectRatio As Single = CSng(ActualMovieSize.Width / ActualMovieSize.Height)

        Dim iLeft As Integer = 0
        Dim iTop As Integer = 0

        Dim newWidth As Integer = maxSize.width
        Dim newHeight As Integer = CInt(newWidth \ AspectRatio)

        If newHeight > maxSize.height Then
            newHeight = maxSize.height
            newWidth = CInt(newHeight * AspectRatio)
            iLeft = (maxSize.Width - newWidth) \ 2
        Else
            iTop = (maxSize.Height - newHeight) \ 2
        End If

        mciSendString("put movie window at " & iLeft & " " & iTop & " " & newWidth & " " & newHeight, "", 0, 0)

        mciSendString("play movie repeat", "", 0, 0)

        Console.ReadLine()
    End Sub

    Public Function getDefaultSize() As Size
        Dim c_Data As String = Space(128)
        mciSendString("where movie source", c_Data, 128, 0)
        Dim parts() As String = Split(c_Data, " ")

        Return New Size(CInt(parts(2)), CInt(parts(3)))
    End Function

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        filename = Chr(34) & filename & Chr(34)
        retVal = mciSendString("open " & filename & " type mpegvideo alias movie parent " _
        & Panel1.Handle.ToInt32 & " style child", "", 0, 0)

        retVal = mciSendString("play movie", "", 0, 0)
        playing = True
        SizeVideoWindow(Panel1.Size)
    End Sub

End Class

我做了一个简单的修改来增加代码的缩进。它可能会帮助您格式化您未来的答案。感谢编辑感谢帮助Drarig29您是否忘记了控制面板1.SizeChanged部分?我已经添加了它。我刚刚在教程中得到了它,可能代码在我的机器上完美地运行。