AutoPlay


AutoPlay, a feature introduced in Windows 98, examines newly discovered removable media and devices and, based on content such as pictures, music or video files, launches an appropriate application to play or display the content. It is closely related to the AutoRun operating system feature. AutoPlay was created in order to simplify the use of peripheral devices - MP3 players, memory cards, USB storage devices and others - by automatically starting the software needed to access and view the content on these devices. AutoPlay can be enhanced by AutoPlay-compatible software and hardware. It can be configured by the user to associate favourite applications with AutoPlay events and actions.

Overview

When a user inserts a CD-ROM into a drives or attaches a USB camera, Windows detects the arrival and starts a process of examining the device or searching the medium. It is looking for properties of the device or content on the medium so that AutoPlay can present a set of meaningful options to the user. When the user makes a particular choice, they also have the option to make that selection automatic the next time Windows sees that content or device.
The AutoPlay dialog shows the result of a user placing a DVD into a DVD reader, in this case the drive. AutoPlay has determined that content is most likely a DVD movie and presents a set of actions to the user based on that decision. These actions are called Handlers and there are sets of Handlers associated with various types of content. The user can now make their decision and click OK to proceed. However, if they also tick the "Always do the selected action" tick box at this point, they will not be prompted the next time that particular content type is seen on that particular drive; the selected application will automatically start.

AutoPlay properties

If a user regrets that decision or wishes to make automatic AutoPlay selections for any particular content type, the AutoPlay properties for any drive are accessible through the My Computer desktop icon. Selecting a drive and then "File/Properties" from the Windows Explorer menu, followed by the selecting the AutoPlay tab, gives a dialog similar to that shown. The content types can be selected with the drop down box. Here the dialog shows the Handlers available if AutoPlay ever determines the content type on drive to be "Pictures". Selecting an action to perform makes that action automatic for that user. Selecting "Prompt me each time to choose an action" deletes any association; AutoPlay will prompt the next time.
The content types available vary with the type of drive selected. Pictures, Music files and Video files are available with any drive. DVD and CD drives can also have "Music CD" or "DVD movie" and Windows Vista adds others like "Video CD movie" to the list.

Mixed content

"Mixed content" is the result of file content types falling into more than one of the Pictures, Music files or Video files content types. Note that a CD containing audio tracks is always considered to be a "Music CD" by Windows, regardless of the presence of data tracks. Therefore, a CD with Picture files, Video files and audio tracks is a "Music CD"; it is not "Mixed content".
If this is the result of the AutoPlay decision, the user is always presented with the AutoPlay dialog. This will contain a selection of applications deemed appropriate for the content found. Thus if Music files and Video files are both discovered on a flash drive, the user will get to choose from the Handlers for "Music files" along with the Handlers for "Video files". In this case, the user cannot make their selection the default one.
However, the AutoPlay properties dialog for any drive usually gives "Mixed content" as a content type option. The options available here are limited to actions that can handle any type of files, usually "Open folder to view files" is the only Handler listed here. This enables the user to make that action the default for Mixed content.

Non-volume devices

Certain types of devices do not appear as drive letters in "My Computer". These are called non-volume devices and AutoPlay handles them somewhat differently from volume devices like CDs and DVDs. Many digital cameras and video devices fall into this category.
As Windows cannot examine the files on the device to determine content type, it is left to the manufacturer to decide how to proceed. A manufacturer can register Handlers against their particular device, can add their device to a group of devices or allow a device class to handle their device for them. This determines which Handlers will be listed in the AutoPlay dialog when their device is discovered.
Image:AutoPlay nonvolume icon.png|left|The tray icon of AutoPlay for a non-volume device or digital camera.|alt=
As these types of devices do not have a drive letter, AutoPlay properties cannot be accessed and changed through "My Computer". However, when a device is attached, the discovery causes Windows to place an icon in the taskbar notification area. AutoPlay preferences for this device can now be changed by clicking this icon. The adjacent image shows the icon that appeared when a video camera was attached.

Default settings

On a new installation of Windows, a default set of handler applications are registered with the AutoPlay system. The following are the defaults with Windows XP SP2. The and are simply strings stored within the Handler, they can vary to give the user a better idea of what will happen if they choose that action. They can also change to suit a user's preferred language. Many Handlers use the same Windows application; for example, Windows Media Player is used to play Music files as well as DVD movies. The word "using" is added by AutoPlay to join the two strings neatly.

