视频在iphone模拟器上工作但不在ipad中

时间:2016-10-29 23:27:05

标签: ios swift ipad video swift3

在我的应用中,我有2个视频。第一个视频在iphone模拟器和我的ipad上播放完美。然而,第二个视频在iphone模拟器上播放,但在我的ipad上播放。我不知道为什么会这样。有什么想法吗?

第一个有效的视频是jxdo11。第二个不起作用的视频是j11。我在ipad上贴了一个j11的小调。 j11 pic; when button is pressed play j11

import UIKit
import AVKit
import AVFoundation

class ViewController: UIViewController {
let  moviePlayer =  AVPlayerViewController()

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}
@IBAction func pc(_ sender: AnyObject) {
     playLocalVideo()
}

func playLocalVideo(){

    if let filePath = Bundle.main.path(forResource: "jxdo11", ofType: "mp4"){
        let videoURL = NSURL(fileURLWithPath: filePath)


        let player = AVPlayer(url: videoURL as URL)


        moviePlayer.player = player
        self.present(moviePlayer, animated: true) {
            self.moviePlayer.player!.play()
        }
    }

    else{
        print("Oops, something wrong when playing video.mp4")
    }
}


@IBAction func Mac(_ sender: AnyObject) {
     playLocalVideo1()
}
func playLocalVideo1(){

    if let filePath = Bundle.main.path(forResource: "j11", ofType: "mp4"){
        let videoURL = NSURL(fileURLWithPath: filePath)


        let player = AVPlayer(url: videoURL as URL)


        moviePlayer.player = player
        self.present(moviePlayer, animated: true) {
            self.moviePlayer.player!.play()
        }
    }

    else{
        print("Oops, something wrong when playing video.mp4")
    }
}


  }

0 个答案:

没有答案