If you have experienced issues connecting to Windows 2003 Servers and other Remote Desktop hosts, or connecting to Citrix sessions from Windows Vista there is a solution you may wish to try.

For an excellent post on the why's and wherefores of the issue see this post from Tom Keating. For more on the Citrix issues see this thread from the Citrix support forums.

The short answer is that the TCP Stack in Vista supports automatic receive window tuning, and this appears to result in connectivity issues in certain situations. The fix is to disable autotuning by running this command as an administrator. (Followed by a log out/log in cycle).

The following is copied directly from Tom's blog post.

- Run a command prompt (cmd.exe) as an Administrator
- Type: netsh interface tcp set global autotuninglevel=disabled
If you want to to re-enable it:
- Type: netsh interface tcp set global autotuninglevel=normal
In some cases you may need to use this command in addition to the above, but I didn't have to:
- Type: netsh interface tcp set global rss=disabled

Now be aware that this will turn off auto tuning on all connections, read Tom's article for a good explanation of how this might be prevented and the possible consequences. I can attest to the fact that it resolved a number of connectivity issues I was having.

Thanks to Mike DieBold of the Kentucky Retirement System for pointing this solution out to me!

Cheers,

Robert Porter


 
Categories: Hardware | Misc


 

I had need to be able to play a video file (both mpg and wmv) in a WinForms application recently. I thought it would be rather straightforward, and for the most part it was. However there were a few gotcha's I ran into so I thought I would document them here in case anyone else runs into the issue. Also, if anyone knows a better way please let me know.

One of the conditions I had to meet was that the video file had to play in a loop continuously, as the application is designed as a Kiosk application. Another condition was that I did not want to display any of the UI controls, just the video itself to avoid users stopping or otherwise altering the video playback.

I decided to use the ActiveX (COM) version of the control for simplicity, so I right clicked the Toolbox and selected the Choose Items option and on the resulting dialog box I selected COM Components, scroll down and select Windows Media Player: (Click on the image to see it full size.)

image

Once that is done we drop the control onto the form, and set it's properties as needed. Some of the properties that I set at design time are shown below:

image

Notably, I set FullScreen to false, and uiMode to none which means that there will be no visible interface, Play, Stop etc will not be displayed to the user allowing me to have more control over the end user experience.

It is important to note that uiMode is not a drop down in the designer, the relevant values for this property are:

  • invisible - Windows Media Player is embedded without any visible user interface (controls, video or visualization window).
  • none - Windows Media Player is embedded without controls, and with only the video or visualization window displayed.
  • mini - Windows Media Player is embedded with the status window, play/pause, stop, mute, and volume controls shown in addition to the video or visualization window.
  • full - Default. Windows Media Player is embedded with the status window, seek bar, play/pause, stop, mute, next, previous, fast forward, fast reverse, and volume controls in addition to the video or visualization window.
  • custom - Windows Media Player is embedded with a custom user interface. Can only be used in C++ programs.

I chose none because I wanted to preserve the option of allowing the interface to be shown for administrative users without messing up the visual layout, none reserves the space necessary to display the UI controls.

With the design time properties set I then wrote the following code to load and play a video file:

   1:          wmpMain.URL = mConfig.VideoFile
   2:          wmpMain.settings.setMode("loop", True)
   3:          wmpMain.settings.autoStart = True
   4:          wmpMain.Ctlcontrols.play()
 

mConfig.VideoFile is a string property that contains a fully qualified path and filename and is used to set the file to be loaded. The second line of code was the tricky part for me, searching for various combinations of .NET and play video in a loop etc resulted in lots of examples of embedding the player in a web page with an attribute called "loop" set to true, but I could not figure out how to implement that in a WinForms version.

Eventually I stumbled on the setMode reference which is rather vague when it comes to intellisense. The available setMode settings are:

Syntax: player.settings.setMode(modeName, state)

    Parameters

    modeName (one of the following)

  • autoRewind - Mode indicating whether the tracks are rewound to the beginning after playing to the end. Default state is true.
  • loop - Mode indicating whether the sequence of tracks repeats itself. Default state is false.
  • showFrame - Mode indicating whether the nearest video key frame is displayed at the current position when not playing. Default state is false. Has no effect on audio tracks.
  • shuffle - Mode indicating whether the tracks are played in random order. Default state is false.
  • state - Boolean specifying whether the new specified mode is active or not.

So in a nutshell that is the basics of getting a video (or audio) file to play in a loop in a WinForms application. There is a lot more you can do with the player, you can programmatically create playlists, react to events the player raises etc. But this illustrates the basics.

Cheers,

Bob Porter


 
Categories: .NET | Programming | VB.NET | Visual Studio