From 29383bb6df7bdd58675b5df9bc52246215184b3f Mon Sep 17 00:00:00 2001 From: Swagat Nayak Date: Mon, 22 Mar 2021 14:39:30 +0530 Subject: [PATCH] Minor bug fix --- .../Classes/SNAVPlayerSubtitles.swift | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/SNAVPlayerSubtitles/Classes/SNAVPlayerSubtitles.swift b/SNAVPlayerSubtitles/Classes/SNAVPlayerSubtitles.swift index 5ddc712..091494b 100644 --- a/SNAVPlayerSubtitles/Classes/SNAVPlayerSubtitles.swift +++ b/SNAVPlayerSubtitles/Classes/SNAVPlayerSubtitles.swift @@ -356,6 +356,11 @@ public extension AVPlayerViewController { show(subtitles: contents,type: type) } + func hideSubtitle() { + + self.parsedPayload = nil + } + func open(fileFromRemote filePath: URL,type: SNAVP_SUBTITLE_TYPE, encoding: String.Encoding = String.Encoding.utf8) { @@ -367,7 +372,7 @@ public extension AVPlayerViewController { //Check status code if statusCode != 200 { - + self.hideSubtitle() NSLog("Subtitle Error: \(httpResponse.statusCode) - \(error?.localizedDescription ?? "")") return } @@ -537,22 +542,10 @@ public extension AVPlayer { //Check status code if statusCode != 200 { - let final = NSMutableDictionary() - final["from"] = Double(0.196) - final["to"] = Double(10.134) - final["text"] = "Error" - self.parsedPayload?.setValue(final, forKey: "0") - + self.hideSubtitle() NSLog("Subtitle Error: \(httpResponse.statusCode) - \(error?.localizedDescription ?? "")") return } - }else{ - let final = NSMutableDictionary() - final["from"] = Double(0.196) - final["to"] = Double(10.134) - final["text"] = "Error" - self.parsedPayload?.setValue(final, forKey: "0") - } // Update UI elements on main thread DispatchQueue.main.async(execute: { @@ -656,7 +649,6 @@ public extension AVPlayer { subtitleLabel?.layer.cornerRadius = 8 subtitleLabel?.clipsToBounds = true subtitleLabel?.layer.frame.inset(by: UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)) - subtitleLabel?.layer.backgroundColor = UIColor.black.withAlphaComponent(CGFloat(0.6)).cgColor subtitleLabel?.layer.rasterizationScale = UIScreen.main.scale subtitleLabel?.lineBreakMode = .byWordWrapping subtitleLabel?.isHidden = false