1

リモートURLのMPMoviePlayerControllerのインスタンスを起動すると、上部のバーに「ムービーを読み込んでいます...」と表示されます。このメッセージをカスタムメッセージに変更する方法はありますか?

4

1 に答える 1

2

表示したい画像 (またはラベルなど) を使用して UIImageView を作成し、それを MoviePlayerControllerView に追加するだけです。

UIImage *loadingScreenImage = [UIImage imageNamed:@"loadingScreen.png"];
loadingScreen = [[UIImageView alloc] initWithImage:loadingScreenImage]; // ivar & property are declared in the interface file
[self.view addSubview:loadingScreen];
[loadingScreen release];

次に、ムービー プレーヤーをインスタンス化し、loadState が変更されたときに通知を受け取るように登録できます。

moviePlayer =  [[MPMoviePlayerController alloc] initWithContentURL:movie.trailerURL];

if ([moviePlayer respondsToSelector:@selector(loadState)]) {

        [moviePlayer prepareToPlay];

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerLoadStateChanged:) name:MPMoviePlayerLoadStateDidChangeNotification object:moviePlayer];}  

次に、通知メソッドで、プレーヤーをビューに追加するロジックを実行します。

- (void) moviePlayerLoadStateChanged:(NSNotification*)notification 
{
    // Unless state is unknown, start playback
    switch ([moviePlayer loadState]) {
        case MPMovieLoadStateUnknown:
            break;
        case MPMovieLoadStatePlayable:
            // Remove observer
            [[NSNotificationCenter defaultCenter] 
             removeObserver:self
             name:MPMoviePlayerLoadStateDidChangeNotification 
             object:nil];

            // Set frame of movie player
            [moviePlayer.view setFrame:CGRectMake(0, 0, 480, 320)];
            [moviePlayer setControlStyle:MPMovieControlStyleFullscreen];
            [moviePlayer setFullscreen:YES animated:YES];
            [self.view addSubview:[moviePlayer view]];   

            // Play the movie
            [moviePlayer play];
                        ...
}
于 2010-12-04T10:32:32.087 に答える