playing mp4

Discussion in 'iOS Development' started by deepp, Jun 3, 2009.

  1. deepp

    deepp New Member

    Joined:
    Sep 4, 2008
    Messages:
    73
    Likes Received:
    0
    Hi ,i am trying to play a video file but when i try to play it,it displays gray screen and can hear video soung but not pictures.what could be the reason?
  2. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    We really need the code, to help you.
  3. deepp

    deepp New Member

    Joined:
    Sep 4, 2008
    Messages:
    73
    Likes Received:
    0
    I am using this code

    NSBundle *bundle = [NSBundle mainBundle];

    NSString *moviePath = [bundle pathForResource

    Please Register or Log in to view images

    "abc" ofType

    Please Register or Log in to view images

    "mp4"];

    NSURL *movieURL;

    if (moviePath)
    {
    movieURL = [NSURL fileURLWithPath:moviePath];
    }

    if (movieURL != nil) {
    moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

    // Register to receive a notification when the movie has finished playing.
    [[NSNotificationCenter defaultCenter] addObserver:self
    selector

    Please Register or Log in to view images

    selector(moviePlayBackDidFinish

    Please Register or Log in to view images


    name:MPMoviePlayerPlaybackDidFinishNotification
    object:moviePlayer];

    moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
    moviePlayer.movieControlMode = MPMovieControlModeDefault;
    moviePlayer.backgroundColor = [UIColor blackColor];

    [moviePlayer play];
    }
  4. spoonforknife

    spoonforknife Retired Moderator

    Joined:
    Nov 15, 2007
    Messages:
    6,896
    Likes Received:
    317
    It seems to me that the moviePlayer is below the view.
  5. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    I think you need something like
    Code:
    [self.view addSubview:moviePlayer aboveSubview:self.view];
    
  6. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    You really need to learn a bit about how things work. You're trying to add a subclass of NSObject to a UIView... an object is not a UIView...

    Upon playing, the movie should automatically display, it may be the simulator or your phone that is messing up.
  7. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    Oh never thought of that. Disregard me in all future posts, I'm an idiot.

    Please Register or Log in to view images

Share This Page