真实设备Iphone上的本地视频播放 [英] Local Video Play on Real device Iphone

查看:55
本文介绍了真实设备Iphone上的本地视频播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用

注意:-我的真实设备已连接到MacMini Hotspot.

如何在真实设备上播放视频?谢谢

解决方案

尝试此代码

 让路径= 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()
    }
}

output on real device

Note:- My real device is connected to MacMini Hotspot.

How Can I Play video on my real device? Thanks

解决方案

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上的本地视频播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