1 <h2 id="usage">Usage</h2>
3 <p>The mediaGalleries API lets you prompt the user for permission to access
4 media galleries on the user's computer. The permission dialog contains common
5 media locations for the platform and allows the user to specify additional
6 locations. From those locations, only media files will be present in the file
9 <h2 id="manifest">Manifest</h2>
11 <p>The media galleries API has two axes of permission parameters:</p>
14 <li>the locations that can be accessed</li>
15 <li>the type of access</li>
18 <p>These two axes and the permission parameters on each axis are described
19 in the table below:</p>
28 <td rowspan="2">Locations</td>
31 If you do not specify a location permission parameter, your app will
32 not be able to access any media galleries until the user grants
33 permission to access specific media galleries at runtime using the
34 media gallery permission dialog.
38 <td>"allAutoDetected"</td>
40 Grants your app access to all auto-detected media galleries on the
41 user's computer. This permission causes an install-time prompt to be
42 displayed indicating that the app will have access to the user's media
47 <td rowspan="2">Access type</td>
49 <td>Grants your app the right to read files in media galleries.</td>
54 Grants your app the right to copy files into media galleries.
55 Only valid media files that Chrome is capable of playing or displaying
56 are permitted; files that Chrome is not able to validate will result
57 in a security error. "read" permission is a prerequisite for "copyTo".
58 Specify both "read" and "copyTo" to obtain both types of permissions to
66 <li>The media gallery permission dialog can be triggered programmatically.
67 The user may have alternate media locations, so even if you specify
68 "allAutoDetected" permsission, it is still important to provide a mechanism
69 to open the permission dialog in your app.</li>
71 <li>There is no write access to media galleries due to the
72 file validation requirement. However, you can write files to
73 a different file system like the temporary file system, and then copy
74 the files into the desired media gallery.</li>
76 <li>Access type permissions do not trigger an install-time prompt
77 by themselves. However, the type of access will be reflected in the
78 media gallery permission dialog, as well as the install-time prompt if
79 "allAutoDetected" permission is requested.</li>
82 <p>Below is an example of a manifest file with mediaGalleries permissions:</p>
84 <pre data-filename="manifest.json">
89 <b>{ "mediaGalleries": ["read", "allAutoDetected"] }</b>
95 <p>This example manifest file will trigger an install-time permission prompt,
96 and let the app read from all auto-detected media galleries on the
97 user's computer. The user may add or remove galleries using the
98 media gallery permission dialog, after which the app will be able
99 to read all the media files from galleries that the user selected.</p>
101 <h2 id="iTunes">iTunes</h2>
103 <p>If present, the user's iTunes library can be accessed as a media gallery.
104 In addition to the media files in the library, the "iTunes Music Library.xml"
105 file is also presented. Regardless of where the music files are actually on the
106 disk (and where the xml file says they are), they are mapping into an
107 Artist/Album/Track hierarchy like iTunes does by default. This mapping doesn't
108 always work perfectly, so there are two things to note for Apps trying to match
109 the xml file with files in the gallery. If the filenames for tracks within an
110 album are not unique, they will be uniquified by adding the track id in
111 parentheses before the extension, and if there is a colon or a slash in the
112 artist, album, or track name, they are turned into underscore characters.</p>