Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to show thumbnails of youtube links. #77

Open
sarathdev opened this issue Nov 27, 2018 · 1 comment
Open

Not able to show thumbnails of youtube links. #77

sarathdev opened this issue Nov 27, 2018 · 1 comment

Comments

@sarathdev
Copy link

Not able to show thumbnails of youtube links. We had a discussion about the same issue for showing for youtube links that are starting with "m.youtube.com". Now what is happening is if we copy a link from youtube player the link what we are getting is entirely different from all the previous links what we handling.
Adding the code that I'm using to show the URL embedded view below

if sosFeedPostDesc.extractURLs() is URL{
                if  let extractedUrls = sosFeedPostDesc.extractURLs() {
                    let url: URL
                    if (extractedUrls as AnyObject).host?.contains("m.youtube.com") == true {
                        var components = URLComponents(string: (extractedUrls as AnyObject).absoluteString as! String)
                        components?.host = "www.youtube.com"
                        if let _url = components?.url {
                            url = _url
                        } else {
                            url = extractedUrls as! URL
                        }
                    } else {
                        url = extractedUrls as! URL
                    }
                    
                    cell.urlPreviewViewHeightConstraint.constant = 60
                    print("Exrtracted URL: \(url.absoluteString) Index:\(indexPath.row)")
                    
                    let embeddedView = URLEmbeddedView()
                    //                    embeddedView.loadURL(url.absoluteString)
                    embeddedView.load(urlString: url.absoluteString)
                    embeddedView.borderColor = .clear
                    embeddedView.cornerRaidus = 0
                    embeddedView.frame = CGRect(x: 0, y:0, width: cell.frame.width - 20, height: 60)
                    embeddedView.didTapHandler = { [weak self] _, url in
                        guard let url = url else { return }
                        self?.present(SFSafariViewController(url: url), animated: true, completion: nil)
                    }
                    for view in cell.urlEmbededViewOutlet.subviews {
                        if let ev = view as? URLEmbeddedView {
                            ev.cancelLoading()
                            ev.removeFromSuperview()
                        }
                    }
                    
                    cell.urlEmbededViewOutlet.addSubview(embeddedView)
                    
                }
            }
            else{
                for view in cell.urlEmbededViewOutlet.subviews {
                    if let ev = view as? URLEmbeddedView {
                        ev.cancelLoading()
                        ev.removeFromSuperview()
                    }
                }
                cell.urlPreviewViewHeightConstraint.constant = 0
            }

Added the entire code in the descrition. Please suggest if you found any edits in existing code as well. Waiting for to hear from you. Thanks in advance :)

@sarathdev
Copy link
Author

sarathdev commented Nov 27, 2018

#39 #41 @marty-suzuki Please help me to resolve this issue asap adding a sample link that copied from youtube app in phone "https://youtu.be/f_UWq8lXfYo". Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant