TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Lee Mac on July 09, 2009, 05:53:22 PM
-
This is a problem that Patrick and I encountered when answering a question over at CADTutor, the OP wanted to open Media Player, play a file, then, once the file had finished playing, close the player.
Patrick kindly provided this example to open the player:
(setq video "Une_video.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)
I tried using this to get the play state of the file to no avail:
(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)
And Parick later made this "kill" function, which is less than ideal, as a manually calculated delay must also be used:
(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")
I wondered if anyone here could offer any insight as to why we could not use methods/properties of the Active X object, after it is created, it would be much appreciated. :?
Thanks,
Lee
-
I'm throwing darts here. :|
Should you be testing for a value of 9 and / or 3 ?
You've probably already seen these.
http://mydev.info/comguide.html
http://kobesearch.cpan.org/htdocs/Wx-ActiveX/Wx/ActiveX/WMPlayer.pm.html
http://search.cpan.org/~mdootson/Wx-ActiveX-0.10/lib/Wx/ActiveX/WMPlayer.pm
-
Can be still to try taskkill?
(setq ws (vlax-get-or-create-object "wscript.shell"))
(vlax-invoke-method ws
"run"
"taskkill /F /T /IM "wmplayer.exe""
1
:vlax-true
)
(vlax-release-object ws)
-
I think the problem is that WMP is not reporting the playstate status as you'd expect it to. Here are 2 dumps of the MP object, the first is when it's at rest, the second when it's playing a video:
; IWMPPlayer4: IWMPPlayer4: Public interface.
; Property values:
; cdromCollection (RO) = #<VLA-OBJECT IWMPCdromCollection 03231524>
; closedCaption (RO) = #<VLA-OBJECT IWMPClosedCaption2 0323154c>
; controls (RO) = #<VLA-OBJECT IWMPControls3 03231574>
; currentMedia = nil
; currentPlaylist = #<VLA-OBJECT IWMPPlaylist 0323159c>
; dvd (RO) = #<VLA-OBJECT IWMPDVD 032315c4>
; enableContextMenu = -1
; enabled = -1
; Error (RO) = #<VLA-OBJECT IWMPError 032315ec>
; fullScreen = 0
; isOnline (RO) = -1
; isRemote (RO) = 0
; mediaCollection (RO) = #<VLA-OBJECT IWMPMediaCollection2 03231614>
; network (RO) = #<VLA-OBJECT IWMPNetwork 0323163c>
; openState (RO) = 6
; playerApplication (RO) = Exception occurred
; playlistCollection (RO) = #<VLA-OBJECT IWMPPlaylistCollection 03231664>
; playState (RO) = 0
; settings (RO) = #<VLA-OBJECT IWMPSettings2 032224e0>
; status (RO) = ""
; stretchToFit = 0
; uiMode = "full"
; URL = ""
; versionInfo (RO) = "11.0.6002.18005"
; windowlessVideo = 0
; Methods supported:
; close ()
; launchURL (1)
; newMedia (1)
; newPlaylist (2)
; openPlayer (1)
T
_$
nil
_$
; IWMPPlayer4: IWMPPlayer4: Public interface.
; Property values:
; cdromCollection (RO) = #<VLA-OBJECT IWMPCdromCollection 0323168c>
; closedCaption (RO) = #<VLA-OBJECT IWMPClosedCaption2 032316b4>
; controls (RO) = #<VLA-OBJECT IWMPControls3 032316dc>
; currentMedia = nil
; currentPlaylist = #<VLA-OBJECT IWMPPlaylist 03231704>
; dvd (RO) = #<VLA-OBJECT IWMPDVD 0323172c>
; enableContextMenu = -1
; enabled = -1
; Error (RO) = #<VLA-OBJECT IWMPError 0323378c>
; fullScreen = 0
; isOnline (RO) = -1
; isRemote (RO) = 0
; mediaCollection (RO) = #<VLA-OBJECT IWMPMediaCollection2 032337b4>
; network (RO) = #<VLA-OBJECT IWMPNetwork 032337dc>
; openState (RO) = 6
; playerApplication (RO) = Exception occurred
; playlistCollection (RO) = #<VLA-OBJECT IWMPPlaylistCollection 03233804>
; playState (RO) = 0
; settings (RO) = #<VLA-OBJECT IWMPSettings2 032224e0>
; status (RO) = ""
; stretchToFit = 0
; uiMode = "full"
; URL = ""
; versionInfo (RO) = "11.0.6002.18005"
; windowlessVideo = 0
; Methods supported:
; close ()
; launchURL (1)
; newMedia (1)
; newPlaylist (2)
; openPlayer (1)
Note that there are NO differences bewteen the 2. One would expect SOMETHING to be different, especially the playstate. I'm looking for a solution.....
-
Yes, I found that result Jeff - but couldn't find a solution.