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

VLCMLMedia: Simplify equality

parent 4a1e3eff
......@@ -27,12 +27,9 @@ class AudioModel: MLBaseModel {
}
func append(_ item: VLCMLMedia) {
for file in files {
if file.identifier() == item.identifier() {
return
}
if !files.contains { $0 == item } {
files.append(item)
}
files.append(item)
}
func delete(_ items: [VLCMLObject]) {
......
......@@ -28,12 +28,9 @@ class VideoModel: MLBaseModel {
}
func append(_ item: VLCMLMedia) {
for file in files {
if file.identifier() == item.identifier() {
return
}
if !files.contains { $0 == item } {
files.append(item)
}
files.append(item)
}
func delete(_ items: [VLCMLObject]) {
......@@ -81,11 +78,22 @@ extension VideoModel: MediaLibraryObserver {
extension VideoModel {
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?()
}
}
extension VLCMLMedia {
static func == (lhs: VLCMLMedia, rhs: VLCMLMedia) -> Bool {
return lhs.identifier() == rhs.identifier()
}
}
extension VLCMLMedia {
@objc func formatDuration() -> String {
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