From 24094a266e24fff201c1d56fcf8c82b8155034fc Mon Sep 17 00:00:00 2001 From: Robin Oster Date: Wed, 12 Aug 2015 14:43:13 +0200 Subject: [PATCH] Update README --- README.md | 33 +++++++++++++++++++++++++++- Source/VideoThumbnailGenerator.swift | 2 +- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 92f4aae..1e7277b 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,38 @@ pod "ROThumbnailGenerator" ``` ## How to use -Todo +The ROThumbnail class is responsible for creating thumbnails by a given URL. The method `getThumbnail(url:NSURL)` does internally check the supported file types and uses the corresponding implementation of ROThumbnailGenerator. + +At the moment there are the following file types supported: + * PDF (.pdf) + * IMAGE (.png, .jpg, .jpeg) + * VIDEO (.mov, .m4a) + +You can retrieve the thumbnail of a given URL like that: +```swift +var thumbnailImage = ROThumbnail.sharedInstance.getThumbnail(fileUrl) +``` + +If you want to add a new implementation of the ROThumbnailGenerator you can do this by implementing the ROThumbnailGenerator class and define your supported file extensions you are going to handle with this implementation. + +Here is a small example: + +```swift +class ImageThumbnailGenerator : ROThumbnailGenerator { + + var supportedExtensions:Array = ["png", "jpg", "jpeg"] + + func getThumbnail(url:NSURL) -> UIImage { + return UIImage(data: NSData(contentsOfURL: url)!) ?? UIImage(named: "Piktogramm_IMAGE")! + } +} +``` + +You can add your implementation with the following call: +```swift +ROThumbnail.sharedInstance.addThumbnailGenerator(yourThumbnailGenerator) +``` + ## License diff --git a/Source/VideoThumbnailGenerator.swift b/Source/VideoThumbnailGenerator.swift index 0c4775b..dd9d424 100644 --- a/Source/VideoThumbnailGenerator.swift +++ b/Source/VideoThumbnailGenerator.swift @@ -11,7 +11,7 @@ import AVFoundation class VideoThumbnailGenerator : ROThumbnailGenerator { - var supportedExtensions:Array = ["mov"] + var supportedExtensions:Array = ["mov", "m4a"] func getThumbnail(url: NSURL) -> UIImage { if let asset:AVAsset = AVAsset.assetWithURL(url) as? AVAsset {