Monotouch - MoviePlayer 永遠不會超越“正在加載...” (Monotouch - MoviePlayer never gets beyond "loading...")


問題描述

Monotouch ‑ MoviePlayer 永遠不會超越“正在加載...” (Monotouch ‑ MoviePlayer never gets beyond "loading...")

I downloaded the MonoTouch example 'PlayMovieRecipe' and it runs perfectly.

I then created a small app (using Storyboard) with a 'MoviePlayer' page. I copied the example code from the sample application but when I run it, it appears to start the movieplayer but never gets beyond 'Loading...'. The sample file (sample.m4v) is in the root of the app. This is the code I used:

namespace test {     public partial class DetailViewController : UIViewController     {         MPMoviePlayerController moviePlayer;         public DetailViewController (IntPtr handle) : base (handle)         {         }

    public override void ViewDidLoad ()
    {
        base.ViewDidLoad ();
        this.btnPlayMovie.TouchUpInside += delegate {
            moviePlayer = new MPMoviePlayerController (NSUrl.FromFilename ("sample.m4v"));
            View.AddSubview (moviePlayer.View);
            moviePlayer.SetFullscreen (true, true);
            moviePlayer.Play ();
        } ;
    }

}

}

‑‑‑‑‑

參考解法

方法 1:

Try explicitly setting the filetype (moviePlayer.SourceType = MPMovieSourceType.File;) right before you add the subview.  I also use a frame for the player which gives a little more control on display height, width etc. since the video can be pinched/zoomed to full screen. Also, make sure your video is set to "content" in it's settings (right‑click Build Action). Cheers!

(by user1658259GeeMan)

參考文件

  1. Monotouch ‑ MoviePlayer never gets beyond "loading..." (CC BY‑SA 3.0/4.0)

#video #mpmovieplayercontroller #xamarin.ios






相關問題

當前在網站上放置音頻和視頻的最佳方式是什麼? (what's the current best way to put audio and video on a web site?)

相當於PNG的視頻? (Video equivalent of PNG?)

IOS - UISaveVideoAtPathToSavedPhotosAlbum 如何返回保存的視頻路徑? (IOS -how could UISaveVideoAtPathToSavedPhotosAlbum return the saved video path?)

如何使用 c# 編寫一個簡單的視頻播放器,以準確的 fps 播放視頻? (How to use c# to write a simple video player which plays the video with accurate fps?)

Monotouch - MoviePlayer 永遠不會超越“正在加載...” (Monotouch - MoviePlayer never gets beyond "loading...")

Android MediaMetadataRetriever setDataSource 失敗 (Android MediaMetadataRetriever setDataSource failed)

枚舉Windows上所有可用視頻編解碼器的最佳方法? (Best way to enumerate all available video codecs on Windows?)

如何通過上傳單個視頻文件為任何 html5 視頻獲得多種質量(360p、480p、720p)選擇 (how can i get multiple quality(360p,480p, 720p) selection for any html5 video with uploading single video file)

由於不支持的編解碼器,FFmpeg/Avconv 無法複製字幕? (FFmpeg/Avconv unable to copy subtitles due to unsupported codec?)

嵌入 youtube 視頻響應解決方案 (embed youtube video responsive solution)

如何輕鬆識別流是視頻還是圖片【ffmpeg庫】 (How to easily recognize whether stream is video or image [ffmpeg library])

livestream.com 如何顯示存檔的視頻? (how is livestream.com displaying the archived video(s)?)







留言討論