@@ -527,7 +527,7 @@ class TagEditorWindow: NSWindowController, NSTextFieldDelegate, NSWindowDelegate
527
527
@IBOutlet weak var locationPathControl : NSPathControl !
528
528
529
529
func populateFileInfo( ) {
530
- //todo correct tags if inconsistent
530
+ //todo touch the actual file if we have to
531
531
let url = NSURL ( string: self . currentTrack!. location!) !
532
532
self . locationPathControl. url = url as URL
533
533
@@ -537,17 +537,29 @@ class TagEditorWindow: NSWindowController, NSTextFieldDelegate, NSWindowDelegate
537
537
flacMDItem? . initForMetadata ( )
538
538
}
539
539
let kind = MDItemCopyAttribute ( mdItem, kMDItemKind) as? String
540
- kindLabel. stringValue = kind!
541
- let duration = MDItemCopyAttribute ( mdItem, kMDItemDurationSeconds) as? Int ?? ( Int ( flacMDItem!. totalFrames / flacMDItem!. sampleRate!) )
542
- durationLabel. stringValue = getTimeAsString ( Double ( duration) ) !
543
- let size = MDItemCopyAttribute ( mdItem, kMDItemFSSize) as! Int
544
- sizeLabel. stringValue = fileSizeFormatter. string ( fromByteCount: Int64 ( size) )
545
- let bitRateCheck = ( MDItemCopyAttribute ( mdItem, kMDItemAudioBitRate) as? Int ?? ( ( ( size ) * 8 ) / 1000 ) / duration) / 1000
546
- bitRateLabel. stringValue = bitRateFormatter. string ( for: bitRateCheck) !
547
- let sampleRateCheck = MDItemCopyAttribute ( mdItem, kMDItemAudioSampleRate) as? Int ?? Int ( flacMDItem!. sampleRate!)
548
- sampleRateLabel. stringValue = sampleRateFormatter. string ( for: sampleRateCheck) !
549
- let channels = MDItemCopyAttribute ( mdItem, kMDItemAudioChannelCount) as? Int ?? Int ( flacMDItem!. channels!)
550
- channelsLabel. stringValue = String ( describing: channels)
540
+ if let kind = kind {
541
+ kindLabel. stringValue = kind
542
+ }
543
+ let duration = MDItemCopyAttribute ( mdItem, kMDItemDurationSeconds) as? Int ?? ( flacMDItem != nil ? ( Int ( flacMDItem!. totalFrames / flacMDItem!. sampleRate!) ) : nil )
544
+ if let duration = duration {
545
+ durationLabel. stringValue = getTimeAsString ( Double ( duration) ) !
546
+ }
547
+ let size = MDItemCopyAttribute ( mdItem, kMDItemFSSize) as? Int
548
+ if let size = size {
549
+ sizeLabel. stringValue = fileSizeFormatter. string ( fromByteCount: Int64 ( size) )
550
+ }
551
+ let bitRateCheck = MDItemCopyAttribute ( mdItem, kMDItemAudioBitRate) as? Int ?? ( size != nil && duration != nil ? ( ( ( ( size!) * 8 ) / 1000 ) / duration!) / 1000 : nil )
552
+ if let bitRateCheck = bitRateCheck {
553
+ bitRateLabel. stringValue = bitRateFormatter. string ( for: bitRateCheck) !
554
+ }
555
+ let sampleRateCheck = MDItemCopyAttribute ( mdItem, kMDItemAudioSampleRate) as? Int ?? ( flacMDItem != nil ? Int ( flacMDItem!. sampleRate!) : nil )
556
+ if let sampleRateCheck = sampleRateCheck {
557
+ sampleRateLabel. stringValue = sampleRateFormatter. string ( for: sampleRateCheck) !
558
+ }
559
+ let channels = MDItemCopyAttribute ( mdItem, kMDItemAudioChannelCount) as? Int ?? ( flacMDItem != nil ? Int ( flacMDItem!. channels!) : nil )
560
+ if let channels = channels {
561
+ channelsLabel. stringValue = String ( describing: channels)
562
+ }
551
563
let encoder = MDItemCopyAttribute ( mdItem, kMDItemAudioEncodingApplication) as? String
552
564
encoderLabel. stringValue = encoder != nil ? encoder! : " No encoder information available. "
553
565
let dateModified = MDItemCopyAttribute ( mdItem, kMDItemContentModificationDate) as? NSDate
0 commit comments