Pip*_*ppo 1 ios avplayer swift
令人惊讶的是,尽管进行了很多搜索,但我仍无法找到答案。
我有一个已缓存的文件,我可以检索我认为是url的缓存目录和文件名吗?
这是获取文件然后播放的代码
let cachedFilePath = getCachedFilePath.result as! String
audioFileURL = cachedFilePath
self.audioPlayerItem = AVPlayerItem(url: NSURL(string: audioFileURL!) as! URL)
Run Code Online (Sandbox Code Playgroud)
这是如果我打印返回的内容audioFileURL:
/ Users / Genie / Library / Developer / CoreSimulator / Devices / A2FB00CE-B018-4FDF-9635-35FD6678DF8D / data / Containers / Data / Application / E18B5E89-B973-4277-AA5C-1378C69D80CD / Library / Caches / Parse / PFFileCache / 7e4a8f655859 %20Name%20of%20the%20Wind%2017-92.mp3
播放器加载,但从不播放,它只是坐在那里旋转。所以我想知道我是否将URL正确传递给播放器?
我读过一个要使用的线程,file://但是没有用。
在创建NSURL的地方,将参数名称替换string为fileURLWithPath
更改
NSURL(string: audioFileURL!)
Run Code Online (Sandbox Code Playgroud)
至
NSURL(fileURLWithPath: audioFileURL!)
Run Code Online (Sandbox Code Playgroud)
另外,您为什么要投射NSURL到URL?为什么不URL直接使用?
| 归档时间: |
|
| 查看次数: |
2199 次 |
| 最近记录: |