WP7 MdeiaPlayer Event for video finished playing - windows-phone-7

I am using MediaPlayerLauncher for playing video. How do we get some notification when the MediaPlayerLauncher is opened() and the video is finished it's playback or the MediaPlayerLauncher is closed.

You can't explicit know if it's from a video or another navigation, but the OnNavigatedTo event will tell you when the user returns to your page.

By using the built in MediaPlayer you are giving up a lot of control to playback. If you really must* know when a video has finished playing you should use the MediaElement and detect the MediaEnded event.
* The end of a movie is typically a grey area. Does it include any ending credits? Is it when the user has watched "enough"? Is a certain percentage through the video sufficient ?

Related

How can I find a list of active plugins on a web page in a browser window

Say I open Youtube,and the video starts playing. How do I find out what in-browser and system plugins / resources are being used to play the music / video?
Asking because on my Firefox, about 50% of the time, when I open youtube, it starts playing the audio of the page in the background, even as the video loads. So when the video is playing, there's audio with it, but there's the same audio, with a small delay playing in the background.
I've tried disabling the extra flash plugin that most other guides about this recommend, and it hasn't helped. Now I want to find out what my browser is using to play the background music.
Simplest thing is probably to right-click on the video and check if the menu that appears is the typical Flash rc-menu or the browser native video right-click menu.

How to load a file in IWMPPlayer without playing it?

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.

How to identify a window playing a video in a browser

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

How can I stop background audio played by other apps?

I have an app for WP7, using BackgroundAudioPlayer as we need to play in the background. The problem is, when there's already an app playing audio in the background, I can't get my AudioPlaybackAgent work, the previous music just keep playing.
The document introduced this way,
BackgroundAudioPlayer.Instance.Close();
by which I can only close the audio that is played by myself or Zune, but it doesn't work when the audio is played by other apps.
So is there a way to close all the playing audio?
OK I fixed it.
What I did to get it play is like this, first I set a track to the player:
BackgroundAudioPlayer.Instance.Track = ...;
Then an OnPlayStateChanged event will fire in the background agent, where I call the BackgroundAudioPlayer.Instance.Play() method. This seems to work great.
But if the background player is already being used by another app, the PlayState won't change to TrackReady when I set the track, and consequently the event won't fire.
To fix this, I simply call the .Play() method in the main UI thread, right after setting the track. And it works.

How to capture actions taken on Windows Media Player

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.

Resources