2011-04-07 18 views
0

的代碼只是簡單的和平(文件1.MP3點擊,在iTunes中播放以及):QTKit奇怪的錯誤

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 

NSError *outError = nil; 
QTMovie *newMovie = [QTMovie movieWithURL:[NSURL URLWithString:@"/Users/Alex/1.mp3"] error:&outError]; 
if (newMovie) { 
    //[newMovie setAttribute:[NSNumber numberWithBool:YES] forKey:QTMovieEditableAttribute]; 

    [self setMovie:newMovie]; 
} 
[movie play]; 

給我錯誤

  • 錯誤域= NSOSStatusErrorDomain 代碼= -2000 UserInfo = 0x2004a6de0「A 必要的數據引用不能被解決。」 「。

回答

1

更改

[movie play]; 

[movie autoplay]; 

可以幫助你。 QTMovie在後臺加載數據,因此要求在其創建後立即播放數據可能太快,因此QTMovie無法真正播放該文件。

1

您需要使用fileURLWithPath:而不是URLWithString:來創建file:NSURLURLWithString:是爲像http:網址等

嘗試:

QTMovie *newMovie = [QTMovie movieWithURL: 
    [NSURL fileURLWithPath:@"/Users/Alex/1.mp3"] error:&outError];