- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / common / extensions / docs / templates / intros / mediaGalleries.html
1 <h2 id="usage">Usage</h2>
2
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
7 system objects.</p>
8
9 <h2 id="manifest">Manifest</h2>
10
11 <p>The media galleries API has two axes of permission parameters:</p>
12
13 <ul>
14   <li>the locations that can be accessed</li>
15   <li>the type of access</li>
16 </ul>
17
18 <p>These two axes and the permission parameters on each axis are described
19 in the table below:</p>
20
21 <table>
22     <tr>
23       <th>Axis</th>
24       <th>Parameter</th>
25       <th>Effect</th>
26     </tr>
27     <tr>
28       <td rowspan="2">Locations</td>
29       <td>none</td>
30       <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.
35       </td>
36     </tr>
37     <tr>
38       <td>"allAutoDetected"</td>
39       <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
43         files.
44       </td>
45     </tr>
46     <tr>
47       <td rowspan="2">Access&nbsp;type</td>
48       <td>"read"</td>
49       <td>Grants your app the right to read files in media galleries.</td>
50     </tr>
51     <tr>
52       <td>"copyTo"</td>
53       <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
59         media galleries.
60       </td>
61     </tr>
62 </table>
63
64 <p>Notes:</p>
65 <ul>
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>
70
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>
75
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>
80 </ul>
81
82 <p>Below is an example of a manifest file with mediaGalleries permissions:</p>
83
84 <pre data-filename="manifest.json">
85 {
86   "name": "My app",
87   ...
88   "permissions": [
89     <b>{ "mediaGalleries": ["read", "allAutoDetected"] }</b>
90   ],
91   ...
92 }
93 </pre>
94
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>
100
101 <h2 id="iTunes">iTunes</h2>
102
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>