Jump to content

Play Divx.avi Fullscreen And Get Lenght Of Avi File


Recommended Posts

salute again...

just want to know if it is possible to let the script check the lenght of an .avi file on the hd so that i can pause the script exactly to the time a video is running in mediaplayer?..

..i want to let the script start mediaplayer with a give file, let player play file in fullscreen..and then close player and jump back to the script.. i make a solution but i thnk its not very professionell.. its somethng like that..:

Func playvideo($nr)
    
If $nr = 1 Then
$wild = "a"
$videotime = 10*60*1000
ElseIf $nr = 2 Then
$wild = "b"
$videotime = 10*60*1000
EndIf
        
$videolist = _FileListToArray("C:\blablabla\", $wild & "*.avi", 1)
If (Not IsArray($videolist)) and (@Error=1) Then
Exit
Else
Do
$filenr = Random( 1, $videolist[0], 1)
$file = $videolist[$filenr]
Until $file <> $fileholder
EndIf
$fileholder = $file
    
Run ('C:\Programme\Windows Media Player\wmplayer.exe ' & '"C:\blablabla\' & $file & '"')
sleep(1000)
WinActivate( "Windows Media Player" )
Send ( "!{ENTER}" , 0)
sleep($videotime)
Send ( "!{F4}" , 0)
Send ( "!{F4}" , 0)
sleep(500)
WinActivate( $scriptname )

Return
EndFunc

...this works but the problem is that a user that clicks while the prozess runs, can kill fullscreen of mediaplayer, and if he kills player the script still runs in it paused state...

...the other problem is, that i dont know the .avi length, cause there are different files with different lenght...so i cant get the exactly pause time (in my script its fixed time)...

..i tried workin with some other threads solutions but none of them was be able to play a divx.avi in fullscreenmode... they just stretch the video to fullscreen and that looks horrible blocking... so maybe someone have a clue on that?..

question1: how can my script get the length of an avi file

question2: u know a better way to play divx.avi in fullscreen mode? (must be non 3rdparty solution, just xp stuff)..

Thanks for ur thoughts..

..salute..

Edited by duketrapp
Link to comment
Share on other sites

while winactive("music player")

sleep(10)

wend

8)

If what you want is to have it pause if the window is activated, use this. bt if you wat to make it go for as long as the window is existing do

While WinExists("Windows Media Player")
Sleep(100)
Wend

But Vals works too :)

Edit: then you really dont need to find movie length :(

Edited by Paulie
Link to comment
Share on other sites

Edit: then you really dont need to find movie length :oops:

...folks... :) .. it isnt that easy.. cause...

my posted script is not what i want..its just tryin make it work somehow.. :">

in real case! the comand should not be sleep($videotime).. :D ..in real case i dont have the video lenght = so i cant set sleep(blablabla) or tell the script when to kill mediaplayer... so..

winactive or winexists are no solutions for this..

the mediaplayer dont close automatic when the file ends... that means... it just stops the file and stay with window open at the desktop... so... both functions will return "mediaplayer is still running the video" to the script cause window is still open, active and exists.... but its not playing anymore..but how can i tell the script?.. :(

..anythng else?... :(

Edited by duketrapp
Link to comment
Share on other sites

:(

..i got it..!!!

..u can check the state of windows media player through :"WinGetState()" :)

..so if u create a routine like that below u can avoid the user from leave fullscreenmode :D

... my script example for all want do so:

EDIT: changed some code.. tested around works good.... but still need check for avi lenghts

EDIT 12.05.2006: now i worked it out perfectly.. runs stable and 100%

$file = The AVI file

$videotime = Length of AVI (if u need get AVI length past CODE2 BEFORE CODE1 in ur script)

CODE1 for Windows Media Player Send Key controlled (Stays in Fullscreenmode until video ends or user close..)

BlockInput(1)
Run ('C:\Programme\Windows Media Player\wmplayer.exe ' & '"C:\BLABLABLA\' & $file & '"')
sleep(1000)
WinActivate( "Windows Media Player" )
BlockInput(0)
    
$videotimer = TimerInit()
    
Do
If WinExists("Windows Media Player") = 0 Then
WinActivate( "MAINGUI" )
Return
EndIf
$state = WinGetState ( "Windows Media Player" )
If BitAnd($state, 8) Then
WinActivate( "Windows Media Player" )
Send ( "!{ENTER}" , 0)
EndIf
Until TimerDiff($videotimer) >= $videotime
    
BlockInput(1)
If WinExists ( "Windows Media Player" ) = 1 Then
WinActivate( "Windows Media Player" )
Send ( "!{F4}" , 0)
EndIf
sleep(100)
If WinExists ( "Windows Media Player" ) = 1 Then
WinActivate( "Windows Media Player" )
Send ( "!{F4}" , 0)
EndIf
BlockInput(0)
WinActivate( "MAINGUI" )

CODE2 for getting AVI File length (Big Thnks to Simucal)

$filepath = "C:\BLABLABLA\" & $file
ConsoleWrite($filepath&@CRLF)
$vid = StringTrimLeft($filepath,StringInStr($filepath,"\",0,-1))
$dir = StringTrimRight($filepath,(StringLen($filepath)-StringInStr($filepath,"\",0,-1)))
$ShellApp = ObjCreate("shell.application")
$oDir = $ShellApp.NameSpace($dir)
$oVid = $oDir.Parsename($vid)
$duration = $oDir.GetDetailsOf($oVid, 21)
$videotime = (((StringMid($duration,4,2)*60)+StringRight($duration,2))*1000);<--- Playtime in Milliseconds

..salute...

Edited by duketrapp
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...