mark2004 Posted December 3, 2014 Share Posted December 3, 2014 Hi Everyone. I'm trying to do some basic control of the playback of audio files with windows media player. I'd like to be able to play/pause/jump back 5 seconds etc through scripting but I'm having some trouble. Here is a basic test script I have been using to just open a file and let it play for 5 seconds and then pause it. I can start playing the file just fine but I cannot pause it. Any ideas? $oWM=ObjCreate("WMPlayer.OCX.7")$oWM.OpenPlayer(@MyDocumentsDir & "testMessage.wav")Sleep(5000)$oWM.Controls.pause Link to comment Share on other sites More sharing options...
computergroove Posted December 3, 2014 Share Posted December 3, 2014 Search the forums -> Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
mark2004 Posted December 4, 2014 Author Share Posted December 4, 2014 I did search the forums. I am using the "openplayer" method which causes the media player application to open and the file begins playing. What is a mystery to me is why I cannot then use the other methods like "play" and "pause" to further control the application. If I use the methods referenced in many other posts to create an object and then open a media file with the "URL" method then the file begins playing in the background through an invisible window and I CAN in fact use "play" and "pause" methods. But I am trying to control a new media player window created with "openplayer" or an existing instance of the Windows Media Player application that was there before my script begins. All other forum references seem to be related to embedded WMP objects in another GUI window where this invisible method would work well. I have tried to use GetObject("","WMPlayer.OCX.7") to attach to an existing WMP window but this doesn't seem to work. It would be a good validation of what I want to ultimately accomplish if I could just open and start playing a file in a WMP window with my code and then have it pause 5 seconds later. Any ideas? Link to comment Share on other sites More sharing options...
mark2004 Posted December 4, 2014 Author Share Posted December 4, 2014 It is almost as if the window launched by $oWM.openplayer("testmessage.wav") is another entity/object that is no longer controlled by $oWM. I haven't had any luck attaching to this new object (if there is in fact a new one). Just thought I would add this for anyone who is burning some mental calories on this for me... Link to comment Share on other sites More sharing options...
computergroove Posted December 4, 2014 Share Posted December 4, 2014 http://windows.microsoft.com/en-us/windows/media-player-keyboard-shortcuts#1TC=windows-7 Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
mark2004 Posted December 4, 2014 Author Share Posted December 4, 2014 That only works when the Windows Media Player is the active window. I have already tried ControlSend() but it doesn't work when its not the active window. I didn't want to get into the full scope of my project but again: "It would be a good validation of what I want to ultimately accomplish if I could just open and start playing a file in a WMP window with my code and then have it pause 5 seconds later" If I can do this all programmatically from within my code then I think I can accomplish my goal. This is just the simplest test snippet I could think of to demonstrate my inability to communicate with the object once the player starts playing. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now