[英]Prevent upload a video that exceeds the limit
I am developing an app that can upload/ record a video. 我正在开发可以上传/录制视频的应用程序。 I set a limit to video but when I upload from library a video that exceeds the limit, a pop-up appear "Video Too Long to Send", but I can choose the video.
我为视频设置了限制,但是当我从库上传超过限制的视频时,会弹出一个窗口“视频太长,无法发送”,但是我可以选择视频。 My issue is: can I disable choose button or make something to stop upload the video.
我的问题是:我可以禁用选择按钮还是要停止播放视频?
Before uploading video you should check video size. 在上传视频之前,您应该检查视频尺寸。 I have done it with my swift application.
我已经完成了我的快速应用程序。 I have used following code.
我使用了以下代码。
let data: NSData = NSData(contentsOfURL: <video URL>)!
if !isFileSizeUpTo10Mebibytes(data.length)
{
//File is more than 10 MB.
}
func isFileSizeUpTo10Mebibytes(fileSize: Int) -> Bool {
return fileSize <= 10485760
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.