Jump to content

detect end of video


klaus.s
 Share

Recommended Posts

Hello,

here some lines to see to see the context

$c= """%programfiles%\Windows Media Player\wmplayer.exe"" " & _

" """ & $f & """ /fullscreen"

run( @comspec & " /c """ & $c & """", "", @sw_hide)

winwaitactive( "Windows Media Player")

$w= wingethandle("")

This works as expected: wmp opens and the video-file $f runs in fullscreen mode.

Now I would like to get a message, when the video is finished. How could this be

achieved?

Klaus

Link to comment
Share on other sites

does wmp quit after playing this $f file? if so, you can replace Run() with RunWait() (see hore info in the help file) else I don't know

Arjan

Link to comment
Share on other sites

Thanks for these suggestions. Meanwhile I found some interesting code referring to ObjCreate( "wmplayer.ocx"), here in this forum. I find it always surprising how things can be done with au3 :)

Here my experimental code

#include <GUIConstants.au3>

  dim $files[4]= [ "" _
    ,"e:\dscf0136.avi" _
    ,"e:\short1.avi" _
    ,"e:\dscf2073.avi" _
     ]

  $title= "kwmp"
  $n_files= 3
  $i_file= 0
  $trace= false
  
  $dx= 0
  $dx_win= 0
  $dx_dur= 0
  $dx_ctrl= 0
  $dx_s= ""

; -------------------------------------------------------------------------
  $this_win= GUICreate( @ScriptName, 305, 50, 0, 30, _
    $WS_SYSMENU, $WS_EX_TOPMOST +$WS_EX_TOOLWINDOW)

  $y= 0
  $ui_prev= GUICtrlCreateButton( "previous", 0, $y, 100)
  $ui_next= GUICtrlCreateButton( "next", 100, $y, 100)
  $ui_close= GUICtrlCreateButton( "close", 200, $y, 100)

  GUISetState( @SW_SHOW)

  while true
    $msg = GUIGetMsg()
    select
      case $msg = $ui_next
        $trace= false
        $i_file+= 1

      case $msg = $ui_prev
        $trace= false
        $i_file-= 1

      case $msg = $ui_close
        $trace= false
        GUIdelete( $dx_win)
        $dx_s= ""
        continueloop
      case $msg = $GUI_EVENT_CLOSE
        exitloop
      case $trace and dx_completed()
        $trace= false
        winsettitle( $this_win, "", $title & " - " & _
          $i_file & "/" & $n_files & " - completed")
        winactivate( $this_win)
        continueloop
      case else
        continueloop
    endselect

    if $i_file < 1 then $i_file= 1
    if $i_file > $n_files then $i_file= $n_files
    $file= $files[$i_file]

    dx_show( $file)
    $trace= true

    winsettitle( $this_win, "", @scriptname & " - " & $i_file & "/" & $n_files)
  wend
  exit
;--------------------------------------------------------------------------

func dx_show( $file);                                               ;{{{

  local $a, $s, $b, $p

  $a= get_wmp_file_display_size( $file)
 ;local $a[2]= [ 400, 300]
  $s= $a[0] & "x" & $a[1]  
  
  if $dx_s <> $s then
    $dx_s= $s
    $p= $dx_win
    $dx_win= GUICreate( "dx_win", 0,0,0,0, $WS_MAXIMIZE)
    
    $b= wingetpos( $dx_win)
    $left= ( $b[2] -$a[0]) /2
    $top= ( $b[3] -$a[1]) /2

    $dx = ObjCreate( "wmplayer.ocx")
    $dx.settings.autoStart = "True"
    $dx_ctrl= GUICtrlCreateObj( $dx, $left, $top, $a[0], $a[1])
    $dx.uiMode= "none"
  endif

  $dx.URL= $file  

 ; to avoid flicker
  $h= 0
  while $h = 0
    $h= $dx.currentMedia.imageSourceHeight
  wend
  
  GUISetState(@SW_SHOW)

  while true
    sleep(1)
    $dx_dur= $dx.currentMedia.duration
    if $dx_dur <> 0 then exitloop
  wend

  winsettitle( $dx_win, "", $file & " " & $dx_s & " " & $dx_dur)
  if $p <> 0 then GUIdelete( $p)
endfunc
; }}}

func dx_completed();                                                 ;{{{

  $dx_t= $dx.controls.currentPosition

  if $dx_t < $dx_dur then return false

  while not $dx.controls.isAvailable("pause")
    sleep(1)
  wend
  $dx.controls.pause()
  return true
endfunc
; }}}


func get_wmp_file_display_size( $file)

  local $obj, $ctrl, $a[2]

  $obj= ObjCreate( "wmplayer.ocx")
  $ctrl= GUICtrlCreateObj( $obj, -900, -900)
  $obj.URL= $file

  while $a[0] = 0 or $a[1] = 0
    $a[0]= $obj.currentMedia.imageSourceWidth
    $a[1]= $obj.currentMedia.imageSourceHeight
  wend
  $obj.controls.stop()
  
  return $a
endfunc

Some delay is caused by the last function to get the image size, suggestions welcome.

Klaus

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...