Browse Source

AudioCollectionViewCell: Adapt to configure also for movies in playlists

closes #439
Carola Nitz 6 years ago
parent
commit
872092e9fc
1 changed files with 12 additions and 1 deletions
  1. 12 1
      Sources/MediaCategoryCells/AudioCollectionViewCell.swift

+ 12 - 1
Sources/MediaCategoryCells/AudioCollectionViewCell.swift

@@ -21,12 +21,14 @@ class AudioCollectionViewCell: BaseCollectionViewCell {
 
     override var media: VLCMLObject? {
         didSet {
-            if let albumTrack = media as? VLCMLMedia {
+            if let albumTrack = media as? VLCMLMedia, albumTrack.subtype() == .albumTrack {
                 update(audiotrack:albumTrack)
             } else if let album = media as? VLCMLAlbum {
                 update(album:album)
             } else if let artist = media as? VLCMLArtist {
                 update(artist:artist)
+            } else if let movie = media as? VLCMLMedia, movie.subtype() == .unknown {
+                update(movie:movie)
             } else {
                 fatalError("needs to be of Type VLCMLMedia or VLCMLAlbum")
             }
@@ -68,6 +70,15 @@ class AudioCollectionViewCell: BaseCollectionViewCell {
         descriptionLabel.text = artist.numberOfTracksString()
     }
 
+    func update(movie: VLCMLMedia) {
+        titleLabel.text = movie.title
+        descriptionLabel.text = movie.mediaDuration()
+        if movie.isThumbnailGenerated() {
+            thumbnailView.image = UIImage(contentsOfFile: movie.thumbnail.absoluteString)
+        }
+        newLabel.isHidden = !movie.isNew()
+    }
+
     override class func cellSizeForWidth(_ width: CGFloat) -> CGSize {
         let numberOfCells: CGFloat
         if width <= DeviceWidth.iPhonePortrait.rawValue {