2010-01-16 4 views
0

내 애플리케이션 번들에있는 QT 동영상을 실행하려고합니다. 그것을 작동시킬 수 없습니다. 누군가 조언 할 수 있습니까?QT 동영상을 애플리케이션 번들에 있습니다.

감사합니다.

NSError* error = nil; 
NSString* moviePath = [NSBundle pathForResource:@"bundledMovie" ofType:@"mp4" inDirectory:[[NSBundle mainBundle] bundlePath]]; 
QTMovie* movie = [QTMovie movieWithFile:moviePath error:&error]; 
if(movie != nil) 
{ 
    [movieView setMovie:movie]; 
} 
else 
{ 
    NSLog(@"Error loading movie: %@", [error localizedDescription]); 
} 

업데이트 : 당신은 NSURL을 사용하려면

, 다음을 사용

-(IBAction)runInternalMovie:(id)sender 

[ 


NSString *internalPath; 
NSURL *internalURL; 
QTMovie *internalMovie; 



internalPath = [[NSBundle mainBundle] pathForResource: @"bundledMovie" 
ofType: @"mp4"]; 
internalURL = [NSURL fileURLWithPath: internalPath]; 
internalMovie = [[QTMovie alloc] initWithURL: internalURL byReference: YES]; 

} 

답변

1

나는 항상 QTMovie의 initWithFile: 방법을 사용하십시오

NSError* error = nil; 
QTMovie* movie = [QTMovie movieWithURL:[[NSBundle mainBundle] URLForResource:@"bundledMovie" withExtension:@"mp4"] error:&error]; 
if(movie != nil) 
{ 
    [movieView setMovie:movie]; 
} 
else 
{ 
    NSLog(@"Error loading movie: %@", [error localizedDescription]); 
} 
2

한편으로는 initWithURL:byReference: 방법이 없습니다. many ways to create a QTMovie object이 있으며 그 중 어느 것도 byReference: 매개 변수를 가지며 그 중 모두 (+movie 제외)는 error: 출력 매개 변수를 사용합니다.

동영상을로드 한 후 동영상을 표시하려면 QTMovieView에 입력해야합니다. 이러한보기를 만드는 가장 쉬운 방법은 라이브러리 패널 (QuickTime Kit 섹션)에서 xib 중 하나의 윈도우로 드래그하여 IB에 있습니다.

그런 다음 컨트롤러를 영화보기로 전환하고 영화를 만든 후 영화보기에 setMovie: 메시지를 보내거나 영화보기의 "영화"속성을 컨트롤러의 속성에 바인딩하십시오.

관련 문제