diff --git a/Musgravite.xcworkspace/xcuserdata/Luna.xcuserdatad/UserInterfaceState.xcuserstate b/Musgravite.xcworkspace/xcuserdata/Luna.xcuserdatad/UserInterfaceState.xcuserstate index 6eeb218..4a79836 100644 Binary files a/Musgravite.xcworkspace/xcuserdata/Luna.xcuserdatad/UserInterfaceState.xcuserstate and b/Musgravite.xcworkspace/xcuserdata/Luna.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Musgravite.xcworkspace/xcuserdata/Luna.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Musgravite.xcworkspace/xcuserdata/Luna.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 79f6512..ce71171 100644 --- a/Musgravite.xcworkspace/xcuserdata/Luna.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Musgravite.xcworkspace/xcuserdata/Luna.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -10,11 +10,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Musgravite/Controller/DetailViewController.swift" - timestampString = "564866494.833429" + timestampString = "564868373.942006" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "195" - endingLineNumber = "195" + startingLineNumber = "197" + endingLineNumber = "197" landmarkName = "getData(_:_:_:)" landmarkType = "7"> @@ -42,11 +42,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Musgravite/Controller/DetailViewController.swift" - timestampString = "564866494.8340271" + timestampString = "564868373.94261" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "196" - endingLineNumber = "196" + startingLineNumber = "198" + endingLineNumber = "198" landmarkName = "getData(_:_:_:)" landmarkType = "7"> diff --git a/Musgravite/Controller/DetailViewController.swift b/Musgravite/Controller/DetailViewController.swift index 8a8d7bc..3471e29 100644 --- a/Musgravite/Controller/DetailViewController.swift +++ b/Musgravite/Controller/DetailViewController.swift @@ -14,6 +14,8 @@ import Alamofire import SwiftMessages import WatchConnectivity import MapKit +import CoreMedia +import AVFoundation class DetailViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, WCSessionDelegate, MKMapViewDelegate, CLLocationManagerDelegate { /* WCSessionDelegate */ @@ -246,19 +248,39 @@ class DetailViewController: UIViewController, UICollectionViewDelegate, UICollec return cell }else if collectionView.tag == 2{ let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "VideoDetailCollectionViewCell", for: indexPath) as! VideoDetailCollectionViewCell - cell.title.text = labInformation!["video"].arrayValue[indexPath.item].stringValue - cell.image.image = UIImage(named: "grad12") + cell.title.text = URL(string: labInformation!["video"].arrayValue[indexPath.item].stringValue)?.lastPathComponent + DispatchQueue.global(qos: .background).async { + let dimage = self.downloadThumbnail(self.labInformation!["video"].arrayValue[indexPath.item].stringValue) + DispatchQueue.main.async { + cell.image.image = dimage + } + } return cell } else if collectionView.tag == 3 { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ModelCellView", for: indexPath) as! ModelCollectionViewCell - cell.image.image = UIImage(named: "grad12") - cell.label.text = labInformation!["material"].arrayValue[indexPath.item].stringValue + cell.image.image = UtilityFunctions().getRandomBackground() + cell.label.text = URL(string: labInformation!["material"].arrayValue[indexPath.item].stringValue)?.lastPathComponent return cell } else { return UICollectionViewCell() } } + func downloadThumbnail(_ path:String) -> UIImage { + do { + let asset = AVURLAsset(url: URL(string: path)! , options: nil) + let imgGenerator = AVAssetImageGenerator(asset: asset) + imgGenerator.appliesPreferredTrackTransform = true + let cgImage = try imgGenerator.copyCGImage(at: CMTimeMake(value: 0, timescale: 1), actualTime: nil) + let thumbnail = UIImage(cgImage: cgImage) + return thumbnail + } catch let error { + print("*** Error generating thumbnail: \(error.localizedDescription)") + return UIImage() + } + } + + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { if collectionView.tag == 1 { return diff --git a/Musgravite/View/Base.lproj/Main.storyboard b/Musgravite/View/Base.lproj/Main.storyboard index 0fffde4..d5d08dc 100644 --- a/Musgravite/View/Base.lproj/Main.storyboard +++ b/Musgravite/View/Base.lproj/Main.storyboard @@ -644,7 +644,7 @@ - +