-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from enebin/release/0.1.1
Release/0.1.1
- Loading branch information
Showing
19 changed files
with
593 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,7 @@ DerivedData/ | |
Aespa-test-env/cuckoo_generator | ||
|
||
Aespa-test-env/run | ||
|
||
Tests/Cuckoo/cuckoo_generator | ||
|
||
Tests/Cuckoo/run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// AespaCoreFileManager.swift | ||
// | ||
// | ||
// Created by 이영빈 on 2023/06/13. | ||
// | ||
|
||
import Foundation | ||
|
||
class AespaCoreFileManager { | ||
private var videoFileProxyDictionary: [String: VideoFileCachingProxy] | ||
private let enableCaching: Bool | ||
|
||
let systemFileManager: FileManager | ||
|
||
init( | ||
enableCaching: Bool, | ||
fileManager: FileManager = .default | ||
) { | ||
videoFileProxyDictionary = [:] | ||
self.enableCaching = enableCaching | ||
self.systemFileManager = fileManager | ||
} | ||
|
||
/// If `count` is `0`, return all existing files | ||
func fetch(albumName: String, count: Int) -> [VideoFile] { | ||
guard count >= 0 else { return [] } | ||
|
||
guard let proxy = videoFileProxyDictionary[albumName] else { | ||
videoFileProxyDictionary[albumName] = VideoFileCachingProxy( | ||
albumName: albumName, | ||
enableCaching: enableCaching, | ||
fileManager: systemFileManager) | ||
|
||
return fetch(albumName: albumName, count: count) | ||
} | ||
|
||
let files = proxy.fetch(count: count) | ||
Logger.log(message: "\(files.count) Video files fetched") | ||
return files | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// VideoFile.swift | ||
// | ||
// | ||
// Created by 이영빈 on 2023/06/13. | ||
// | ||
|
||
import UIKit | ||
import SwiftUI | ||
import AVFoundation | ||
|
||
/// `VideoFile` represents a video file with its associated metadata. | ||
/// | ||
/// This struct holds information about the video file, including a unique identifier (`id`), | ||
/// the path to the video file (`path`), and an optional thumbnail image (`thumbnail`) | ||
/// generated from the video. | ||
public struct VideoFile: Equatable { | ||
/// A `Date` value keeps the date it's generated | ||
public let generatedDate: Date | ||
|
||
/// The path to the video file. | ||
public let path: URL | ||
|
||
/// An optional thumbnail generated from the video with `UIImage` type. | ||
/// This will be `nil` if the thumbnail could not be generated for some reason. | ||
public var thumbnail: UIImage? | ||
} | ||
|
||
/// UI related extension methods | ||
public extension VideoFile { | ||
|
||
/// An optional thumbnail generated from the video with SwiftUI `Image` type. | ||
/// This will be `nil` if the thumbnail could not be generated for some reason. | ||
var thumbnailImage: Image? { | ||
if let thumbnail { | ||
return Image(uiImage: thumbnail) | ||
} | ||
|
||
return nil | ||
} | ||
} | ||
|
||
extension VideoFile: Identifiable { | ||
public var id: URL { | ||
self.path | ||
} | ||
} | ||
|
||
extension VideoFile: Comparable { | ||
public static func < (lhs: VideoFile, rhs: VideoFile) -> Bool { | ||
lhs.generatedDate > rhs.generatedDate | ||
} | ||
} |
Oops, something went wrong.