Playing a video

Discussion in 'iOS Programming' started by naphatkrit, Jun 25, 2012.

  1. naphatkrit, Jun 25, 2012
    Last edited: Jun 26, 2012

    naphatkrit macrumors member

    Joined:
    Jul 18, 2011
    #1
    Hi,
    I'm trying to get a video to play in my app. I've googled this and followed quite a few tutorial, to no success. I'm just met with a blank dark screen. Here is my code:

    Code:
     NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"recording5" ofType:@"mov"];
        self.moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:[NSURL URLWithString:resourcePath]];
        [self.moviePlayer.view setFrame:self.view.bounds];
        
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish) name:MPMoviePlayerPlaybackDidFinishNotification object:self.moviePlayer];
        
        self.moviePlayer.controlStyle = MPMovieControlModeDefault;
        self.moviePlayer.shouldAutoplay = YES;
        [self.view addSubview:moviePlayer.view];
        [self.moviePlayer setFullscreen:YES animated:YES];
    moviePlayer is a variable I declared in my .h file.
    Is there something wrong with my code? The video is a screen recording from Quicktime X with the resolution set to match that of the iPad.
     
  2. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    Yeah there is something wrong :p
    First of all, MPMovieController doesn't support MOV coding. Second, there are some newer versions of the MPMovieController, I think "MPMoviePlayerViewController" is the correct one :), you should use that one instead for better manipulation.
    Also, I found that MOV isn't supported in 10 seconds of google search >.>
     
  3. naphatkrit thread starter macrumors member

    Joined:
    Jul 18, 2011
    #3
    Wow I had no idea .mov isn't supported. I assumed that it is supported because I was able to use iTunes to sync it over to the iPad and play normally from the Video app. What format do you recommend?
    I'll also try MPMoviePlayerViewController, but if the problem is with the format, I don't think tell work.

    Thank you so much for getting back to me so quickly :) Love this forum!
     
  4. Twilio macrumors newbie

    Joined:
    Jun 25, 2012
    #4
    yes you have one think wrong in your code.......

    you are using "MPMoviePlayerController" it is wrong way to calling.... if you use "MPMoviePlayerViewController" then you got no error and your streaming will going accurately.
     
  5. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #5
    He doesn't have any streaming, with on device "movies", MOV isn't supported, MP4 is your best bet. (most native+support encoded). If it works, head back.
    And the newer version I showed you, you can also add as a subview, and just resize like you want it to, I think this was introduced since 4.x something.
    In the beginning video's were only full screen, so they changed it to a new one, you can assign your current movieController to the pointer of the Playerview.movieplayer or something if I remember correctly, rest of the code should be nearly the same.
     
  6. naphatkrit thread starter macrumors member

    Joined:
    Jul 18, 2011
    #6
    I tried your suggestions and went with MPMoviePlayerViewController and .mp4 format. Now, the video control screen does come up, but the content is still black, and this is shown in the log:

    Code:
    2012-06-26 15:56:22.439 videoNew[2277:13a03] [MPAVController] Autoplay: Likely to keep up or full buffer: 0
    2012-06-26 15:56:22.442 videoNew[2277:13a03] [MPAVController] Autoplay: Skipping autoplay, not enough buffered to keep up.
    What does this mean?
     

Share This Page