在开始之前,我想告诉你,现在我跳到iPhone开发,我是新手。
我在视频视图中遇到了问题。我需要在视图中呈现视图。我做过类似的事情
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
moviePlayer = AVPlayerViewController()
if let player = moviePlayer {
let playerItem = AVPlayerItem(URL: NSURL(string: "http://cdnapi.kaltura.com/p/1/sp/11000/playManifest/entryId/0_eruqsdasd/flavorIds/1111/format/applehttp/protocol/http/a.m3u8")! )
playerVideo = AVPlayer(playerItem: playerItem)
player.player = playerVideo
player.view.frame = self.videoView.frame
player.view.sizeToFit()
player.showsPlaybackControls = true
videoView.addSubview(player.view)
print("SeekTime:Table: \(moviePlayer.player?.currentTime())")
}
}
输出是这样的。
你可以帮我解决这个问题 output image答案 0 :(得分:1)
您可以尝试使用VC而不是添加为子视图
self.presentViewController(moviePlayer, animated: true) {
self.moviePlayer.player!.play()
}
否则,您可以查看videoView
答案 1 :(得分:1)
您的视频播放器有一个Y偏移,需要减少以便它适合屏幕,尝试 -
//get size of screen
var screenSize : CGRect = UIScreen.mainScreen().bounds;
//set width and height of screen into screenHeight and screenWidth
var screenHeight = screenSize.height;
var screenWidth = screenSize.width;
//re-position video-frame
player.view.frame.position.y = screenHeight * 0;
如果player.view.frame
方法不起作用,请尝试以下方法:
player.view.frame.center.y = screenHeight * 0;
如果player.view
没有名为frame
的成员,请使用player.frame
。