I want to programmtically detect the state of movie currently being played in Windows Media Player. i..e if the movie is maximized I need to find that it is maximized and put the word "MAXIMIZED" in text file, if the movie is paused I need to capture PAUSED in text file, if movie is stopped I need to capture STOPPED in text file.
The capturing needs to happen in the background i.e. totally transparent to end user as the user takes action while watching the movie on Windows Media player
I am planning to achieve this using Visual Basic 6.0
Kindly provide me inputs / pointers on how to go about this.
Thanks
I think only way how to do this, is using Windows Media Player SDK.
Windows Media Developer Center
You have to create a Media Player plugin and access the state using the Media Player API.
Theoretically you could also do some external analysis of the Media Player, for example by enumerating its windows and handles and reading window texts, but that would be very "hacky" and most fragile.
Although creating a plugin sounds like a lot of work, it'll be the better solution in the long run.
Related
I've got a project that uses IWMPPlayer4, the ActiveX interface to Windows Media Player. Downloading and playing a video from the Internet is easy: just call put_URL, and it connects to the video and begins to play it.
But what if I want to tell it to load up a video from a certain URL but not begin to play it yet? It's not clear from the documentation I've seen how I would do that, but I figure there has to be a way to accomplish it. Does anyone know how?
I tried calling get_controls and then either the Pause or Stop methods on the resulting IWMPControls interface immediately after calling put_URL, but both caused the same problem: no media actually loaded, and clicking the Play button on-screen plays nothing.
It's been a long time since I've worked with WMP API's, but I think you want this:
IWMPSettings::put_autoStart
From the MSDN link above:
You should set put_autoStart to FALSE immediately before you set
IWMPCore::put_URL, IWMPCore::put_currentPlaylist, or
IWMPCore::put_currentMedia in skins and remoted Player controls if you
wish to ensure that the media item does not start playing immediately.
Also, unless you set put_autostart to TRUE immediately before
specifying a media item, you should not rely on this setting as a
substitute for using the IWMPControls::play method.
I wish to understand how one can programmatically identify if a window is playing video content?
I used spy++ to identify particular attributes for windows playing video but I did not find any particular attributes associated with window playing video.
I have handles to all windows on screen and want to find which ones are playing video ? Could you please throw some light on how can one do this and are there any special properties associated with a window playing video?
I found similar article :
can we get window handle of the window which is playing video?
But I don't want to minimize application , I know user is using browser(ie,firefix,chrome) to watch video (from youtube,hulu)and window is visible on screen.
You can if you have execution privileges over the environment the Flash Player is executed in. You can listen for the playing event thrown by the Flash Player.
Listen for my Flash event in Javascript
Is there any way to get window handle of the window which is currently playing video. This is the only information my program will be having.
updated to include info incorrectly provided as an answer
I think I should explain what exactly I want to achieve here.
I actually wanted to share/stream my DVD data to the remote machine. Currently what I am doing is, I am capturing the screen/video into to still frames and sending it to remote system but now I don't want to see the playing video on my host machine. I could think of few probable solutions,
1.) If we can capture the data of a hide/minimized window.
Did some investigation and seems it is not possible. Please add your thoughts.
2.) Convert the DVD data format into ffmpeg format and stream it.
Don't have any idea if we will be allowed to convert the data format. If most of the DVD formats allow to covert then I can go for this option but not sure how complicated it could be.
3.) Will create some virtual surface play the DVD data to that surface and capture the screen of that surface.
Again not sure if DVD will play on that virtual/fake surface created by kernel mode driver.
There are probably three main playback engines used on windows; DirectShow (WMP, MPC) , ffmpeg (VLC, MPlayer) and QuickTime.
If you look closer at DirectShow will will see that it supports hardware overlays, windowed and windowless rendering and Direct3d surface support.
Even if you focus on a single app you are going to have problems since you don't know what kind of renderer is in use. You might be able to find a child window that always has the same position and dimensions as the video, but then you are relying on things that could change between versions etc.
I want to make a little query here before I submit my game on the app-hub. Microsoft has set strict policies regarding the music interruptions in the game, I've followed all of them except for the one that says ".../adjust the background music", though the value of the MediaPayer volume could be changed yet I dunno who to give this control to user in the game for adjusting it (volume). Opinions and suggestions will be highly appreciated.
The requirement in question relates only to the initial launch of the application. If your game plays background music (by using the MediaPlayer class; SoundEffect should not be used for background music), then on initial launch, if the user is already listening to music, then you must not pause or stop the active music without first asking the user. A simple message box should suffice. It would also be friendlier to the user if you provided a setting that enabled the user to change their initial decision, so that they can switch to your game music if they chose to keep listening to their own music.
i'm looking for an activeX component which allows loading .wav files, displaying + playing it - and also is capable of displaying/setting the current playing position.
any ideas?
thanks
You can use either Windows Media Player right of the box (choose Components "Windows Media Player"). It can be used with or without the controls (select Custom from the properties menu to turn off the controls) and supports events for everything you need. It plays wav files, mp3 files, and on Windows 7 and newer operating systems AAC's out of the box (basically anything windows media player supports). If this doesn't float your boat, installing VLC gives you the VLC activex control, however redistributing it might have some issues.