【发布时间】:2014-11-21 06:28:39
【问题描述】:
我有这个代码:
import UIKit
import MediaPlayer
class ViewController: UIViewController {
var moviePlayer:MPMoviePlayerController!
var bounds: CGRect = UIScreen.mainScreen().bounds
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
var width:CGFloat = bounds.size.width
var height = (width / 16) * 9
var url:NSURL = NSURL(string: "http://jplayer.org/video/m4v/Big_Buck_Bunny_Trailer.m4v")
moviePlayer = MPMoviePlayerController(contentURL: url)
moviePlayer.view.frame = CGRect(x: 0, y: 40, width: width, height: height)
self.view.addSubview(moviePlayer.view)
moviePlayer.fullscreen = true
moviePlayer.controlStyle = MPMovieControlStyle.Embedded
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
它可以从服务器播放视频,但我有一个问题:
如果我想拥有纵向模式的应用程序,我是否仍然只能在用户以全屏模式播放视频时将其变为横向?如果有,该怎么做?
之前谢谢。
【问题讨论】:
-
你是怎么找到的?
-
@Flakerim :不,我还没有找到答案……你有同样的问题吗?
-
可以的。您可以以编程方式执行此操作,请查看此帖子:stackoverflow.com/questions/25651969/…
标签: ios swift xcode media-player mpmovieplayercontroller