2011-06-08 62 views
1

我要演電影與控制 - 播放,停止,快進,等我用這個代碼:播放電影與MPMoviePlayer - 控制將不顯示

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    NSURL *movieUrl = [NSURL fileURLWithPath: 
         [[NSBundle mainBundle] pathForResource:@"Spot" 
                 ofType:@"mp4"]]; 

    MPMoviePlayerController* myMovie=[[MPMoviePlayerController alloc] 
             initWithContentURL:movieUrl]; 

    //disable scaling of our movie 
    myMovie.scalingMode = MPMovieScalingModeNone; 
    [myMovie.view setFrame: myView.bounds]; 
    [myView addSubview: myMovie.view]; 

    [[myMovie view] setFrame:[myView bounds]]; 
    myMovie.initialPlaybackTime = 2.0; 

    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(movieFinished:) 
               name:MPMoviePlayerPlaybackDidFinishNotification 
               object:myMovie]; 
    myMovie.scalingMode = MPMovieScalingModeAspectFill; 
    myMovie.controlStyle = MPMovieControlStyleEmbedded; 
    [myMovie play]; 
    // Do any additional setup after loading the view from its nib. 
} 

的電影作品,但有沒有控制。任何人都可以幫助我嗎?

回答

0

嘗試,如果這個工程...

-(void)viewWillAppear:(BOOL)animated 
{ 
    NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"Spot.mp4" ofType:nil]; 
    NSURL *url = [NSURL fileURLWithPath:urlStr]; 
    moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url]; 
    [self.view addSubview:moviePlayer.view]; 
    moviePlayer.view.frame = CGRectMake(0, 0, 300, 400); 
    [moviePlayer play]; 
} 

你會得到所有的控制。

+0

謝謝你的工作 – user761812 2011-06-08 18:22:54

相關問題