From 268ffbb678c52a0edce696d2d411d507bc4e7025 Mon Sep 17 00:00:00 2001 From: MichaelRow Date: Thu, 31 Dec 2015 16:58:51 +0800 Subject: [PATCH] bug fix --- Lyrics/AppController.swift | 22 ++++++++++++++++++---- Lyrics/AppDelegate.swift | 4 ++-- Lyrics/Base.lproj/LyricsEditWindow.xib | 4 ++-- Lyrics/Base.lproj/MainMenu.xib | 6 +++--- Lyrics/Base.lproj/Preferences.xib | 7 ++----- Lyrics/Base.lproj/StatusMenu.xib | 4 ++-- Lyrics/LyricsWindowController.swift | 2 +- Lyrics/zh-Hans.lproj/Preferences.xib | 11 ++++------- Lyrics/zh-Hans.lproj/StatusMenu.xib | 4 ++-- Lyrics/zh-Hant.lproj/Preferences.xib | 9 +++------ Lyrics/zh-Hant.lproj/StatusMenu.xib | 4 ++-- LyricsX Helper/AppDelegate.swift | 13 +++---------- 12 files changed, 44 insertions(+), 46 deletions(-) diff --git a/Lyrics/AppController.swift b/Lyrics/AppController.swift index f02cad8..10a3d0f 100644 --- a/Lyrics/AppController.swift +++ b/Lyrics/AppController.swift @@ -23,6 +23,7 @@ class AppController: NSObject, NSUserNotificationCenterDelegate { var timeDly:Int = 0 var timeDlyInFile:Int = 0 + private var isTrackingThreadRunning = false private var hasDiglossiaLrc:Bool = false private var lyricsWindow:LyricsWindowController! private var menuBarLyrics:MenuBarLyrics! @@ -109,9 +110,11 @@ class AppController: NSObject, NSUserNotificationCenterDelegate { } currentLyrics = "LyricsVox" + isTrackingThreadRunning = true dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) { () -> Void in self.voxTrackingThread() } + if vox.running() && vox.playing() { currentSongID = vox.currentPersistentID().copy() as! NSString currentSongTitle = vox.currentTitle().copy() as! NSString @@ -395,10 +398,7 @@ class AppController: NSObject, NSUserNotificationCenterDelegate { private func voxTrackingThread() { var currentPosition: Int = 0 - while true { - if vox.running() { - break - } + while !vox.running() { NSThread.sleepForTimeInterval(1.5) } @@ -427,7 +427,15 @@ class AppController: NSObject, NSUserNotificationCenterDelegate { //Check whether terminate. if userDefaults.boolForKey(LyricsQuitWithVox) { NSApp.terminate(nil) + return } + if currentLyrics != nil { + currentLyrics = nil + dispatch_async(dispatch_get_main_queue(), { () -> Void in + self.lyricsWindow.displayLyrics(nil, secondLyrics: nil) + }) + } + isTrackingThreadRunning = false return } NSThread.sleepForTimeInterval(0.2) @@ -437,6 +445,12 @@ class AppController: NSObject, NSUserNotificationCenterDelegate { func voxPlayerInfoChanged (n:NSNotification){ // check whether song is changed + if !isTrackingThreadRunning { + isTrackingThreadRunning = true + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { () -> Void in + self.voxTrackingThread() + }) + } if currentSongID == vox.currentPersistentID() { return } else { diff --git a/Lyrics/AppDelegate.swift b/Lyrics/AppDelegate.swift index a1315e0..cfd583d 100644 --- a/Lyrics/AppDelegate.swift +++ b/Lyrics/AppDelegate.swift @@ -24,7 +24,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { LyricsSavingPathPopUpIndex : NSNumber(integer: 0), LyricsUserSavingPath : userSavingPath, LyricsAutoLaunches : NSNumber(bool: true), - LyricsLaunchTpyePopUpIndex : NSNumber(integer: 2), + LyricsLaunchTpyePopUpIndex : NSNumber(integer: 1), LyricsServerIndex : NSNumber(integer: 0), LyricsQuitWithVox : NSNumber(bool: false), LyricsDisableAllAlert : NSNumber(bool: false), @@ -62,7 +62,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { NSColorPanel.sharedColorPanel().showsAlpha = true - let lyricsXHelpers = NSRunningApplication.runningApplicationsWithBundleIdentifier("Eru.LyricsX-Helper") + let lyricsXHelpers = NSRunningApplication.runningApplicationsWithBundleIdentifier("Eru.LyricsVox-Helper") for helper in lyricsXHelpers { helper.forceTerminate() } diff --git a/Lyrics/Base.lproj/LyricsEditWindow.xib b/Lyrics/Base.lproj/LyricsEditWindow.xib index 788cf71..55cba4a 100644 --- a/Lyrics/Base.lproj/LyricsEditWindow.xib +++ b/Lyrics/Base.lproj/LyricsEditWindow.xib @@ -5,7 +5,7 @@ - + @@ -40,7 +40,7 @@ - + diff --git a/Lyrics/Base.lproj/MainMenu.xib b/Lyrics/Base.lproj/MainMenu.xib index 7d0b4f5..9191d65 100644 --- a/Lyrics/Base.lproj/MainMenu.xib +++ b/Lyrics/Base.lproj/MainMenu.xib @@ -1,8 +1,8 @@ - + - + @@ -12,7 +12,7 @@ - + diff --git a/Lyrics/Base.lproj/Preferences.xib b/Lyrics/Base.lproj/Preferences.xib index 702c4c0..6cd6bf3 100644 --- a/Lyrics/Base.lproj/Preferences.xib +++ b/Lyrics/Base.lproj/Preferences.xib @@ -318,16 +318,13 @@ - + - - - @@ -1085,7 +1082,7 @@ - Hi from the developer of LricsX. I hope you enjoy using LricsX!
 LyricsX is a open source app based on some code of DynamicLyrics and other third party libraries. Its maintenance and developing needs time and money. In fact, I'm concidering set up a server to deal with the update thing. If you love this app, you can support me by donating using Wechat or Alipay. Thank you for being awesome! + Hi from the developer of LricsVox. I hope you enjoy using LricsVox!
 LyricsVox is a open source app based on some third party libraries. Its maintenance and developing needs time and money. In fact, I'm concidering set up a server to deal with the update thing. If you love this app, you can support me by donating using Wechat or Alipay. Thank you for being awesome! diff --git a/Lyrics/Base.lproj/StatusMenu.xib b/Lyrics/Base.lproj/StatusMenu.xib index 53122e5..b7e0d22 100644 --- a/Lyrics/Base.lproj/StatusMenu.xib +++ b/Lyrics/Base.lproj/StatusMenu.xib @@ -150,7 +150,7 @@ - + @@ -162,7 +162,7 @@ - + diff --git a/Lyrics/LyricsWindowController.swift b/Lyrics/LyricsWindowController.swift index 605a735..676721a 100644 --- a/Lyrics/LyricsWindowController.swift +++ b/Lyrics/LyricsWindowController.swift @@ -81,7 +81,7 @@ class LyricsWindowController: NSWindowController { backgroundLayer.addSublayer(secondLyricsLayer) setAttributes() setScreenResolution() - displayLyrics("LyricsX", secondLyrics: nil) + displayLyrics("LyricsVox", secondLyrics: nil) let nc:NSNotificationCenter = NSNotificationCenter.defaultCenter() nc.addObserver(self, selector: "handleAttributesUpdate", name: LyricsAttributesChangedNotification, object: nil) diff --git a/Lyrics/zh-Hans.lproj/Preferences.xib b/Lyrics/zh-Hans.lproj/Preferences.xib index 2eb6c86..24f5403 100644 --- a/Lyrics/zh-Hans.lproj/Preferences.xib +++ b/Lyrics/zh-Hans.lproj/Preferences.xib @@ -341,16 +341,13 @@ - + - - - - + @@ -1095,8 +1092,8 @@ - 您好,我是LyricsX的开发者。很高兴能给你带来一款为您提供便利的软件,希望您在使用过程中度过愉快的每一天! - LyricsX是一款开源的软件,并基于DynamicLyrics的部分代码以及一些第三方库。它仍需要花费时间维护与后期开发,并且将来可能需要搭建服务器以提供更便捷的更新支持。如果您喜爱这款软件,您可以通过微信以及支付宝向我提供捐赠以支持后续的开发维护。感谢您的慷慨捐赠! + 您好,我是LyricsVox的开发者。很高兴能给你带来一款为您提供便利的软件,希望您在使用过程中度过愉快的每一天! + LyricsVox是一款开源的软件,并基于一些第三方库。它仍需要花费时间维护与后期开发,并且将来可能需要搭建服务器以提供更便捷的更新支持。如果您喜爱这款软件,您可以通过微信以及支付宝向我提供捐赠以支持后续的开发维护。感谢您的慷慨捐赠! diff --git a/Lyrics/zh-Hans.lproj/StatusMenu.xib b/Lyrics/zh-Hans.lproj/StatusMenu.xib index 0c54a61..1255183 100644 --- a/Lyrics/zh-Hans.lproj/StatusMenu.xib +++ b/Lyrics/zh-Hans.lproj/StatusMenu.xib @@ -151,7 +151,7 @@ - + @@ -163,7 +163,7 @@ - + diff --git a/Lyrics/zh-Hant.lproj/Preferences.xib b/Lyrics/zh-Hant.lproj/Preferences.xib index ba3705a..6536dae 100644 --- a/Lyrics/zh-Hant.lproj/Preferences.xib +++ b/Lyrics/zh-Hant.lproj/Preferences.xib @@ -343,16 +343,13 @@ - + - - - @@ -1101,8 +1098,8 @@ - 您好,我是LyricsX的開發者。很高興能給你帶來一款為您提供便利的軟體,希望您在使用過程中度過愉快的每一天! - LyricsX是一款開源的軟體,並基於DynamicLyrics的部分程式碼以及一些第三方庫。它仍需要花費時間維護與後期開發,並且將來可能需要搭建伺服器以提供更便捷的更新支援。如果您喜愛這款軟體,您可以通過微信以及支付寶向我提供捐贈以支援後續的開發維護。感謝您的慷慨捐贈! + 您好,我是LyricsVox的開發者。很高興能給你帶來一款為您提供便利的軟體,希望您在使用過程中度過愉快的每一天! + LyricsVox是一款開源的軟體,並基於一些第三方庫。它仍需要花費時間維護與後期開發,並且將來可能需要搭建伺服器以提供更便捷的更新支援。如果您喜愛這款軟體,您可以通過微信以及支付寶向我提供捐贈以支援後續的開發維護。感謝您的慷慨捐贈! diff --git a/Lyrics/zh-Hant.lproj/StatusMenu.xib b/Lyrics/zh-Hant.lproj/StatusMenu.xib index af66973..e4bfef5 100644 --- a/Lyrics/zh-Hant.lproj/StatusMenu.xib +++ b/Lyrics/zh-Hant.lproj/StatusMenu.xib @@ -150,7 +150,7 @@ - + @@ -162,7 +162,7 @@ - + diff --git a/LyricsX Helper/AppDelegate.swift b/LyricsX Helper/AppDelegate.swift index e5d4dd0..2c46185 100644 --- a/LyricsX Helper/AppDelegate.swift +++ b/LyricsX Helper/AppDelegate.swift @@ -28,7 +28,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { if returnedObj == nil { // nil when key not found (register defaults) - launchType = 2 + launchType = 1 } else { launchType = (returnedObj?.integerValue)! } @@ -37,21 +37,13 @@ class AppDelegate: NSObject, NSApplicationDelegate { case 0: //launches at login launchLyricsVox() - NSApp.terminate(nil) case 1: - //launches with iTunes + //launches with vox if vox.running() { waitForVoxQuit() } waitForVoxLaunch() launchLyricsVox() - case 2: - //launches when iTunes playing - if vox.running() { - waitForVoxQuit() - } - waitForVoxLaunch() - NSDistributedNotificationCenter.defaultCenter().addObserver(self, selector: "launchLyricsVox", name: "com.coppertino.Vox.trackChanged", object: nil) default: break } @@ -68,6 +60,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { pathComponents = pathComponents.subarrayWithRange(NSMakeRange(0, pathComponents.count-4)) let path = NSString.pathWithComponents(pathComponents as! [String]) NSWorkspace.sharedWorkspace().launchApplication(path) + NSApp.terminate(nil) } func waitForVoxLaunch() {