iphone - 使用 MonoTouch 播放视频时出现问题

标签 iphone ipad video xamarin.ios mpmovieplayer

我在使用 MonoTouch 播放视频时遇到了一些问题。据我所知,可以采取两种不同的方法。两者都会导致播放音频但不播放视频。我打赌我遗漏了一些简单的东西,所以任何帮助都会很棒。

尝试一——取自机器翻译文档

moviePlayer = new MPMoviePlayerController(new NSUrl("test.mp4"));  
moviePlayer.Play();

尝试二

moviePlayer = new MPMoviePlayerViewController(new NSUrl("test.mp4")); 
this.PresentMoviePlayerViewController(moviePlayer);

谢谢

最佳答案

从文档上看,需要在 View 中添加MPMoviePlayerController,否则视频不知道播放到哪里。

您的第二次尝试看起来好一些,您是在调用 moviePlayer 的播放方法(注意这是一个 MPMoviePlayerViewController)MPMoviePlayerController(名为 MoviePlayer)吗?

物有所值,我能得到;

moviePlayerController = new MPMoviePlayerViewController(new NSUrl("test.mp4")); 
this.PresentMoviePlayerViewController(moviePlayerController);

在示例 iPad 应用程序上运行时没有任何问题。你确定你的 test.mp4 是...

  1. 编码正确
  2. 包含在项目中
  3. 视频的构建操作设置为内容

MPMoviePlayerController 文档:http://developer.apple.com/library/ios/#documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/MPMoviePlayerController/MPMoviePlayerController.html

MPMoviewPlayerViewController 文档: http://developer.apple.com/library/ios/#documentation/MediaPlayer/Reference/MPMoviePlayerViewController_class/Reference/Reference.html#//apple_ref/occ/cl/MPMoviePlayerViewController

关于iphone - 使用 MonoTouch 播放视频时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4768910/

相关文章:

iphone - 如果用户在文本字段为空时按下提交按钮,则摇动 UIAlertView

iphone - ARC转换: iphone implicit conversion of 'BOOL' (aka 'signed char' ) to 'id' is disallowed with ARC

xcode Swift 将录制的视频保存为 mov 或 mp4

html5 <video> 标签在 chrome/firefox 中无法播放大于 10 MB 的 mp4 文件

video - 直播视频码率计算公式

ios - Appium:启动Appium Inspector时,App连续崩溃

ios - 通过(?)用户数据将自定义对象(例如,使用DYRateView进行评级)添加到GMSMarker

iphone - 如何为 UITextView 启用滑动手势

performance - drawRect 性能

ios - UISlider 在第一代 iPad 上不流畅