Forum Xamarin.iOS

Playing a video stored within the app

nodoidnodoid GBMember, Beta ✭✭✭


I'm trying to play a video full screen without the controls that is stored within the app itself. The code I'm using is this

private void startAnimation()
     using (var pool = new NSAutoreleasePool())
          InvokeOnMainThread(() =>
               player = new MPMoviePlayerController(NSUrl.FromFilename("Graphics/videos/noaudio-data-download.mp4"))
                   AllowsAirPlay = true,
                   Fullscreen = true,
                   ScalingMode = MPMovieScalingMode.Fill,
                   RepeatMode = MPMovieRepeatMode.One
               player.View.Frame = View.Frame;


which should work (ok, it will give me the controls, but will still show the video).

When I try and display the video though, I'm getting the following error

_itemFailedToPlayToEnd: {
    kind = 1;
    new = 2;
    old = 0;

The video is working (tested using VLC), so I'm not sure what the problem is.

Any advice or help would be appreciated.



  • EsauREsauR USMember

    I have this same error. Did anyone figure out the solution to this?

  • nodoidnodoid GBMember, Beta ✭✭✭

    The example in monotouch-samples works fine with iOS7

  • EsauREsauR USMember

    I still get the same error even when using the exact same movie file. The only difference is that I don't have a setfullscreen to true because I want it playing in the background below some user interface buttons

  • nodoidnodoid GBMember, Beta ✭✭✭

    Can you post up or provide a link to your code (on something like github) so I can try and find the source of the issue?

  • nodoidnodoid GBMember, Beta ✭✭✭

    Let me understand this fully.

    You have a video as a background and over that you want to put some buttons (a bit like that annoying video that you get on the PayPal website)?

    Try this

    private void PlayVideoInLoop(bool loop)
                var mpPlayer = new MPMoviePlayerController(NSUrl.FromFilename("Videos/file.m4v"));
                mpPlayer.ControlStyle = MPMovieControlStyle.None;
                if (loop)
                    mpPlayer.RepeatMode = MPMovieRepeatMode.One;
                mpPlayer.View.Frame = new RectangleF(0, 0, View.Bounds.Size.Width, View.Bounds.Size.Height);
                var btnOver = new UIButton(new RectangleF(25, 50, 100, 40));
                btnOver.SetTitle("Hello there", UIControlState.Normal);

    You may need to bring the subview to the front, but this should do it.

  • EsauREsauR USMember

    Check out the Spotify app to see what I mean by a video playing in the background and with buttons above it as an interface.

    Thanks for the code, I will try it in a bit.

  • EsauREsauR USMember

    Hey nodoid,

    That did not work. I have the same error:

    2014-08-09 01:13:57.006 xamarinpcl[328:60b] _itemFailedToPlayToEnd: {
    kind = 1;
    new = 2;
    old = 0;

    I do see a black screen with the button overlay on top that says "Hello There". But essentially it is still the same issue with mines. I have the video file located in the root folder of the project and in the /Videos/ folder

    Anyone have any other ideas or suggestions?

  • nodoidnodoid GBMember, Beta ✭✭✭

    Hmmm, can you post the code with the file onto github so I can try and find the issue?

Sign In or Register to comment.