Commit 6741ba71 authored by Soomin Lee's avatar Soomin Lee
Browse files

VLCMLMedia: Simplify equality

parent 4a1e3eff
...@@ -27,12 +27,9 @@ class AudioModel: MLBaseModel { ...@@ -27,12 +27,9 @@ class AudioModel: MLBaseModel {
} }
func append(_ item: VLCMLMedia) { func append(_ item: VLCMLMedia) {
for file in files { if !files.contains { $0 == item } {
if file.identifier() == item.identifier() { files.append(item)
return
}
} }
files.append(item)
} }
func delete(_ items: [VLCMLObject]) { func delete(_ items: [VLCMLObject]) {
......
...@@ -28,12 +28,9 @@ class VideoModel: MLBaseModel { ...@@ -28,12 +28,9 @@ class VideoModel: MLBaseModel {
} }
func append(_ item: VLCMLMedia) { func append(_ item: VLCMLMedia) {
for file in files { if !files.contains { $0 == item } {
if file.identifier() == item.identifier() { files.append(item)
return
}
} }
files.append(item)
} }
func delete(_ items: [VLCMLObject]) { func delete(_ items: [VLCMLObject]) {
...@@ -81,11 +78,22 @@ extension VideoModel: MediaLibraryObserver { ...@@ -81,11 +78,22 @@ extension VideoModel: MediaLibraryObserver {
extension VideoModel { extension VideoModel {
func medialibrary(_ medialibrary: VLCMediaLibraryManager, thumbnailReady media: VLCMLMedia) { func medialibrary(_ medialibrary: VLCMediaLibraryManager, thumbnailReady media: VLCMLMedia) {
print("VideoModel: thumbnailReady for: \(media) with image: \(media.thumbnail)") for (index, file) in files.enumerated() {
if file == media {
files[index] = media
break
}
}
updateView?() updateView?()
} }
} }
extension VLCMLMedia {
static func == (lhs: VLCMLMedia, rhs: VLCMLMedia) -> Bool {
return lhs.identifier() == rhs.identifier()
}
}
extension VLCMLMedia { extension VLCMLMedia {
@objc func formatDuration() -> String { @objc func formatDuration() -> String {
return String(format: "%@", VLCTime(int: Int32(duration()))) return String(format: "%@", VLCTime(int: Int32(duration())))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment