ムービープレーヤーのビデオの上にビュー/ラベル/ボタンを表示する際に問題が発生しました。Apple の MoviePlayer サンプル プロジェクトでは、次のコードを使用してビデオの上にビューを追加できます。
MoviePlayerAppDelegate *appDelegate = (MoviePlayerAppDelegate *)[[UIApplication sharedApplication] delegate];
// initialize a new MPMoviePlayerController object with the specified URL, and play the movie
[appDelegate initAndPlayMovie:[self localMovieURL]];
NSArray *windows = [[UIApplication sharedApplication] windows];
if ([windows count] > 1) {
// Locate the movie player window
UIWindow *moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];
// Add our overlay view to the movie player's subviews so it is displayed above it.
[moviePlayerWindow addSubview:self.overlayView];
}
overlayview は、要求されたラベルとボタンを含むビューです。ただし、.m3u8 ファイルを含む映画の URL に同じコードを適用すると、オーバーレイ ビューが表示されません。
NSURL *newMovieURL = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8">];
if (movieURL) {
NSLog(@"movieURL");
if ([movieURL scheme]) // sanity check on the URL
{ NSLog(@"[movieURL scheme]");
[appDelegate initAndPlayMovie:newMovieURL];
NSArray *windows = [[UIApplication sharedApplication] windows];
NSLog(@"windows count:%d", [windows count]);
if ([windows count] > 1) {
UIWindow *moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];
[moviePlayerWindow addSubview:self.overlayView];
}
}
else NSLog(@"![movieURL scheme]"); } else
NSLog(@"!movieURL");
ムービーが再生されても、返されるウィンドウの数は前の例の 2 に対して 1 だけです。URL が正常かどうかを確認すると、movieURL は null を返しますが、ストリーミングされたコンテンツは引き続き再生されます。ウィンドウ数が 1 より大きいかどうかのチェックを外してみましたが、それでもオーバーレイ ビューは表示されませんでした。
誰もこれを回避する方法を知っていますか? ありがとう