我正在尝试在 Collection View 中播放 mp4 视频,但未能成功。我试过的方法是:
方法一:
let html = "<video playsinline controls width=\"100%\" src=\"\(url)\"> </video>"
cell.webview.loadHTMLString(html, baseURL: nil)
cell.webview.allowsInlineMediaPlayback = true
方法二:
cell.webview.loadRequest(URLRequest(url: URL(string: source)!))
最佳答案
你能试试下面的代码吗,
let html = "<video width=\"100%\" controls> <source src=\"http://test.creatrixcampus.com/uploads/doc/binaryOctalHex_1526459737.mp4\" type=\"video/mp4\"></video>"
更新
let html = "<iframe src=\"http://test.creatrixcampus.com/uploads/doc/binaryOctalHex_1526459737.mp4\" width=\"100%\"></iframe>"
webView.loadHTMLString(html, baseURL: nil)
webView.allowsInlineMediaPlayback = true
下面是相同的输出,
如有任何疑问,请告诉我。
关于ios - 无法在 Collection View 中播放 mp4 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50366118/