Jump to content

Recommended Posts

Posted (edited)

Dear Forum;

I have been searching for days to make a good working GUI script with .mp4 file. But I want the .mp4 file to repeat in a loop. mp4 plays in screen, but after mp4 is finished, it is not repeating. I want to repeat it during the whole script. I searched and searched, but can't find an option for repeating. I think the wmp player needs a repeat input during use of script, but Windows does not have that command line for it. 

Another problem is starting the script. When script starts you see shortly a black empty background before video in GU starts to play. Is there an option to start withoiut the background startingscreen from wmp? My script is attached.

By the way, I tried folowing script link too, Video plays good but does not repeat the mp4 too. 

 

Thanks for your help.

Kajoe

AutoitRepeat problem.rar

Edited by Kajoe
  • Replies 53
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Posted

The best working mp4 script I have is the one attached below. I used the template from Belini above. In this I only need the repeat function for GUI mp4. Thank you very much.

The same test video is used as in example above.

Test UDF GUI forum .au3

Posted (edited)

@Kajoe, you need to take the length of the video and put it in a loop to repeat when the run time is longer than the time of your video

#include <Sound.au3>
Global $count = 0

$aSound = _SoundOpen(@ScriptDir & "\Voorbeeld.mp4")
$time = _SoundLength($aSound, 2)
_SoundPlay($aSound)
$count = TimerInit()

HotKeySet("{esc}", "quit")

While 1
    Sleep(10)
    If TimerDiff($count) > $time Then
        _SoundPlay($aSound)
        $count = TimerInit()
    EndIf
WEnd

Func quit()
    Exit
EndFunc   ;==>quit

 

Edited by Belini
Posted (edited)

Hi Belini. Thank you very much for very quick reply.

Do you mean that I have to calculate the time of the Voorbeeld.mp4 file? And put that in a loop? How do I put it in a loop. I tried to add 

' <param name=".settings.setMode("Loop", True)", but that gives fault message

By the way, I do not have sound in video. Only video

 

Best regards, Kajoe

 

Edited by Kajoe
Posted (edited)

just use while 1 for infinite loop

#include <GUIConstants.au3>
#include <Sound.au3>
#include <wmp.au3>

Opt ("GUIOnEventMode", 1)

$ Form1 = GUICreate ("AForm1", 518, 439, 192, 125)
GUISetOnEvent ($ GUI_EVENT_CLOSE, "quit")
$ wmp = _wmpcreate (1, 8, 8, 425, 425); cria objeto
_wmpvalue ($ wmp, "nocontrols"); oculta os controles
GUISetState (@SW_SHOW)

$ aSound = _SoundOpen (@ScriptDir & "\ Voorbeeld.mp4")
$ time = _SoundLength ($ aSound, 2)
$ count = TimerInit ()

_wmploadmedia ($ wmp, @ScriptDir & "\ Voorbeeld.mp4"); carrega mídia

HotKeySet ("{esc}", "quit")

Enquanto 1; Loop infinito
    Sono (10)
    If TimerDiff ($ count)> $ time Then
        _wmploadmedia ($ wmp, @ScriptDir & "\ Voorbeeld.mp4"); carrega mídia
        $ count = TimerInit ()
        MsgBox (4096, '', $ aSound)
    Fim se
Aplique

Func quit ()
    Saída
EndFunc

you can use the video.au3 udf also which i consider to be the best

Edited by Belini
Posted (edited)

Dear Belini;

with   apenas use while 1 para loop infinito file above I got lots of errors in script. And when I look at that script it is for GUI to leave GUI open until time inintiated. Isn't it? That wat not what I ment in my question. GUI screen works perfectly with the script I have attaced, but mp4 is only 10 seconds long. And I want to repeat the voorbeeld.mp4 untill gui screen stopt by initiated script. 

So I need to replay "voorbeeld.mp4) constantly in GUI, until GUI screen closes automaticly by script.

Edited by Kajoe
Posted

Another example using UDF video.au3 without using a timer and without putting it in the loop

#include "video.au3"

Global $idS, $count

Example()

HotKeySet("{esc}", "quit")

While 1
    Sleep(1000)
    $count += 1
    If $count = 30 Then ExitLoop
WEnd

quit()

