-2

我正在快速制作简单的电影播放器​​。我在 ViewController 中有这样的播放器。

在此处输入图像描述

我想要这样。

在此处输入图像描述

这是代码

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

}

}
4

2 回答 2

2

继续 Dharmesh 回复,请更新

moviePlayer.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height)

然后它将根据设备屏幕尺寸进行调整。

希望能帮助到你!

于 2014-10-18T15:14:54.633 回答
1

Try this because it's work for me:

moviePlayer.view.frame = CGRect(x: 0, y: 0, width: 320, height: 568)
于 2014-10-18T13:41:13.843 回答