chrome.mediaGalleries
- Description
Use the
chrome.mediaGalleries
API to access media files (audio, images, video) from the user's local disks (with the user's consent). - Permissions
mediaGalleries
Summary
- Types
- Methods
mediaGalleries.addGalleryWatch(galleryId: string, callback: function)
mediaGalleries.addUserSelectedFolder(callback: function)
mediaGalleries.getMediaFileSystemMetadata(mediaFileSystem: DOMFileSystem): MediaFileSystemMetadata
mediaGalleries.getMediaFileSystems(details?: MediaFileSystemsDetails, callback: function)
mediaGalleries.getMetadata(mediaFile: Blob, options?: MediaMetadataOptions, callback: function)
mediaGalleries.removeGalleryWatch(galleryId: string)
- Events
Types
AddGalleryWatchResult
Properties
- galleryIdstring
- successboolean
GalleryChangeDetails
Properties
- galleryIdstring
Identifies the modified gallery.
Type of change event.
MediaFileSystemMetadata
Properties
- deviceIdstring optional
If the media gallery is on a removable device, a unique id for the device while the device is online.
- galleryIdstring
A unique and persistent id for the media gallery.
- isAvailableboolean
True if the device is currently available.
- isMediaDeviceboolean
True if the device the media gallery is on was detected as a media device. i.e. a PTP or MTP device, or a DCIM directory is present.
- isRemovableboolean
True if the media gallery is on a removable device.
- namestring
The name of the file system.
MediaFileSystemsDetails
Properties
- interactiveGetMediaFileSystemsInteractivity optional
Whether to prompt the user for permission to additional media galleries before returning the permitted set. Default is silent. If the value 'yes' is passed, or if the application has not been granted access to any media galleries and the value 'if_needed' is passed, then the media gallery configuration dialog will be displayed.
MediaMetadata
Properties
- albumstring optional
Defined for audio and video.
- artiststring optional
- attachedImagesBlob[]
The images embedded in the media file's metadata. This is most often used for album art or video thumbnails.
- commentstring optional
- copyrightstring optional
- discnumber optional
- durationnumber optional
Defined for audio and video. In seconds.
- genrestring optional
- heightnumber optional
Defined for video. In pixels.
- languagestring optional
- mimeTypestring
The browser sniffed mime type.
- rawTags
All the metadata in the media file. For formats with multiple streams, stream order will be preserved. Container metadata is the first element.
- rotationnumber optional
Defined for video. In degrees.
- titlestring optional
- tracknumber optional
- widthnumber optional
MediaMetadataOptions
Properties
- metadataTypeGetMetadataType optional
Specifies which subset of the metadata to retrieve. Defaults to 'all' if the option is omitted.
StreamInfo
Properties
- tagsobject
An unfiltered string->string dictionary of tags for the stream.
- typestring
Describes format of container or codec of stream, i.e. "mp3", "h264".
GalleryChangeType
Enum
"contents_changed"
, or "watch_dropped"
GetMediaFileSystemsInteractivity
Enum
"no"
, "yes"
, or "if_needed"
GetMetadataType
Enum
"all"
, "mimeTypeAndTags"
, or "mimeTypeOnly"
Methods
addGalleryWatch
mediaGalleries.addGalleryWatch(galleryId: string, callback: function)
Adds a gallery watch for the gallery with the specified gallery ID. The given callback is then fired with a success or failure result.
Parameters
- galleryIdstring
- callbackfunction
The callback parameter should be a function that looks like this:
(result: AddGalleryWatchResult) => {...}
- result
addUserSelectedFolder
mediaGalleries.addUserSelectedFolder(callback: function)
Present a directory picker to the user and add the selected directory as a gallery. If the user cancels the picker, selectedFileSystemName will be empty. A user gesture is required for the dialog to display. Without a user gesture, the callback will run as though the user canceled.
Parameters
- callbackfunction
The callback parameter should be a function that looks like this:
(mediaFileSystems: DOMFileSystem[], selectedFileSystemName: string) => {...}
- mediaFileSystemsDOMFileSystem[]
- selectedFileSystemNamestring
getMediaFileSystemMetadata
mediaGalleries.getMediaFileSystemMetadata(mediaFileSystem: DOMFileSystem): MediaFileSystemMetadata
Get metadata about a specific media file system.
Parameters
- mediaFileSystemDOMFileSystem
Returns
- returns
getMediaFileSystems
mediaGalleries.getMediaFileSystems(details?: MediaFileSystemsDetails, callback: function)
Get the media galleries configured in this user agent. If none are configured or available, the callback will receive an empty array.
Parameters
- detailsMediaFileSystemsDetails optional
- callbackfunction
The callback parameter should be a function that looks like this:
(mediaFileSystems: DOMFileSystem[]) => {...}
- mediaFileSystemsDOMFileSystem[]
getMetadata
mediaGalleries.getMetadata(mediaFile: Blob, options?: MediaMetadataOptions, callback: function)
Gets the media-specific metadata for a media file. This should work for files in media galleries as well as other DOM filesystems.
Parameters
- mediaFileBlob
- optionsMediaMetadataOptions optional
- callbackfunction
The callback parameter should be a function that looks like this:
(metadata: MediaMetadata) => {...}
- metadata
removeGalleryWatch
mediaGalleries.removeGalleryWatch(galleryId: string)
Removes a gallery watch for the gallery with the specified gallery ID.
Parameters
- galleryIdstring
Events
onGalleryChanged
mediaGalleries.onGalleryChanged.addListener(listener: function)
Fired when a media gallery is changed or a gallery watch is dropped.
Event
- listenerfunction
The listener parameter should be a function that looks like this:
(details: GalleryChangeDetails) => {...}
- details