Windows 95 and Windows 98

Windows 95 and Windows 98 do have a primitive version of AutoPlay. Its sole job is to deal with Audio CDs, Video CDs and Movie DVDs and start an application to deal with them. If the new arrival does not fall into one of these categories Windows proceeds with the usual AutoRun process.
Image:Explorer Folder Options.png|thumb|Explorer Folder Options dialog box on Windows XP|alt=
The action taken with Audio CDs and Movie DVDs essentially considers both types of media as if they were files; Explorer then simply performs the default action associated with that file type. File types and the actions associated with them can be viewed and changed from within any Explorer folder from the "File Types" tab of the "Tools/Folder Options" menu. They are stored in the Registry under HKEY_CLASSES_ROOT.
If the CD is a Red Book standard format Audio CD, then Explorer calls the default action registered for the file type. This is normally set to "Play" and commonly calls.
If the DVD is a Movie DVD then Explorer calls the default action registered for the file type. Movie DVDs are recognised by the existence of the file. The action for DVD is also normally set to "Play" and commonly calls.
The fact that the check for Audio CDs and Movie DVDs is done before AutoRun has implications for disabling the automatic playing of these types of media. Disabling AutoRun via the Registry or Group Policy or looking for messages within an application does not prevent these media types from automatically playing on insertion.
However one can disable Audio CDs by editing the file type for AudioCD and clicking "Set default". This will remove the Play action as the default for that file type. Alternatively, changing the entry under the key to "" will accomplish the same thing. The disabling action for Movie DVDs is the same, with "DVD" used in place of "AudioCD".
The pertinent Registry settings are shown below along with their defaults in Windows 98SE:

HKEY_CLASSES_ROOT\AudioCD\shell
"Play"
HKEY_CLASSES_ROOT\AudioCD\shell\play
"&Play"
HKEY_CLASSES_ROOT\AudioCD\shell\play\command
"%SystemRoot%\cdplayer.exe /play %1"
HKEY_CLASSES_ROOT\DVD\shell
"Play"
HKEY_CLASSES_ROOT\DVD\shell\play
"&Play"
HKEY_CLASSES_ROOT\DVD\shell\play\command
"%SystemRoot%\system32\dvdplay.exe /play %1"

Volumes

AutoRun

If a file called autorun.inf exists in the root directory of the file system, settings in that file can add to the options presented to the user or affect the view AutoPlay has of the content. Under Windows XP, the existence of this file may affect the process flow - AutoRun can proceed to executing an application directly without user intervention. Under Windows Vista, AutoRun cannot bypass AutoPlay in this way; it can only add to the options presented to the user. The Inf handling section of the AutoRun article details when and whether AutoPlay is invoked.
The AutoRun layer initially consults Windows Registry values to decides whether to initiate actions for any particular drive or drive type. If AutoRun has been disabled for the newly discovered volume, then the process halts at that point, effectively disabling AutoPlay for that volume.

Content sniffing

After AutoRun completes, AutoPlay initiates by doing an examination of the volume for content. This is called content sniffing. AutoPlay decides whether the volume is an Audio CD, movie DVD, a blank recordable medium or a generic volume which contains files.
In the case of a generic volume, AutoPlay starts with the root directory and searches the file system to a depth of four directory levels below the root directory to find file types that fall into certain categories or "content types".
If this search takes more than a second or so, a progress dialog shows the scanning process taking place. This dialog can easily be confused with an Explorer copy operation; however, no files are being copied or moved.

Content types

As far as AutoPlay sniffing is concerned, files fall into three main categories or "content types". Files outside these categories are not of interest:
Pictures.jpg.gif.bmp.png...
Music.mp3.wav.wma...
Video.avi.mpg...

Content is considered to be "Mixed content" if files fall into more than one of the three categories.
Content is considered to be Unknown if the content sniffing process finds no categorisable content. This does not mean that there are no files present, just no files falling into one or more of the above three content types. In this case AutoPlay opens an Explorer window on the root directory of the medium and the process flow finishes here.