问题描述
我无法获得编辑的VideoPath的完整NSURL,这是我的代码:
I can't get the full NSURL of the editedVideoPath, here's my code:
// GLOBAL VARIABLES
var videoPath = String()
var videoURL = NSURL()
// Video Editor delegate
func videoEditorController(editor: UIVideoEditorController, didSaveEditedVideoToPath editedVideoPath: String) {
if saveToPhotoLibrary {
if UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(editedVideoPath) {
UISaveVideoAtPathToSavedPhotosAlbum(editedVideoPath, self, nil, nil)
}
print("SAVED TO PHOTO LIBRARY AT: \(editedVideoPath)")
}
videoPath = editedVideoPath
videoURL = NSURL(string: editedVideoPath)!
print("VIDEO PATH: \(videoPath)")
print("VIDEO URL: \(videoURL)")
dismissViewControllerAnimated(true, completion: nil)
}
问题是我无法从 videoPath 字符串,这是XCode控制台打印出的内容:
The problem is the I can't get the full NSURL out of the videoPath string, here's what the XCode console prints out:
VIDEO PATH: /private/var/mobile/Containers/Data/Application/D7536AD4-353A-48CA-8F31-2D78F9F10730/tmp/trim.BFF7D20F-138A-46A2-A58E-76736AF7343E.MOV
VIDEO URL: /private/var/mobile/Containers/Data/Application/D7536AD4-353A-48CA-8F31-2D78F9F10730/tmp/trim.BFF7D20F-138A-46A2-A58E-76 ... 343E.MOV
如您所见,VIDEO URL几乎在其末尾获得点,而VideoPath字符串是正确的。这是一个非常有线的问题我以前从未遇到过这个NSURL语句:
As you can see, the VIDEO URL gets dots almost by the end of it, while the VideoPath string is correct. This is a pretty wired issue I've never encountered before with this NSURL statement:
videoURL = NSURL(string: editedVideoPath)!
由于我需要将编辑过的视频上传到网络服务器,我需要完整正确的网址。我认为这是一个 print()问题,但如果我试图抓住 videoURL XCode告诉我它是零,那么 print()函数说实话:(
Since I need to upload that edited video to a web server, I need its full correct url. I thought is was a print() issue, but if I try to grab the videoURL XCode tells me that it's nil, so print() function tells the truth :(
我在stackoverflow上搜索过这里,没有成功。
I've searched here and there on stackoverflow, no success.
希望有人可以提供帮助,
谢谢!
Hope someone can help,Thanks!
推荐答案
由于你使用的是文件路径,你想使用
Since you're using a file path, you want to use
NSURL(fileURLWithPath: editedVideoPath)
而不是
NSURL(string: editedVideoPath)
这篇关于来自String的NSURL在UIVideoEditorController的视频路径Swift 2 iOS 8上被截断,点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!