-1

이제 MPMoviePlayer과 관련된 새로운 질문이 있습니다. 나는 ipad의 한쪽에있는 비디오를 다른 쪽에서 나열하는 테이블 뷰를 가지고 있습니다. 목록에서 선택한 비디오를 재생합니다. 동일한보기에서 발생합니다. 이제 다른 동영상으로 전환하면 문제가 없습니다. 이제 UIVideoEditorController을 사용하여 비디오를 편집 할 때 문서 폴더에서 현재 비디오 파일을 바꾸고 비디오를 다시 재생합니다. 하지만 내 선수는 일을 그만 둔다.MPMoviePlayer를 사용하여 동영상 재생

내 생각에 문제는 그 플레이어가 UIVideoEditorController 내에서 제대로 풀리지 않는다고 생각한다. 내가 편집기를 발표하지만 여전히 내가 거기 만입니다 .. 아무것도가 다시 작동하지 않습니다 :(

나를 도와주세요 최대한 빨리

-(void)playVideoWithIndex:(NSNumber *)index1 
{ 
int index = [index1 intValue]; 
indexVideo = [index1 intValue]; 
if(index > [SourceArray count]){ 
    NSLog(@"dg"); 
    return; 
} 

if (mp) { 
    [mp stop]; 
    [mp.view removeFromSuperview]; 
    [mp release]; 
    mp=nil; 
} 
// NSArray *sourcePaths=[[NSArray alloc] initWithArray:[[NSBundle mainBundle] pathsForResourcesOfType:@"mov" inDirectory:nil]]; 
videoDtls *v =[SourceArray objectAtIndex:index]; 
lbl_date.text=v.iVideoDate; 
lbl_Title.text=v.iVideoTitle; 
lbl_description.text=v.iVideoDesc; 
lblDesc.text = @"Description"; 

lable_title.text = v.iVideoTitle; 
NSString *documentFolderPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; 
NSString *mainImageFolderPath=[documentFolderPath stringByAppendingPathComponent:@"Videos"]; 
NSString *urlStr = [mainImageFolderPath stringByAppendingPathComponent:v.iVideoPath]; 
self.vpath = urlStr; 
NSLog(@"asdsd %@",urlStr); 
NSURL *url = [NSURL fileURLWithPath:urlStr]; 


mp = [[MPMoviePlayerController alloc] initWithContentURL:url]; 

if ([mp respondsToSelector:@selector(loadState)]) 
{ 
    // Set movie player layout 
    //[mp setControlStyle:MPMovieControlStyleFullscreen]; 

    //[mp setFullscreen:YES]; 
    // May help to reduce latency 
    [mp prepareToPlay]; 
    mp.useApplicationAudioSession = NO; 
// mp.controlStyle = MPMovieControlStyleDefault; 
// mp.useApplicationAudioSession = YES; 
    // Register that the load state changed (movie is ready) 
    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(moviePlayerLoadStateChanged:) 
               name:MPMoviePlayerLoadStateDidChangeNotification 
               object:nil]; 
    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(moviePlayerEnterFullScreen:) 
               name:MPMoviePlayerDidEnterFullscreenNotification 
               object:nil]; 

    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(moviePlayerExitFullScreen:) 
               name:MPMoviePlayerWillExitFullscreenNotification 
               object:nil]; 
    [[NSNotificationCenter defaultCenter] 
    addObserver:self 
    selector:@selector(moviePlayerDidFinish:) 
    name:MPMoviePlayerPlaybackDidFinishNotification 
    object:nil]; 

    [[mp view] setFrame:CGRectMake(0, 0, 480, 320)]; 

    // Add movie player as subview 
    [playerView addSubview:[mp view]]; 
    mp.initialPlaybackTime = -1.0; 




} 
else 
{ 
    // Register to receive a notification when the movie is in memory and ready to play. 
    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(moviePreloadDidFinish:) 
               name:MPMoviePlayerContentPreloadDidFinishNotification 
               object:nil]; 
} 

// Register to receive a notification when the movie has finished playing. 
[[NSNotificationCenter defaultCenter] addObserver:self 
             selector:@selector(moviePlayBackDidFinish:) 
              name:MPMoviePlayerPlaybackDidFinishNotification 
              object:nil]; 

}

비디오가 테이블보기에서 재생 될 때이 메소드가 호출된다. 에디터가 SUC을 반환 할 때이 메소드가 불려

.

- (void)videoEditorController:(UIVideoEditorController *)editor didSaveEditedVideoToPath:(NSString *)editedVideoPath 
{ 
CFShow(editedVideoPath); 
NSFileManager *fileManager = [[NSFileManager alloc] init]; 
NSError *error = nil; 
NSString *path = self.vpath; 
NSLog(@"PATH %@", self.vpath); 
if([fileManager removeItemAtPath:path error:&error] != YES){ 
    NSLog(@"ERROR 1 : %@",[error localizedDescription]); 
} 
else{ 
// can do save here. the data has *not* yet been saved to the photo album 
if ([fileManager copyItemAtPath:editedVideoPath toPath:path error:&error] != YES) 
    NSLog(@"Can't move file with error: %@", [error localizedDescription]); 
} 
[popOver dismissPopoverAnimated:YES]; 
[self dismissMoviePlayerViewControllerAnimated]; 
[editor release]; 
[self performSelector:@selector(playVideoWithIndex:) withObject:[NSNumber numberWithInt:indexVideo] afterDelay:0.2]; 

} 고마워. 후 내 비디오가 재생되지 않습니다

답변

0

마지막으로 UIVideoEditorController를 다른보기 컨트롤러에서 사용하고 몇 초 동안 재생하는 것을 지연하여 문제를 해결했습니다. 내가 교체 된 비디오를 재생하려고했기 때문에 이런 일이 발생할 수 있습니다.

관련 문제