标题

我尝试用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)


但是会输出视频声音。视频不输出。

最佳答案

像这样更改您的功能:

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


也许这可以帮助您。

关于ios - Swift Play Video无法显示,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27029357/

10-12 14:31