How to play a video file from the URL of type .3gp

前端 未结 2 976
慢半拍i
慢半拍i 2021-01-16 23:51

Thanks in advance. I want to implement the code to play a video in iphone programatically from URL. I have written the code like this .

 NSURL *url = [NSURL          


        
2条回答
  •  醉梦人生
    2021-01-16 23:58

    I have played successfully .3gp with iphone sdk and my code is :

    NSString *soundLocalPath  = [[NSBundle mainBundle] pathForResource:@"Demo_video" ofType:@"3gp"];
    
    NSURL *tempUrl   = [NSURL fileURLWithPath:soundLocalPath];
    
    self.soundUrlPath = tempUrl;
    
    MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL: self.soundUrlPath];
    
    self.mpMoviePlayer = player;
    
    [player release];
    
    [self.mpMoviePlayer prepareToPlay];
    [self.mpMoviePlayer.view setFrame: self.view.bounds];  // player's frame must match parent's
    
    [self.view addSubview: self.mpMoviePlayer.view];
    
    [self.mpMoviePlayer play];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(movieFinishedCallback:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:player];
    
    
    -(void) movieFinishedCallback:(NSNotification*) aNotification
    {
        MPMoviePlayerController *player = [aNotification object];
    
        [[NSNotificationCenter defaultCenter] removeObserver:self
                                                        name:MPMoviePlayerPlaybackDidFinishNotification
                                                      object:player];
    
        [player autorelease];
    }
    

提交回复
热议问题