问题
I'm doing simple movie player in swift. I have player in ViewController like this.
and i want it like this.
Here's code
import UIKit
import MediaPlayer
class DetailViewController: UIViewController {
var moviePlayer:MPMoviePlayerController!
override func viewDidLoad() {
super.viewDidLoad()
var url:NSURL = NSURL(string: "http://jplayer.org/video/m4v/Big_Buck_Bunny_Trailer.m4v")
moviePlayer = MPMoviePlayerController(contentURL: url)
moviePlayer.view.frame = CGRect(x: 16, y: -100, width: 600, height: 400)
moviePlayer.view.sizeToFit()
self.view.addSubview(moviePlayer.view)
moviePlayer.fullscreen = true
moviePlayer.controlStyle = MPMovieControlStyle.Embedded
}
}
回答1:
in continuation to Dharmesh reply, please update
moviePlayer.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height)
it will then be adjusted as per device screen size.
Hope it helps!
回答2:
Try this because it's work for me:
moviePlayer.view.frame = CGRect(x: 0, y: 0, width: 320, height: 568)
来源:https://stackoverflow.com/questions/26440238/movie-player-in-swift