本文介绍了真实设备Iphone上的本地视频播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用
解决方案
尝试此代码
让路径= NSBundle.mainBundle().pathForResource("small",ofType:"mp4")让fileURL = NSURL.init(fileURLWithPath:path)如果(fileURL){打印(视频网址不为空")}
还可以检查副本捆绑资源中的视频
--->项目
---->目标----> BuildPhase---->复制捆绑资源->添加small.mp4
Use this link I am trying to play a video on the simulator with AVPlayerViewController
. That work on simulator perfectly. But when I am trying to play it on real Device. It doesn't work.
import UIKit
import AVKit
import AVFoundation
class SafaribroserViewController: UIViewController {
var playerViewController = AVPlayerViewController()
var playerView = AVPlayer()
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func hsdgfsf(_ sender: Any) {
let fileURL = NSURL.init(fileURLWithPath: "/Users/macmini/Downloads/QRCodeReader-master 3/QRCodeReader/small.mp4")
playerView = AVPlayer(url: fileURL as URL)
playerViewController.player = playerView
present(playerViewController,animated:true) {
self.playerViewController.player?.play()
}
}
解决方案
Try this code
let path = NSBundle.mainBundle().pathForResource("small", ofType: "mp4")
let fileURL = NSURL.init(fileURLWithPath: path)
if (fileURL)
{
print("Video url is not empty")
}
And Also Check video in Copy Bundle Resources
---> Project
---->Target
---->BuildPhase
---->Copy Bundle Resources-->Add small.mp4
这篇关于真实设备Iphone上的本地视频播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!