Dela via


Auto-launching with AutoPlay (XAML)

Purpose

You can use AutoPlay to provide your app as an option when a user connects a device to their PC. This includes non-volume devices such as a camera or media player, or volume devices such as a USB thumb drive, SD card, or DVD. You can also use AutoPlay to offer your app as an option when users share files between two PCs by using proximity (tapping).

In this section

Topic Description

Quickstart: Register an app for AutoPlay content

You can register apps as options for AutoPlay content events. AutoPlay content events are raised when a volume device such as a camera memory card, thumb drive, or DVD is inserted into the PC.

Quickstart: Register an app for an AutoPlay device

You can register apps as options for AutoPlay device events. AutoPlay device events are raised when a device is connected to a PC.

Quickstart: Configure removable storage as an AutoPlay device

You can identify a volume device such as a memory card or thumb drive as an AutoPlay device when the volume device is connected to a PC. This is especially useful when you want to associate a specific app for AutoPlay to present to the user for your volume device.

 

Developer audience

Developers use AutoPlay when they create apps that respond to a user initiated device connection. You can use AutoPlay to perform an action on the user's behalf by offering a handler for a particular device. When a user connects a device, AutoPlay determines the type of device and raises either a device event for non-volume devices, or a content event for volume devices. You can register for the event that corresponds to your app by adding a Declaration in your application manifest for the specific event type. After you have built and deployed your app, AutoPlay recognizes the declaration for the app. AutoPlay then includes it in the list of possible actions that a user can take to respond to that event. For an example, see Quickstart: Register an app for AutoPlay content.

You can also perform an action when a user has received files that are shared by using proximity (tapping). In this case, the files are placed in a temporary folder on the target PC and AutoPlay raises a content event based on the type of files shared.

Note  If you are a device manufacturer and you want to associate your Windows Store device app as an AutoPlay handler for your device, you can identify that app in the device metadata. For more info, see AutoPlay for Windows Store device apps.

 

AutoPlay Events

The AutoPlay system allows apps to register for a variety of device and volume (disk) arrival events. To register for AutoPlay content events, you must enable the Removable Storage capability in your package manifest. This table shows the events that you can register for and when they are raised.

Scenario Event Description
Using photos on a Camera WPD\ImageSource Raised for cameras that are identified as Windows Portable Devices and offer the ImageSource capability.
Using music on an audio player WPD\AudioSource Raised for media players that are identified as Windows Portable Devices and offer the AudioSource capability.
Using videos on a video camera WPD\VideoSource Raised for video cameras that are identified as Windows Portable Devices and offer the VideoSource capability.
Access a connected flash drive or external hard drive StorageOnArrival Raised when a drive or volume is connected to the PC.   If the drive or volume contains a DCIM, AVCHD, or PRIVATE\ACHD folder in the root of the disk, the ShowPicturesOnArrival event is raised instead.
Using photos from mass storage (legacy) ShowPicturesOnArrival Raised when a drive or volume contains a DCIM, AVCHD, or PRIVATE\ACHD folder in the root of the disk. IIf a user  has enabled Choose what to do with each type of media in the AutoPlay Control Panel, AutoPlay will examine a volume connected to the PC to determine the type of content on the disk. When pictures are found, ShowPicturesOnArrival is raised.
Receiving photos with Proximity Sharing (tap and send) ShowPicturesOnArrival When users send content with using proximity (tap and send), AutoPlay will examine the shared files to determine the type of content. If pictures are found, ShowPicturesOnArrival is raised.
Using music from mass storage (legacy) PlayMusicFilesOnArrival If a user has enabled Choose what to do with each type of media in the AutoPlay Control Panel, AutoPlay will examine a volume connected to the PC to determine the type of content on the disk.  When music files are found, PlayMusicFilesOnArrival is raised.
Receiving music with Proximity Sharing (tap and send) PlayMusicFilesOnArrival When users send content with using proximity (tap and send), AutoPlay will examine the shared files to determine the type of content. If music files are found, PlayMusicFilesOnArrival is raised.
Using videos from mass storage (legacy) PlayVideoFilesOnArrival If a user has enabled Choose what to do with each type of media in the AutoPlay Control Panel,, AutoPlay will examine a volume connected to the PC to determine the type of content on the disk. When video files are found, PlayVideoFilesOnArrival is raised.
Receiving videos with Proximity Sharing (tap and send) PlayVideoFilesOnArrival When users send content with using proximity (tap and send), AutoPlay will examine the shared files to determine the type of content. If video files are found, PlayVideoFilesOnArrival is raised.
Handling mixed sets of files from a connected device MixedContentOnArrival If a user has enabled Choose what to do with each type of media in the AutoPlay Control Panel, AutoPlay will examine a volume connected to the PC to determine the type of content on the disk. If no specific content type is found (for example, pictures), MixedContentOnArrival is raised.
Handling mixed sets of files with Proximity Sharing (tap and send) MixedContentOnArrival When users send content with using proximity (tap and send), AutoPlay will examine the shared files to determine the type of content. If no specific content type is found (for example, pictures), MixedContentOnArrival is raised.
Handle video from optical media

PlayDVDMovieOnArrival

PlayBluRayOnArrival

PlayVideoCDMovieOnArrival

PlaySuperVideoCDMovieOnArrival

Handle music from optical media

PlayCDAudioOnArrival

PlayDVDAudioOnArrival

Play enhanced disks

PlayEnhancedCDOnArrival

PlayEnhancedDVDOnArrival

Handle writeable optical disks

HandleCDBurningOnArrival

HandleDVDBurningOnArrival

HandleBDBurningOnArrival

Handle any other device or volume connection UnknownContentOnArrival Raised for all events in case content is found that does not match any of the AutoPlay content events. Use of this event is not recommended. You should only register your application for the specific AutoPlay events that it can handle.

 

You can specify that AutoPlay raise a custom AutoPlay Content event using the CustomEvent entry in the autorun.inf file for a volume. For more info, see Autorun.inf entries.

You can register your app as an AutoPlay Content or AutoPlay Device event handler by adding an extension to the package.appxmanifest file for your app. If you are using Microsoft Visual Studio, you can add an AutoPlay Content or AutoPlay Device declaration in the Declarations tab. For an example, see Quickstart: Register an app for AutoPlay content. If you are editing the package.appxmanifest file for your app directly, add an Extension element to your package manifest that specifies either windows.autoPlayContent or windows.autoPlayDevice as the Category. For example, the following entry in the package manifest adds an AutoPlay Content extension to register the app as a handler for the ShowPicturesOnArrival event.

  <Applications>
    <Application Id="AutoPlayHandlerSample.App">
      <Extensions>
        <Extension Category="windows.autoPlayContent">
          <AutoPlayContent>
            <LaunchAction Verb="show" ActionDisplayName="Show Pictures" 
                          ContentEvent="ShowPicturesOnArrival" />
          </AutoPlayContent>
        </Extension>
      </Extensions>
    </Application>
  </Applications>

Roadmap for Windows Runtime apps using C# or Visual Basic