【问题标题】:Issues playing a video with MonoTouch使用 MonoTouch 播放视频时出现问题
【发布时间】:2011-01-22 16:08:27
【问题描述】:

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

尝试一 - 取自 MT 文档

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

尝试二

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

谢谢

【问题讨论】:

    标签: iphone ipad video xamarin.ios mpmovieplayer


    【解决方案1】:

    通过查看文档,您需要将 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

    【讨论】:

    • 我之前曾尝试将 MPMoviePlayerController 添加到视图中,但没有任何运气。文档显示我没有设置帧大小。添加类似moviePlayer.View.Frame = View.Frame;让它生机勃勃。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-18
    • 1970-01-01
    • 2014-01-04
    • 1970-01-01
    • 2023-02-09
    相关资源
    最近更新 更多