Music_Player3/relax.offline.mp3.music/MP/Common/Tool(工具封装)/MP_WebVisitorDataManager.swift
2024-07-29 15:39:53 +08:00

47 lines
1.3 KiB
Swift

//
// MP_WebVisitorDataManager.swift
// relax.offline.mp3.music
//
// Created by Mr.Zhou on 2024/7/26.
//
import UIKit
///
class MP_WebVisitorDataManager: NSObject {
static var shared = MP_WebVisitorDataManager()
///web()
private var webView:WKWebView?
///
private lazy var homePath = "https://music.youtube.com/watch?"
override init() {
let webConfiguration = WKWebViewConfiguration()
//WebView
webView = .init(frame: .zero, configuration: webConfiguration)
super.init()
//
webView?.navigationDelegate = self
webView?.uiDelegate = self
}
deinit {
webView = nil
}
/// webyoutube
/// - Parameters:
/// - videoId: id
/// - list:
func getYoutubeWatch(_ videoId:String, list:String?) {
var path = homePath+"?"+"v=\(videoId)"
if let l = list, l.isEmpty == false {
path = path+"&list="+l
}
guard let watchUrl = URL(string: path) else {return}
let request = URLRequest(url: watchUrl)
//web
webView?.load(request)
}
}
extension MP_WebVisitorDataManager: WKNavigationDelegate, WKUIDelegate {
}