video is not playing on ipad(device) when i use a separate audio track with it

Posted by sujith1406 on Stack Overflow See other posts from Stack Overflow or by sujith1406
Published on 2011-06-29T07:26:00Z Indexed on 2011/06/29 8:22 UTC
Read the original article Hit count: 170

In my application i need to play a video(silent ) together with another audio.i am using mpmovieplayercontroller for video and avaudioplayer for audio.the problem is on device (for ipad) the video is not playing .it is working perfect on ipad and iphone simulator .also on iphone .i am using ipad (os 3.2 ) installed.why is this so??

this is the code i am using

NSString *trackname=[dict objectForKey:@"AudioFile"];
    NSLog(@"track--->%@",trackname);
    NSString *newAudioFile = [[NSBundle mainBundle] pathForResource:trackname ofType:@"mp4"];
    player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL  fileURLWithPath:newAudioFile] error:NULL];
    if(error) {
        NSLog(@"%@",&error);
    }
    [player prepareToPlay];
    [player play];
    player.numberOfLoops=0;
    slider.maximumValue=player.duration;
    slider.minimumValue=0;
    [playpausebtn setBackgroundImage:[UIImage imageNamed:@"pausebutton.png"] forState:UIControlStateNormal];
    timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(updateSlider) userInfo:nil repeats:YES];
    NSString *videoFile = [[NSBundle mainBundle] pathForResource:@"video-track" ofType:@"mp4"];
    moviePlayer=[[MPMoviePlayerController alloc]initWithContentURL:[NSURL  fileURLWithPath:videoFile]];
    [[moviePlayer view] setFrame: [videoView bounds]];  // frame must match parent view
    [videoView addSubview: [moviePlayer view]];
    [videoView setBackgroundColor:[UIColor blackColor]];
    moviePlayer.repeatMode=MPMovieRepeatModeOne;
    moviePlayer.controlStyle=MPMovieControlStyleNone;
    [moviePlayer play];

© Stack Overflow or respective owner

Related posts about iPad

Related posts about mpmovieplayercontroller