0

I am using MPMoviePlayer to play local video files in my app. Files are .mov formated. When I run my app in simulator it works fine. But when I run it in iPhone video runs with no sound. Here is my code,

    self.currUrl = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Gun_Shot" ofType:@"mov"]];
    if (self.mpc)
     {
       [self.mpc release];
       self.mpc = nil;
     }
    self.mpc =  [[MPMoviePlayerController alloc]
             initWithContentURL:self.currUrl];   
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.mpc];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackLoadStateDidChange:) name:MPMoviePlayerLoadStateDidChangeNotification object:self.mpc];   
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidEnterFullScreen:) name:MPMoviePlayerDidEnterFullscreenNotification object:self.mpc];    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidExitFullScreen:) name:MPMoviePlayerDidExitFullscreenNotification object:self.mpc]; 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackNowPlayingContinues:) name:MPMoviePlayerNowPlayingMovieDidChangeNotification object:self.mpc];  
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackStateChanged:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:self.mpc];

    self.mpc.controlStyle = MPMovieControlStyleNone;
    self.mpc.shouldAutoplay = NO;
    self.mpc.view.frame = CGRectMake(0, 0, self.mpView.frame.size.width, self.mpView.frame.size.height);
    [self.mpView addSubview:self.mpc.view];
    [self.mpView bringSubviewToFront:self.topMainView];
    [self.mpView bringSubviewToFront:self.bottomMainView];
    [self.mpc prepareToPlay];
    self.timeLbl.text = [NSString stringWithFormat:@"%f Sec(s)", self.mpc.duration];

I don't understand why the videos gone mute when the app runs on iPhone. Any help will be appreciated..

Esty
  • 1,882
  • 3
  • 17
  • 36

1 Answers1

1

Without looking at your code. One reason could be that your iPhone is in silent mode.

This answer might also help you.

Community
  • 1
  • 1
Masa
  • 3,241
  • 1
  • 16
  • 12
  • Why I have to use AVAudioSession! As per all the tutorials MPMoviePlayer is able to do what I seek. As per I know MPMoviePlayer can play .mp4, .3gp and .mov formats. But when I give .mp4 / .3gp my app crashed. For .mov it played but no sound. Is there any method for the audio in MPMoviePlayer that I have missed ?!? – Esty Mar 28 '13 at 12:45