Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Oster committed Aug 12, 2015
1 parent 85e577d commit 24094a2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = ["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

Expand Down
2 changes: 1 addition & 1 deletion Source/VideoThumbnailGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import AVFoundation

class VideoThumbnailGenerator : ROThumbnailGenerator {

var supportedExtensions:Array<String> = ["mov"]
var supportedExtensions:Array<String> = ["mov", "m4a"]

func getThumbnail(url: NSURL) -> UIImage {
if let asset:AVAsset = AVAsset.assetWithURL(url) as? AVAsset {
Expand Down

0 comments on commit 24094a2

Please sign in to comment.