Jump to content

GUI script .mp4 repeat command problem


Kajoe
 Share

Recommended Posts

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
Link to comment
Share on other sites

  • Replies 53
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

@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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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