MediaStore

public protocol MediaStore : Peripheral

Aggregated media store. Contains information on all medias stored on a device, aggregating media on different stores.

  • Current indexing state of the media store.

    Declaration

    Swift

    var indexingState: MediaStoreIndexingState { get }
  • Total number of photo medias in the media store.

    Declaration

    Swift

    var photoMediaCount: Int { get }
  • Total number of video medias in the media store.

    Declaration

    Swift

    var videoMediaCount: Int { get }
  • Total number of photo resources in the media store.

    Declaration

    Swift

    var photoResourceCount: Int { get }
  • Total number of video resources in the media store.

    Declaration

    Swift

    var videoResourceCount: Int { get }
  • Creates a new Media list.

    This function starts loading the media store content, and notifies when it has been loaded and each time the content changes.

    Declaration

    Swift

    func newList(observer: @escaping (_ medias: [MediaItem]?) -> Void) -> Ref<[MediaItem]>

    Parameters

    observer

    observer which gets notified when the media list loads or changes

    medias

    list media, nil if the store has been removed

    Return Value

    a reference on a list of MediaItem. Caller must keep this instance referenced for the observer to be called.

  • Creates a new Media list for a specific storage.

    This function starts loading the media store content on a specific storage, and notifies when it has been loaded and each time the content changes.

    Note

    if storage is nil, MediaItems in any storage are returned in the list.

    Declaration

    Swift

    func newList(storage: StorageType?,
                 observer: @escaping (_ medias: [MediaItem]?) -> Void) -> Ref<[MediaItem]>

    Parameters

    storage

    storage type on which the Media list will be created

    observer

    observer which gets notified when the media list loads or changes

    medias

    list media, nil if the store has been removed

    Return Value

    a reference on a list of MediaItem. Caller must keep this instance referenced for the observer to be called.

  • Creates a new media thumbnail downloader.

    Note

    Typical usage in a UITableView is to call newMediaThumbnailDownloader() in UITableViewDataSource.(tableView:cellForRowAt:) and store the returned Ref<UIImage> inside the UITableViewCell. Then in the UITableViewCell.prepareForReuse() function set the stored Ref<UIImage> to nil to cancel the download request.

    Declaration

    Swift

    func newThumbnailDownloader(media: MediaItem,
                                observer: @escaping (_ thumbnail: UIImage?) -> Void) -> Ref<UIImage>

    Parameters

    media

    media item to download the thumbnail from

    observer

    observer called when the thumbnail has been downloaded. Observer is called immediately if the thumbnail is already cached

    thumbnail

    loaded or cached thumbnail, nil if the thumbnail can’t be downloaded

    Return Value

    A reference of the media downloader. Caller must keep this instance referenced for the observer to be called.

  • Create a new resource thumbnail downloader.

    Note

    Typical usage in a UITableView is to call newMediaThumbnailDownloader() in UITableViewDataSource.(tableView:cellForRowAt:) and store the returned Ref<UIImage> inside the UITableViewCell. Then in the UITableViewCell.prepareForReuse() function set the stored Ref<UIImage> to nil to cancel the download request.

    Declaration

    Swift

    func newThumbnailDownloader(resource: MediaItem.Resource,
                                observer: @escaping (_ thumbnail: UIImage?) -> Void) -> Ref<UIImage>

    Parameters

    resource

    resource item to download the thumbnail from

    observer

    observer called when the thumbnail has been downloaded. Observer is called immediately if the thumbnail is already cached

    thumbnail

    loaded or cached thumbnail, nil if the thumbnail can’t be downloaded

    Return Value

    A reference of the resource downloader. Caller must keep this instance referenced for the observer to be called.

  • Creates a new media resource downloader.

    Note

    If full type is selected (default), signatures will also be downloaded. If preview type is selected, no signature will be downloaded and videos will be ignored.

    Default Implementation

    Creates a new media resource downloader.

    Declaration

    Swift

    func newDownloader(mediaResources: MediaResourceList, type: DownloadType, destination: DownloadDestination,
                       observer: @escaping (_ downloader: MediaDownloader?) -> Void) -> Ref<MediaDownloader>

    Parameters

    mediaResources

    list of media resources to download

    type

    download type

    destination

    download destination

    observer

    observer called when the MediaDownloader changes, indicating download progress

    Return Value

    a reference on a MediaDownloader. Caller must keep this instance referenced until all media are downloaded. Setting it to nil cancels the download.

  • Creates a new media resource uploader.

    Resource files will be uploaded to the device’s internal storage, in the order defined by the specified resources array.

    Declaration

    Swift

    func newUploader(resources: [URL], target: MediaItem,
                     observer: @escaping (_ uploader: ResourceUploader?) -> Void) -> Ref<ResourceUploader>

    Parameters

    resources

    resource files to upload

    target

    target media item to attach uploaded resource files to

    observer

    observer called when the ResourceUploader changes, indicating upload progress and status

    Return Value

    a reference on a ResourceUploader. Caller must keep this instance referenced for the observer to be called. Setting it to nil cancels the upload.

  • Creates a new Media deleter, to delete a list of media.

    Declaration

    Swift

    func newDeleter(medias: [MediaItem],
                    observer: @escaping (_ deleter: MediaDeleter?) -> Void) -> Ref<MediaDeleter>

    Parameters

    medias

    medias to delete.

    observer

    observer called when the MediaDeleter changes, indicating progress of the delete task. Referenced media deleter is nil if the delete task was interrupted.

    deleter

    deleter storing the delete progress info

    Return Value

    a reference on a MediaDeleter. Caller must keep this instance referenced until all media are deleted. Setting it to nil cancels the delete.

  • Creates a new Media deleter, to delete a list of media resources.

    Declaration

    Swift

    func newDeleter(mediaResources: MediaResourceList,
                    observer: @escaping (_ deleter: MediaDeleter?) -> Void) -> Ref<MediaDeleter>

    Parameters

    mediaResources

    list of media resources to delete

    observer

    observer called with MediaDeleter changes, indicating progress of the delete task. Referenced media deleter is nil if the delete task was interrupted.

    deleter

    deleter storing the delete progress info

    Return Value

    a reference on a MediaDeleter. Caller must keep this instance referenced until all media are deleted. Setting it to nil cancels the delete.

  • Creates a new media deleter to delete all medias.

    Declaration

    Swift

    func newAllMediasDeleter(observer: @escaping (_ deleter: AllMediasDeleter?) -> Void) -> Ref<AllMediasDeleter>

    Parameters

    observer

    observer called when AllMediasDeleter changes, indicating progress of the delete task. Referenced media deleter is nil if the delete task was interrupted.

    deleter

    deleter storing the delete progress info

    Return Value

    a reference on a AllMediaDeleter. Caller must keep this instance referenced until all media are deleted. Setting it to nil cancels the delete.