2013-09-30 4 views
0

내가 작업중인 모바일 응용 프로그램은 응용 프로그램의 sqlite 데이터베이스에 정의 된 URL을 열고 응용 프로그램 내의 플레이어에 비디오 내용을 스트리밍하는 webview viewcontroller를로드합니다.Webview 충돌 응용 프로그램 닫기

동영상이 제대로로드되고 재생되지만보기를 닫을 때마다 충돌이 발생합니다.

관련 OBJ-C 코드는 다음과 같습니다

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil gscreenvid:(NSString *)url { 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     gscreenvid = url; 
    } 
    return self; 
} 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    if (gscreenvid != nil && [gscreenvid compare:@""] != 0) { 
     NSURL *p_url = [NSURL URLWithString:gscreenvid]; 
     NSURLRequest *requestObj = [NSURLRequest requestWithURL:p_url]; 
     [webView loadRequest:requestObj]; 
    } 
} 

- (IBAction) cancelButtonTapped:(id) sender { 
    [self.delegate dismissViewControllerAnimated:YES completion:nil]; 
} 

답변

0

될 것으로 판단 이 줄을 viewDidLoad에 넣으십시오.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackStateDidChange:) name:@"MPAVControllerItemPlaybackDidEndNotification" object:nil]; 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerWillExitFullscreen) name:@"UIMoviePlayerControllerWillExitFullscreenNotification" object:nil]; 
} 

- (void)playerWillExitFullscreen { 
    [self.delegate dismissViewControllerAnimated:YES completion:nil]; 
    NSLog(@"done"); 
} 

- (void)playbackStateDidChange:(NSNotification *)note { 
    NSLog(@"note.name=%@ state=%d", note.name, [[note.userInfo 
    objectForKey:@"MPAVControllerNewStateParameter"] intValue]); 
    [self.delegate dismissViewControllerAnimated:YES completion:nil]; 
} 
0

내가

[self.delegate dismissViewControllerAnimated:YES completion:nil];

아래 라인은 내가 추가 내 문제를 해결하려면

[self dismissViewControllerAnimated:YES completion:nil];

+0

이 문제가 해결되지 않습니다. 여전히 검은 색으로 고정되어 고정됩니다. – davidcondrey

+0

질문을 더 읽은 후에는 MediaPlayer 프레임 워크를 사용하여 URL에서 비디오를 재생해야합니다. Vimeo가 동영상 페이지가 아닌 동영상에 대한 HTML 5 URL을 갖고 있는지 확실하지 않습니다. https://developer.apple.com/library/ios/documentation/mediaplayer/reference/MPMoviePlayerController_Class/Reference/Reference.html#//apple_ref/occ/cl/MPMoviePlayerController –