Swift Play视频无法显示

时间:2014-11-19 23:57:12

标签: ios xcode video swift

标题

我正尝试用Swift播放视频。 我使用此代码更改UIController

var vc = playVideoOne()
self.presentViewController(vc, animated: true, completion: nil)

这是我的PlayVideo代码

var audioplayer:MPMoviePlayerController=MPMoviePlayerController()
var url:NSURL = NSURL(string: "http://dev.fjuts.com:83/test.mp4")!
self.audioplayer.contentURL = url
audioplayer.play()
self.view.addSubview(audioplayer.view)

但输出了视频声音。视频无法输出。

1 个答案:

答案 0 :(得分:1)

改变你的功能:

var audioplayer : MPMoviePlayerController!

var url:NSURL = NSURL(string: "http://dev.fjuts.com:83/test.mp4")

audioplayer = MPMoviePlayerController(contentURL: url)

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

audioplayer.view.sizeToFit()

audioplayer.play()

self.view.addSubview(audioplayer.view)

audioplayer.fullscreen = true

audioplayer.controlStyle = MPMovieControlStyle.Embedded

可能这可以帮到你..