Func Example()
    Local $time, $gui
    $gui = GUICreate("Example", 600, 200, -1, -1)
    GUISetState(@SW_SHOW)
    $idS = _Video_Open(@ScriptDir & "\" & "Voorbeeld.mp4", $gui, 0, 0, 600, 200)
    $time = _Video_Length($idS, 1)
    _Video_Play($idS)
    AdlibRegister("Repeat", $time)
EndFunc   ;==>Example

Func Repeat()
    _Video_Seek($idS, 0)
    _Video_Play($idS)
EndFunc   ;==>Repeat

Func quit()
    _Video_Close($idS)
    AdlibUnRegister("Repeat")
    Exit
EndFunc   ;==>quit

 

Posted

I forgot to put $ WS_CLIPCHILDREN in creating the Gui

#include <WindowsConstants.au3>
#include "video.au3"

Global $idS, $count

Example()

HotKeySet("{esc}", "quit")

While 1
    Sleep(1000)
    $count += 1
    If $count = 30 Then ExitLoop
WEnd

quit()

Func Example()
    Local $time, $gui
    $gui = GUICreate("Example", 600, 200, -1, -1, $WS_CLIPCHILDREN)
    GUISetState(@SW_SHOW)
    $idS = _Video_Open(@ScriptDir & "\" & "Voorbeeld.mp4", $gui, 0, 0, 600, 200)
    $time = _Video_Length($idS, 1)
    _Video_Play($idS)
    AdlibRegister("Repeat", $time)
EndFunc   ;==>Example

Func Repeat()
    _Video_Seek($idS, 0)
    _Video_Play($idS)
EndFunc   ;==>Repeat

Func quit()
    _Video_Close($idS)
    AdlibUnRegister("Repeat")
    Exit
EndFunc   ;==>quit

 

Posted (edited)
Quote

Hi Belini. Stil the same. No video. Did you test it with the example mp4 I had attached?

yes I tested it with the video you posted

#include <WindowsConstants.au3>
#include "video.au3"

Global $idS, $count, $number = 1; Make tests from 1 to 7

Example()

HotKeySet("{esc}", "quit")

While 1
    Sleep(1000)
    $count += 1
    If $count = 30 Then ExitLoop
WEnd

quit()

Func Example()
    Local $time, $gui
    $gui = GUICreate("Example", 600, 200, -1, -1, $WS_CLIPCHILDREN)
    GUISetState(@SW_SHOW)
    $idS = _Video_Open(@ScriptDir & "\" & "Voorbeeld.mp4", $gui, 0, 0, 600, 200)
    $time = _Video_Length($idS, 1)
    _Video_execute($idS, 0, $number)
    AdlibRegister("Repeat", $time)
EndFunc   ;==>Example

Func Repeat()
    _Video_Seek($idS, 0)
    _Video_execute($idS, 0, $number)
EndFunc   ;==>Repeat

Func _Video_execute($string = '', $mod = 0, $opt = 1)
    If $mod = 1 Then
        $string = "play " & $string & " fullscreen"
    Else
        $string = "play " & $string
    EndIf

    Switch $opt
        Case 1
            DllCall("C:\WINDOWS\system32\winmm.dll", 'long', 'mciSendString', 'str', $string, 'str', '', 'int', 0, 'ptr', 0); mciSendString
        Case 2
            DllCall("C:\WINDOWS\system32\winmm.dll", "int", "mciSendString", "str", $string, "str", "", "long", 0, "long", 0); mciSendString
        Case 3
            DllCall("C:\WINDOWS\system32\winmm.dll", "int", "mciSendString", "str", $string, "str", "", "int", 0, "hwnd", 0); mciSendString 
        Case 4
            DllCall("C:\WINDOWS\system32\winmm.dll", 'long', 'mciSendStringA', 'str', $string, 'str', '', 'int', 0, 'ptr', 0); mciSendStringA
        Case 5
            DllCall("C:\WINDOWS\system32\winmm.dll", "int", "mciSendStringA", "str", $string, "str", "", "long", 0, "long", 0); mciSendStringA          
        Case 6          
            DllCall("C:\WINDOWS\system32\winmm.dll", "dword", "mciSendStringW", "wstr", $string, "wstr", "", "uint", 0, "ptr", 0); mciSendStringW
        Case 7
            DllCall("C:\WINDOWS\system32\winmm.dll", "int", "mciSendStringW", "wstr", $string, "wstr", "", "long", 0, "long", 0); mciSendStringW
    EndSwitch
EndFunc   ;==>_Video_execute

Func quit()
    _Video_Close($idS)
    AdlibUnRegister("Repeat")
    Exit
EndFunc   ;==>quit

do tests by changing the number from 1 to 7, one of them should work for you

Edited by Belini
Posted

With new script still no video. Maybe the Windows standard winm.dll is not good working for this script. And I tried to replace it with the one that you had posted in other thread, but windows does not allow to change the dll file.

Posted (edited)

Here on my windows 7 _Video_Length () returns 9984 ms and _Video_play() opens with image, try with the change I made in _mciSendString()

https://mega.nz/file/4EsiFRpY#UHFmL-OqM046KjILvUo9gCIqkXATiVD__3mcrC-IvVk

Edited by Belini
Posted

change the Example() function and post what was written by consolewrite()

Func Example()
    Local $time, $gui
    $gui = GUICreate("Example", 600, 200, -1, -1, $WS_CLIPCHILDREN)
    GUISetState(@SW_SHOW)
    $idS = _Video_Open(@ScriptDir & "\" & "Voorbeeld.mp4", $gui, 0, 0, 600, 200)
    ConsoleWrite('Id = ' & $idS & @crlf)
    $time = _Video_Length($idS, 1)
    ;MsgBox(4096, 'Time', $idS)
    ConsoleWrite('Time = ' & $time & ' ms' & @crlf)
    _Video_play($idS)
    AdlibRegister("Repeat", $time)
EndFunc   ;==>Example

 

Posted

+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
Id = ylsplduaic
Time =  ms
+>20:40:21 AutoIt3.exe ended.rc:0
+>20:40:21 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 31.44
 

Posted (edited)

there can only be some problem with winm.dll on windows 10 because it works well on windows 7 and windows xp then you need to find another way to play videos without using winm.dll

 

Func Example()
    Local $time, $gui
    $gui = GUICreate("Example", 600, 200, -1, -1, $WS_CLIPCHILDREN)
    GUISetState(@SW_SHOW)
    $idS = _Video_Open(@ScriptDir & "\" & "Voorbeeld.mp4", $gui, 0, 0, 600, 200)
    ConsoleWrite('Id = ' & $idS & @crlf)
    $time = _Video_Length($idS, 1)
    ;MsgBox(4096, 'Time', $idS)
    ConsoleWrite('Time = ' & $time & ' ms' & @crlf)
    _Video_play($idS)
    if Number($time) = 0 then $time = 9984
    AdlibRegister("Repeat", $time)
EndFunc   ;==>Example

try like this to see if at least open the video

Edited by Belini
Posted

I am going to try to copy your winm.dll on my windows 10 and test again. Than it is shure that this dll is the problem. Thank you very much for support. I really apreaciate it. 

Best regards, Kajoe

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...