1

iPhone デバイスのサーバーからビデオを再生しようとしています。そのために次の方法を使用していますが、シミュレータでのみ機能します。iPhone 3G では動作しませんか?

iPhone 3G でこのメソッドを呼び出すと、ビデオ モーダル画面が開き、ビデオの読み込みが開始され、モーダル画面が突然閉じられます。コンソールにエラーは表示されません。

iPhone 3G にはバージョン 4.0 がインストールされています。私の iPhone 4 のバージョンは 4.1 です。

他の誰かがこれを経験しましたか?

-(IBAction)playMedia{

NSString* url = [self.data objectForKey:@"url"];    

//initialize the movie player
self.moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:url]];

//show a background image while the user waits
moviePlayerViewController.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"background.png"]];
moviePlayerViewController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;


//show the movie
[self presentMoviePlayerViewControllerAnimated:moviePlayerViewController];

[moviePlayerViewController release];

}
4

2 に答える 2

1

OK、iPhone 4 と iPhone 3G の両方でビデオが動作するようになりました。基本的に問題はファイル形式でした。.mov ファイルを再生していました。形式を .mp4 に変更すると、両方のデバイスで動作するようになりました。コードに変更はありません。

これが同じ問題を抱えている他の人に役立つことを願っています。

于 2010-09-15T00:59:38.550 に答える
0

私は上記を少し違ったやり方で行います:

-(IBAction)playMedia{ 

NSString* url = [self.data objectForKey:@"url"];     

//initialize the movie player 

MPMoviePlayerViewController *tmpPlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:url]];
self.moviePlayerViewController = tmpPlayer; 

//show a background image while the user waits 
UIColor *tmpColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"background.png"]];
self.moviePlayerViewController.view.backgroundColor = tmpColor;

self.moviePlayerViewController.moviePlayer.movieSourceType = MPMovieSourceTypeFile; 

//show the movie 
[self presentMoviePlayerViewControllerAnimated:self.moviePlayerViewController]; 

[tmpPlayer release]; 
[tmpColor release];
}
于 2010-09-13T23:11:29.180 に答える