ビデオが再生されますが、写真はありません - ただ音ですか?
-
02-10-2019 - |
質問
編集: :あなたがこれに出会って、私が最終的にそれをどのように解決したかを知りたい場合、私は最終的にそのコードをあきらめ、これを行いました:
-(void)playMovieAtURL:(NSURL*)theURL{
mediaPlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:theURL];
[self presentMoviePlayerViewControllerAnimated:mediaPlayer];
mediaPlayer.view.backgroundColor = [UIColor blackColor];
}
オリジナル投稿:
これは私のコードです - 私はそれをAppleサイトから取り除いたので、問題はありません。
DidSeLectRowAtIndexPathメソッドのuitableviewcontrollerで実行されます。
行を選択すると、ビデオが再生を開始します - サウンドは少なくとも出力されます - しかし、写真はありません。なぜこれがなぜですか?フレームワークを含めました。
このビデオは、テストに使用したApple Webサイト(FaceTimeビデオ)の1つです。
-(void)playMovieAtURL:(NSURL*)theURL{
MPMoviePlayerController* theMovie =
[[MPMoviePlayerController alloc] initWithContentURL: theURL];
theMovie.scalingMode = MPMovieScalingModeAspectFill;
theMovie.controlStyle = MPMovieControlStyleNone;
// Register for the playback finished notification
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(myMovieFinishedCallback:)
name: MPMoviePlayerPlaybackDidFinishNotification
object: theMovie];
// Movie playback is asynchronous, so this method returns immediately.
[theMovie play];
}
解決
mpmovieplayercontrollerの動作はOS 3.2で変更されました - 今すぐ階層に映画プレーヤーのビューを明示的に追加する必要があります - 次のようなものを使用してください。
[aView addSubview:moviePlayerController.view];
moviePlayerController.view.frame = aView.frame;
または、mpmovieplayerviewcontroller(3.2の新規)を使用して、ビューを管理できます。
前と3.2ポストの両方のデバイス(IOS 3.1および4.0など)の両方をターゲットにしている場合、コードが実行されているOSを決定し、それに応じて処理するために条件付きコードが必要です。私はこれを以前のプロジェクトで使用しました:
if ([moviePlayerController respondsToSelector:@selector(setFullscreen:animated:)]) {
// Running on OS 3.2 or above
// Code to add to a view here...
}
所属していません StackOverflow