Welcome What's new in Chrome extensions Getting started API Reference Samples
Welcome What's new in Chrome extensions Getting started API Reference Samples

chrome.mediaGalleries

This API is part of the deprecated Chrome Apps platform. Learn more about migrating your app.
  • 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

AddGalleryWatchResult

Properties

  • galleryId
    string
  • success
    boolean

GalleryChangeDetails

Properties

  • galleryId
    string

    Identifies the modified gallery.

  • Type of change event.

MediaFileSystemMetadata

Properties

  • deviceId
    string optional

    If the media gallery is on a removable device, a unique id for the device while the device is online.

  • galleryId
    string

    A unique and persistent id for the media gallery.

  • isAvailable
    boolean

    True if the device is currently available.

  • isMediaDevice
    boolean

    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.

  • isRemovable
    boolean

    True if the media gallery is on a removable device.

  • name
    string

    The name of the file system.

MediaFileSystemsDetails

Properties

  • 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

  • album
    string optional

    Defined for audio and video.

  • artist
    string optional
  • attachedImages
    Blob[]

    The images embedded in the media file's metadata. This is most often used for album art or video thumbnails.

  • comment
    string optional
  • copyright
    string optional
  • disc
    number optional
  • duration
    number optional

    Defined for audio and video. In seconds.

  • genre
    string optional
  • height
    number optional

    Defined for video. In pixels.

  • language
    string optional
  • mimeType
    string

    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.

  • rotation
    number optional

    Defined for video. In degrees.

  • title
    string optional
  • track
    number optional
  • width
    number optional

MediaMetadataOptions

Properties

  • metadataType

    Specifies which subset of the metadata to retrieve. Defaults to 'all' if the option is omitted.

StreamInfo

Properties

  • tags
    object

    An unfiltered string->string dictionary of tags for the stream.

  • type
    string

    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

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

  • callback
    function

    The callback parameter should be a function that looks like this:

    (mediaFileSystems: DOMFileSystem[], selectedFileSystemName: string) => {...}
    • mediaFileSystems
      DOMFileSystem[]
    • selectedFileSystemName
      string

getMediaFileSystemMetadata

mediaGalleries.getMediaFileSystemMetadata(mediaFileSystem: DOMFileSystem): MediaFileSystemMetadata

Get metadata about a specific media file system.

Parameters

  • mediaFileSystem
    DOMFileSystem

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

  • details
  • callback
    function

    The callback parameter should be a function that looks like this:

    (mediaFileSystems: DOMFileSystem[]) => {...}
    • mediaFileSystems
      DOMFileSystem[]

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

removeGalleryWatch

mediaGalleries.removeGalleryWatch(galleryId: string)

Removes a gallery watch for the gallery with the specified gallery ID.

Parameters

  • galleryId
    string

Events

onGalleryChanged

mediaGalleries.onGalleryChanged.addListener(listener: function)

Fired when a media gallery is changed or a gallery watch is dropped.

Event

We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.