Jump to content

Recommended Posts

Posted
grrrr... I don't find. :x

(vlax-invoke mp 'close) don't work

 

Annoying isn't it :glare:

 

I tried this, but with no luck:

 

(setq video "Une_video.avi")
(setq mp (vlax-create-object "WMPlayer.OCX"))
(vlax-invoke mp 'openPlayer (findfile video))
(while
 (progn
   (setq pl (vlax-get-property mp 'playstate))
   (cond ((eq 3 pl)
          (vlax-invoke mp 'close))
         (t t ))))
(vlax-release-object mp)

  • Replies 41
  • Created
  • Last Reply

Top Posters In This Topic

  • Patrick_35

    12

  • Lee Mac

    11

  • The Buzzard

    11

  • Small Fish

    7

Posted

(defun kill(qui / item meth1 meth2 obj WMI)
 (setq WMI (vlax-create-object "WbemScripting.SWbemLocator")
       meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil)
       meth2 (vlax-invoke meth1 'ExecQuery "Select * from Win32_Process")
 )
 (vlax-for item meth2
   (and (setq obj (vlax-get item 'CommandLine)) (vl-string-search (strcase qui) (strcase obj))
     (vlax-invoke item 'Terminate)
   )
 )
 (foreach item (list WMI meth1 meth2)
   (vlax-release-object item)
 )
)

(kill "wmplayer.exe")

@+

 

Just out of interest, is this process "dangerous" :unsure:

Posted

Yes, but you take a break before you kill the process

For example (repeat 10000)

 

Otherwise, in my archives, I found this, but I have not the time to present

(setq video "Une_video.avi")
(setq ie (vlax-create-object "InternetExplorer.Application"))
(foreach item (list 'MenuBar 'Toolbar 'AddressBar 'StatusBar)
 (vlax-put ie item 0)
)
(vlax-put ie 'Width 350)
(vlax-put ie 'Height 278)
(vlax-put ie 'Left 96)
(vlax-put ie 'Top 150)
(vlax-invoke ie 'Navigate "about:blank")
(vlax-put ie 'Resizable -1)
(setq doc (vlax-get ie 'Document))
(vlax-put doc 'Title (findfile video))
(foreach item '("<html>"
       "<head><title>Windows Media Player</title></head>"
       "<body>"
       "<OBJECT id=""VIDEO"" width=""320"" height=""240"""
       "position:absolute; left:0;top:0;"""
       "CLASSID=""CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"""
       "type=""application/x-oleobject"">"
       "<PARAM NAME=""URL"" VALUE=""" & video & """>"
       "<PARAM NAME=""SendPlayStateChangeEvents""VALUE=""True"">"
       "<PARAM NAME=""AutoStart"" VALUE=""True"">"
       "<PARAM name=""uiMode"" value=""full"">"
       "<PARAM NAME=""showControls"" VALUE=""1"">"
       "<PARAM name=""PlayCount"" value=""1"">"
       "</OBJECT></body></html>")
 (vlax-invoke doc 'WriteLn item)
)
(vlax-put ie 'visible -1)
(vlax-release-object ie)

@+

Posted
Just out of interest, is this process "dangerous" :unsure:

Yes, but I have no choice to close mp

:(

ActiveX does not always respond to what we want to

 

And normally, we master what we do

o:)

 

@+

Posted
Good link :)

 

But, it's don't work with vlisp :(

 

@+

 

Yeah, VL has its limitations. I just used that link to help with my code in post #21.

 

By the way, what reference do you use for retrieving such information as this:

 

 (setq WMI (vlax-create-object "WbemScripting.SWbemLocator")
       meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil)
       meth2 (vlax-invoke meth1 'ExecQuery "Select * from Win32_Process")

 

I use vlax-dump-object quite a lot, but it doesn't let you know what args you need to specify, just how many...

 

How do you know to use: "WbemScripting.SWbemLocator"?

 

Thanks, et merci beaucoup mon ami.

 

Lee

Posted

hey thanks guys...awesome! - that solves some problems for me.

Just one thing,- when I when I use the 'kill' function to close

windows player I have a "delay" unfortunately it does not

like it and I get a hour glass which means I have to ctrl+alt+del.

Is there a different way to have a delay before the video finishes?

 

(defun do_avi1 ()
 (setq dcl_id3 (load_dialog "demo.DCL"))
 (if (not (new_dialog "view_avi" dcl_id3)) (exit))
 (setq video "demo.avi")
 (setq mp (vlax-create-object "WMPlayer.OCX"))
 (vlax-invoke mp 'openPlayer (findfile video))
 (vlax-dump-object mp T) ; to look full functions
 (vlax-release-object mp)
 (command "_.delay"  6000) 
 (kill "wmplayer.exe")
 (start_dialog)
 (unload_dialog dcl_id3)
 );defun

Posted

Lee

I found on website (sorry, in french) all that are necessary to use wmi.

But I failed to translate into vlisp.

It was on that I found TheSwamp :)

For activex, I seek with Vlax-dump-object, but also with google (with createobject ...)

 

ps: thank you for the french :)

 

Small Fish

Why the dialog box ?

 

@+

Posted

Thanks for the link & info Patrick, much appreciated. :)

 

Lee

Posted
Patrick_35

Why the dialog box ?

Because I have the video launching from my 'help' button.

It works fine. I just have problems closing the video.

Posted

yes they can. I guess that's what will have to happen.

Posted

Hi

 

If I do that, it's work fine.

 

(defun kill(qui / item meth1 meth2 obj WMI)
 (setq WMI (vlax-create-object "WbemScripting.SWbemLocator")
       meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil)
       meth2 (vlax-invoke meth1 'ExecQuery "Select * from Win32_Process")
 )
 (vlax-for item meth2
   (and (setq obj (vlax-get item 'CommandLine)) (vl-string-search (strcase qui) (strcase obj))
     (vlax-invoke item 'Terminate)
   )
 )
 (foreach item (list WMI meth1 meth2)
   (vlax-release-object item)
 )
)

(defun do_avi (video / mp video)
 (if (setq video (findfile video))
   (progn
     (setq mp (vlax-create-object "WMPlayer.OCX"))
     (vlax-invoke mp 'openPlayer video)
     (command "_.delay"  6000)
     (kill "wmplayer.exe")
   )
 )
 (princ)
)

(do_avi "demo.avi")

@+

Posted

Patrick, won't the delay be different for each video played?

Posted

Hi

 

I think I found another solution

 

(setq video (findfile "c:/test/volet.avi"))

to read the avi file

(setq wsh (vlax-create-object "WScript.Shell"))
(setq mp (findfile "C:/test/MPlayerc.exe"))
(setq run (vlax-invoke-method wsh 'exec (strcat mp " " video)))

Close Mplayer

(vlax-invoke run 'terminate)
(vlax-release-object wsh)

to find its time

(setq sh (vlax-create-object "Shell.Application"))
(setq dir (vlax-invoke sh 'Namespace (vl-filename-directory video)))
(setq name (vlax-invoke bb 'parsename (strcat (vl-filename-base video) (vl-filename-extension video))))
(setq time (vlax-invoke-method name 'extendedproperty "duration"))
(vlax-release-object sh)

@+

Posted

and I find this to run avi without WScript.Shell

(vlax-invoke-method name 'invokeverbex "open")

I search to close it

 

@+

Posted

I see you use that method a lot now Patrick - is this something new you have learnt?

 

I saw you use it over at theSwamp to open a Notepad file :D

 

Lee

Posted

Yes Lee,

I just discovered this method and it offers many possibilities.

It is the search for the duration that brought me on shell.Application and can be opened with any application, I wanted to share it on theswamp.

 

@+

Posted

Patrick thanks - I tried your code out as shown below - it runs okay but wmplayer still does not close after finishing. Do I need to change something?

thanks

 

(defun c:playAvi (/ video wsh mp run sh dir name time)

(setq video (findfile "c:/test/volet.avi"))

;;;to read the avi file
(setq wsh (vlax-create-object "WScript.Shell"))
 
(setq mp (findfile "C:/program files/windows media player/wmplayer.exe"))
(setq run (vlax-invoke-method wsh 'exec (strcat mp " " video)))

;;;to find its time
(setq sh (vlax-create-object "Shell.Application"))
(setq dir (vlax-invoke sh 'Namespace (vl-filename-directory video)))
(setq name (vlax-invoke bb 'parsename (strcat (vl-filename-base video) (vl-filename-extension video))))
(setq time (vlax-invoke-method name 'extendedproperty "duration"))
(vlax-release-object sh)

(command "_.delay"  time) 
 
;;;Close Mplayer
(vlax-invoke run 'terminate)
(vlax-release-object wsh)

(princ)
 );defun

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...