ios - 重置 MPMoviePlayerViewController 播放

标签 ios swift mpmovieplayercontroller

我的应用程序中有一个视频在 MPMoviePlayerViewController 中播放。我想知道是否可以在按下按钮时重置 MPMoviePlayerViewController。目前,如果用户在播放视频时点击 Done 然后尝试再次观看视频,它会从他们停止的地方继续。这导致我的一些其他代码出现一些问题,我希望它从头开始。这可能吗?


我希望视频在按下 Done 按钮时自行重置,以便为下一次做好准备。

我有一个功能,想在这里添加视频的重置。

func doneButtonClick(sender:NSNotification?) {
    let value = UIInterfaceOrientation.Portrait.rawValue
    UIDevice.currentDevice().setValue(value, forKey: "orientation")
}

最佳答案

让您的视频停止。然后在您想再次播放视频时调用 play 。这将从视频的开头开始播放。

myMoviePlayerController.stop()

MPMediaPlayback Protocol Reference

关于ios - 重置 MPMoviePlayerViewController 播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31007741/

相关文章:

ios - 在 Xcode 10.2.1 上构建,tvOS 和 iOS 项目失败

swift - swift中从外部函数调用值变量

ios - 如何从 UIWebView 嵌入式 YouTube 视频播放接收 NSNotifications

ios - MPMoviePlayerController 不从 Documents 文件夹播放

ios - 根据计时器调整表格 View 单元格文本

php - iOS应用程序需要POST到PHP脚本,然后解析返回的XML

html - iOS 上 HTML 中不可选择的文本

iphone - 安全地向服务器验证 iPhone 应用程序?

ios - 如何动态填充标签栏 Controller 的标签栏。? ( swift ——iOS 9)

ios - 为什么从全屏返回时我的 MPMoviePlayerController 的 scalingMode 不被尊重?