2011-04-12 36 views
2

每當我的應用程序更改顯示的動畫,這是一個循環電影,他停下來,直到他最終開始電影。 的MoviePlayerConntroller創建這樣MPMoviePlayerController延遲應該幾乎沒有

self.moviePlayer = [MPMoviePlayerController alloc]; 
    [moviePlayer initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"NewChar" ofType:@"m4v"]] ]; 
    // remove playerview from our view (no prob is he isnt attached to any) 
    [moviePlayer.view removeFromSuperview]; 
    // tell our playerview the size he has to use 
    moviePlayer.view.frame = CGRectMake(0, 0, 320, 430); 
    // and add hin to the superview behind everything else 
    [self.view insertSubview:moviePlayer.view atIndex:0]; 
    // no moviecontrolls 
    moviePlayer.controlStyle = MPMovieControlStyleNone; 
    // looping forever 
    moviePlayer.repeatMode= MPMovieRepeatModeOne; 
    // let him use his own Audio Session for old devices 
    moviePlayer.useApplicationAudioSession= NO; 
    // fix the silly black background on iOS 4.3 
    moviePlayer.view.backgroundColor = [UIColor clearColor]; 

實際電影播放這樣

[moviePlayer initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Whatever" ofType:@"m4v"]]]; 
[moviePlayer play]; 

正如我所說的,每個電影改變時,他需要一段時間來顯示它。在較新的設備上可以,因爲它們速度更快,但在G2上它有點令人不安。 嘗試準備播放,但這沒有什麼區別。

任何想法我錯過了什麼?

感謝您的閱讀! :)

回答

1

從磁盤加載電影需要一定的時間,並且在較舊的設備上顯然會變慢。視頻有多大?

+1

57kb。我怎麼能在內存中保存電影?爲每個動畫構建一堆電影播放器​​會有點矯枉過正。也許有更好的方法? SpaceAce和DragonsLair Apps播放電影。不知道他們怎麼做,沒有掛。 – 2011-04-12 13:43:02