diff --git a/Aerial/Source/Controllers/PreferencesWindowController.swift b/Aerial/Source/Controllers/PreferencesWindowController.swift
index 37e8c600..ad27cf52 100644
--- a/Aerial/Source/Controllers/PreferencesWindowController.swift
+++ b/Aerial/Source/Controllers/PreferencesWindowController.swift
@@ -234,7 +234,10 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
}
let videoManager = VideoManager.sharedInstance
videoManager.addCallback { done, total in
- self.updateDownloads(done: done, total: total)
+ self.updateDownloads(done: done, total: total, progress: 0)
+ }
+ videoManager.addProgressCallback { done, total, progress in
+ self.updateDownloads(done: done, total: total, progress: progress)
}
self.fontManager.target = self
latitudeFormatter.maximumSignificantDigits = 10
@@ -651,18 +654,22 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
preferences.fadeMode = sender.indexOfSelectedItem
}
- func updateDownloads(done: Int, total: Int) {
- print("VMQueue: done : \(done) \(total)")
+ func updateDownloads(done: Int, total: Int, progress: Double) {
+ print("VMQueue: done : \(done) \(total) \(progress)")
+
if total == 0 {
downloadProgressIndicator.isHidden = true
downloadStopButton.isHidden = true
downloadNowButton.isEnabled = true
- } else {
+ } else if progress == 0 {
downloadNowButton.isEnabled = false
downloadProgressIndicator.isHidden = false
downloadStopButton.isHidden = false
downloadProgressIndicator.doubleValue = Double(done)
downloadProgressIndicator.maxValue = Double(total)
+ downloadProgressIndicator.toolTip = "\(done) / \(total) video(s) downloaded"
+ } else {
+ downloadProgressIndicator.doubleValue = Double(done) + progress
}
}
@@ -1535,9 +1542,6 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
count += 1
}
return count
-
- //let city = item as! City
- //return city.day.videos.count + city.night.videos.count
default:
return 0
}
diff --git a/Aerial/Source/Models/AerialVideo.swift b/Aerial/Source/Models/AerialVideo.swift
index a0e83e80..8823be55 100644
--- a/Aerial/Source/Models/AerialVideo.swift
+++ b/Aerial/Source/Models/AerialVideo.swift
@@ -102,33 +102,6 @@ class AerialVideo: CustomStringConvertible, Equatable {
}
return getClosestAvailable(wanted: preferences.videoFormat!)
-/* // We need to return the closest available format, not pretty
- if preferences.videoFormat == Preferences.VideoFormat.v4KHEVC.rawValue {
- if url4KHEVC != "" {
- return URL(string: self.url4KHEVC)!
- } else if url1080pHEVC != "" {
- return URL(string: self.url1080pHEVC)!
- } else {
- return URL(string: self.url1080pH264)!
- }
- } else if preferences.videoFormat == Preferences.VideoFormat.v1080pHEVC.rawValue {
- if url1080pHEVC != "" {
- return URL(string: self.url1080pHEVC)!
- } else if url1080pH264 != "" {
- return URL(string: self.url1080pH264)!
- } else {
- return URL(string: self.url4KHEVC)!
- }
- } else {
- if url1080pH264 != "" {
- return URL(string: self.url1080pH264)!
- } else if url1080pHEVC != "" {
- // With the latest versions, we should always have a H.264 fallback so this is just for future proofing
- return URL(string: self.url1080pHEVC)!
- } else {
- return URL(string: self.url4KHEVC)!
- }
- }*/
}
func getClosestAvailable(wanted: Int) -> URL {
diff --git a/Aerial/Source/Models/Cache/VideoManager.swift b/Aerial/Source/Models/Cache/VideoManager.swift
index de48bc52..97263742 100644
--- a/Aerial/Source/Models/Cache/VideoManager.swift
+++ b/Aerial/Source/Models/Cache/VideoManager.swift
@@ -8,10 +8,12 @@
import Foundation
typealias VideoManagerCallback = (Int, Int) -> Void
+typealias VideoProgressCallback = (Int, Int, Double) -> Void
class VideoManager: NSObject {
static let sharedInstance = VideoManager()
var managerCallbacks = [VideoManagerCallback]()
+ var progressCallbacks = [VideoProgressCallback]()
/// Dictionary of CheckCellView, keyed by the video.id
private var checkCells = [String: CheckCellView]()
@@ -47,6 +49,10 @@ class VideoManager: NSObject {
managerCallbacks.append(callback)
}
+ func addProgressCallback(_ callback:@escaping VideoProgressCallback) {
+ progressCallbacks.append(callback)
+ }
+
// Is the video queued for download ?
func isVideoQueued(id: String) -> Bool {
if queuedVideos.firstIndex(of: id) != nil {
@@ -119,6 +125,12 @@ class VideoManager: NSObject {
if let cell = checkCells[id] {
cell.updateProgressIndicator(progress: progress)
}
+ DispatchQueue.main.async {
+ // Callback the callbacks
+ for callback in self.progressCallbacks {
+ callback(self.totalQueued-self.queuedVideos.count, self.totalQueued, progress)
+ }
+ }
}
/// Cancel all queued operations
diff --git a/Aerial/Source/Views/CheckCellView.swift b/Aerial/Source/Views/CheckCellView.swift
index a672ee1d..ac1964e3 100644
--- a/Aerial/Source/Views/CheckCellView.swift
+++ b/Aerial/Source/Views/CheckCellView.swift
@@ -87,7 +87,6 @@ class CheckCellView: NSTableCellView {
queuedImage.isHidden = true
status = .downloading
}
-
progressIndicator.doubleValue = Double(progress)
}
diff --git a/Resources/Info.plist b/Resources/Info.plist
index af5a5136..3a443bef 100644
--- a/Resources/Info.plist
+++ b/Resources/Info.plist
@@ -15,11 +15,11 @@
CFBundlePackageType
BNDL
CFBundleShortVersionString
- 1.4.6beta2
+ 1.4.6beta3
CFBundleSignature
????
CFBundleVersion
- 1.4.6beta2
+ 1.4.6beta3
LSApplicationCategoryType
LSMinimumSystemVersion
diff --git a/Resources/PreferencesWindow.xib b/Resources/PreferencesWindow.xib
index 58ba01e3..3be80b47 100644
--- a/Resources/PreferencesWindow.xib
+++ b/Resources/PreferencesWindow.xib
@@ -137,7 +137,7 @@
-
+
@@ -216,7 +216,7 @@
-
+
-
+
@@ -234,7 +234,7 @@
-
+
@@ -243,7 +243,7 @@
-
-
+
+
-
+
@@ -1323,7 +1323,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required)
-
+
@@ -1726,7 +1726,7 @@ Shift, but macOS 10.12.4 or above and a compatible Mac are required)
-
+