zhengwenming / WMPlayer

WMPlayer-AVPlayer的封装,继承UIView,支持pods,手势快进、快退,全面适配全面屏,同时支持网络和本地视频的播放
MIT License
3.27k stars 761 forks source link

播放本地视频,提示视频加载失败 #194

Closed yuanweiphone closed 1 year ago

yuanweiphone commented 5 years ago

作者,你好 播放本地视频提示The requested URL was not found on this server." UserInfo={NSLocalizedDescription=The requested URL was not found on this server., NSUnderlyingError=0x600003ca97d0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}} 但是本地是存在文件的,这是什么原因呢? 代码如下

    let path = Bundle.main.path(forResource: "444", ofType: "mp4")
    let url = URL(fileURLWithPath: path!)
    let urlPath = url.absoluteString.removingPercentEncoding

    let playerModel = WMPlayerModel()
    playerModel.title = videoName
    playerModel.videoURL = URL(fileURLWithPath: urlPath!)

    playerView = WMPlayer(model: playerModel)
    playerView.frame = CGRect(x: 170, y: 200, width: SCREEN_WIDTH - 340, height: 400)
    view.addSubview(playerView)
    playerView.play()
zhengwenming commented 5 years ago

换个mp4的视频测试一下,如果不是视频的原因,估计就是url路径问题。视频播放器确认是支持本地视频的。