I am trying to create a Coded UI property that checks for an open WMP file.
public BrowserWindow VideoWindow
{
get
{
if (this._videoWindow == null || !this._videoWindow.Exists)
{
this._videoWindow = new BrowserWindow();
this._videoWindow.SearchProperties["Name"] = "Windows Media Player";
this._videoWindow.SearchProperties["ControlType"] = "Window";
}
return this._videoWindow;
}
}
Obviously, this will not work. Originally, the application opened a link to a video site. So this worked, but since it is quite a bit different than a BrowserWindow I am not sure how to do it. How can I use Coded UI to "grab" it?
The only real difference for windows media player from the video site you've been dealing with is that windows media player will be a WpfWindow instead of a BrowserWindow -
public WpfWindow VideoWindow
{
get
{
if (this._videoWindow == null || !this._videoWindow.Exists)
{
this._videoWindow = new WpfWindow();
this._videoWindow.SearchProperties["Name"] = "Windows Media Player";
this._videoWindow.WindowTitles.Add("Windows Media Player");
}
return this._videoWindow;
}
}
After that, you just have to get the controls inside of the media player window(WpfControls instead of HtmlControls) to determine which file is open.
Related
I’m writing a small application that will launch Internet Explorer and will open a unknown list or URLs, either as new windows or as new tabs within existing windows (depending on the setting for that particular site). The websites being launched can be in any internet zone. I am able to use the SHDocVw methods to open new Windows and tabs.
I’m trying to figure out a way to track the last opened Internet Explorer reference, so that I can use that reference to open tabs.
I’m running into the situation where, due to “loosely-coupled Internet Explorer” (LCIE) and IE protected mode, the IE instance that I launch gets shut down and another automatically launched (IE virtual tab switching). This causes me to lose the reference that I had to the original IE and when I try opening a tab it fails.
I would like to use the ShellWindows FindWindowSW method to get a specific Window (based on the ShellWindows cookie value), but I can’t get it to work.
Could someone point me in the right direction?
private InternetExplorer GetLastExplorer(int cookie)
{
object _m = Type.Missing;
const int SWC_BROWSER = 0x00000001;
const int SWFO_COOKIEPASSED = 4;
int pHWND;
_shellWindows.FindWindowSW(cookie, ref _m, SWC_BROWSER, out pHWND, 5);
foreach (InternetExplorer window in _shellWindows)
{
if (window.HWND == pHWND)
return window;
}
return null;
}
I couldn’t get this to work, and had to take a different approach. I ended up doing the following to get the last opened IE instance:
private InternetExplorer _lastInternetExplorer;
private List<InternetExplorer> _existingInternetExplorers = new List<InternetExplorer>();
private static ShellWindows _shellWindows = new ShellWindows();
_shellWindows.WindowRegistered += OnShellWindowRegistered;
private void OnShellWindowRegistered(int lCookie)
{
foreach (InternetExplorer window in _shellWindows)
{
if (!_existingInternetExplorers.Contains(window))
{
_lastInternetExplorer = window;
_existingInternetExplorers.Add(window);
}
}
}
I would like to know how to open URL on button click in Gear VR App. Samsung Internet App in Oculus Store can be used in this scenario. Just like in 2D Non-VR Android Application, URL is automatically opened in Chrome or Firefox based on default browser. But in Gear VR app when I call
Application.OpenURL("http://www.google.co.uk");
the app freezes.
If this is not possible at all, then is there a way to show intractable Web-View in 3D space?
Any kind of help will be appreciated.
I had found the solution from this post on Oculus forum.
Here is the working code:
public class OpenWebsiteOnHeadsetRemove : MonoBehaviour
{
#region Serialized
public OVRManager m_OVRManager;
#endregion
#region Variables
private bool m_UserPresent = true;
private bool m_HasOpenedURL = false;
#endregion
#region Lifecycle
private void Update () {
#if UNITY_ANDROID
bool isUserPresent = m_OVRManager.isUserPresent;
if( m_UserPresent != isUserPresent )
{
if( isUserPresent == false && m_HasOpenedURL == false && Application.isEditor == false )
{
m_HasOpenedURL = true;
Application.OpenURL("http://www.google.co.uk");
}
}
m_UserPresent = isUserPresent;
#endif
}
#endregion
}
It will wait until the user has removed the headset before opening the
app to avoid the jarring visuals of the app freezing when you try to
open the URL. If the player takes the headset off and puts it back on
they will be returned to where they were in the game.
Hope this helps late users :)
Courtesy: Glitchers Games
I have created a Windows Form Application having axWindowsMediaPlayer control. I haven't created a playlist on it, but I have stored my .mp4 files at a particular location. I pass the path to my next video at Media Ended state. For the first time, the player receives the correct path and play. But for the second video, I can only see a black screen although the player is receiving the correct path to play.
Here is my code for Media Ended State:
private void axWindowsMediaPlayer_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
if(e.newState == 8)
{
//Getting jumpTo of selected page
var selectedElementJumpToValue = MainContentAreaBl.GetSelectedElementValue(_currentId, "jumpTo");
if (selectedElementJumpToValue != null)
{
_currentId = selectedElementJumpToValue;
if (_currentId != "menu")
{
pagination.Text = MainContentAreaBl.GetPaginationText(_currentId);
LaunchPlayer(selectedElementJumpToValue);
}
else
{
this.Hide();
this.SendToBack();
menu.BringToFront();
}
}
}
}
private void LaunchPlayer(string id)
{
string selectedElementPageTypeValue = MainContentAreaBl.GetSelectedElementPageTypeValue(id);
var playerFile = Path.Combine(Common.ContentFolderPath, MainContentAreaBl.GetSelectedElementDataPathValue(id));
if (selectedElementPageTypeValue == "video")
{
InitialiseMediaPlayer();
axShockwaveFlash.Stop();
axShockwaveFlash.Visible = false;
if (File.Exists(playerFile))
{
axWindowsMediaPlayer.URL = playerFile;
}
}
else if (selectedElementPageTypeValue == "flash")
{
InitialiseShockwaveFlash();
axWindowsMediaPlayer.close();
axWindowsMediaPlayer.Visible = false;
if (File.Exists(playerFile))
{
axShockwaveFlash.Movie = playerFile;
axShockwaveFlash.Play();
}
}
}
private void InitialiseMediaPlayer()
{
axWindowsMediaPlayer.Visible = true;
axWindowsMediaPlayer.enableContextMenu = false
axWindowsMediaPlayer.uiMode = "none";
axWindowsMediaPlayer.Dock = DockStyle.Fill;
}
When I debugged my application, I saw Media Player getting the correct path after e.newState == 10 (Ready state). What am I doing wrong?
Edit 1: I found out that after my current video enters into Media Ended state, the player is stopped from playing. Even if I write axWindowsMediaPlayer.ctlControls.play();, it doesn't affect the media player. Is this a bug from in axWindowsMediaPlayer?
I have encountered this issue before as well. The most likely cause is that you are giving the command axWindowsMediaPlayer.ctlControls.play(); while the play state is still changing ( after Media Ended, it will change to Ready state). If a command is sent to the player while the play state is changing, it won't do anything. Another possible cause of your error is that sometimes Media State 9 (transitioning) needs to be included with if(e.newState == 8) such that you have if(e.newState == 8 | e.newState==9). I have had cases where it doesn't pick up on State 8 (media ending), possibly because it happens really fast and jumps to transitioning - not completely sure of this cause but I had a player that wasn't moving to the next video in the playlist because of this happening. To solve this I did something like:
if (e.newState == 8 | e.newState== 9 | e.newState== 10)
{
if (e.newState == 8)
{ //Insert your code here
}
This would vary slightly depending on what you are trying to achieve. Another thing to watch out for is using the PlayStateChange Event to set the Video URL, this causes problems as a result of re-entry problems with WMP - see other posts for further explanation on my last comment:
here is a good one and another here. Hope this helps!
We're using VideoLan DotNet for WPF to play DVD movies in our WPF application. Some movies have multiple audio stream. (for example in multiple languages) How can we choose the desired audio stream?
While searching VideoLan's Wiki, I found this:
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public int AudioTrack
{
get
{
return this.nativeVlc.GetVlcObjectInt(ObjectType.VLC_OBJECT_INPUT, "audio-es", -1);
}
set
{
this.nativeVlc.SetVlcObjectInt(ObjectType.VLC_OBJECT_INPUT, "audio-es", value);
}
}
But I can't find the same property in the project I'm using (Vlc.DotNet)
So how can I detect how many audio streams exist and choose one?
I found out how to do so (mediaPlayer is an instance of VlcControl):
We can count audio streams using mediaPlayer.AudioProperties.TrackCount and select the index using mediaPlayer.AudioProperties.Track.
Now is there any way to get their description? (They usually have a name such as "English")
i'm using VLC control in Windows form and my code for work
private void karaokeToolStripMenuItem_Click(object sender, EventArgs e)
{
// MessageBox.Show(axVLCPlugin21.audio.count.ToString(), "audio track");
if (axVLCPlugin21.audio.track == 1)
{
try
{
axVLCPlugin21.audio.track = 2;
}
catch (Exception ex)
{
// show Exception here by messageBox or other
//if there are exceptions, the file has only one track
}
}
else
axVLCPlugin21.audio.track = 1;
}
I hope to help you.
I'm making a Silverlight application and I'm using a MediaElement to play a video from the user's disk that I know the path of (say, "C:/foo.MOV"). I'd like a Javascript trigger from the browser to change the source of the MediaElement to another known file (eg "C:/bar.MOV"). I can make a button to do this in Silverlight, and I can have a Javascript trigger execute code inside the Silverlight app, but when I do, the MediaElement appears empty.
I've even tried having the Javascript call the btnLoadNewMediaTest_Click event, and while that event works fine called from user clicks on the button, it doesn't affect the media at all when called from outside the app.
Looking at the MediaElement in the debug, it seems that when it's called from the Javascript the MediaElement's Source appears as null and it seems to have made an empty copy.
I can confirm the Javascript is triggering the events in Silverlight, as it trips breakpoints in the Silverlight code.
I have managed to solve this: I created an EntryPoint class that is scriptable from JavaScript. When the JavaScript sendCommand is triggered, it puts a command and args into a queue held by the entry point. Every tick of a timer in the Silverlight app, the app checks the Count() of the queue and gets any commands and processes them.
From the Javascript, I call silverlightControl.Context.EntryPoint.setCommand("commandname", "args").
In the EntryPoint I have
[ScriptableMember()]
public string setCommand(string commandValue, string argsValue)
{
commands.Enqueue(commandValue);
args.Enqueue(argsValue);
commandWaitingFlag = true;
return Application.Current.HasElevatedPermissions.ToString();
}
In the Silverlight itself, I have a DispatcherTimer with an interval of 100ms. This has a tick event:
public void Each_Tick(object o, EventArgs e)
{
//Other code
if (entryPoint.commandWaitingFlag)
{
handleEntryPointCommands();
}
}
From inside handleEntryPointCommands I call a method of the entryPoint, getCommand():
public string[] getCommand() {
string commandOut = string.Empty;
string argsOut = string.Empty;
if (commands.Count > 0)
{
commandOut = commands.Dequeue();
argsOut = args.Dequeue();
if (commands.Count == 0)
{
commandWaitingFlag = false;
}
return new string[2] { commandOut, argsOut };
}
else
{
return new string[2];
}
}
and then can use the command I've gotten however I like. Hopefully that's more helpful with some code.