さまざまなビデオの再生後に固有の情報ページを表示するアプリを作成しようとしています。現在、moviePlayBackDidFinish
通知方法で情報ページを表示していますが、さまざまなビデオ用にカスタマイズする方法がわかりません。これが私のコードです...よろしくお願いします!!
movieplayercontroller をサブクラス化した後に編集します... で新しいプロパティを使用するにはどうすればよいですNSNotification
か?
// サブクラス化された movieplayercontroller myMovie.h
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
@interface myMovie: MPMoviePlayerViewController
{
myMovie *videoPlayer;
}
@property (nonatomic, strong) NSString *movieTitle;
@end
myMovie.m
#import "myMovie.h"
@interface myMovie ()
@end
@implementation myMovie
@synthesize movieTitle;
@end
//メインビューコントローラー
videoPlayViewController.h
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
#import "View2.h"
#import "myMovie.h"
@interface videoPlayViewController : UIViewController
-(IBAction) playMovie;
videoPlayViewController.m
#import "videoPlayViewController.h"
#import "myMovie.h"
@interface videoPlayViewController ()
@end
@implementation videoPlayViewController
-(void)playMovie
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"sample" ofType:@"mov"]];
myMovie *videoPlayer = [[myMovie alloc]
initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:videoPlayer.moviePlayer];
videoPlayer.moviePlayer.controlStyle = MPMovieControlStyleDefault;
videoPlayer.moviePlayer.shouldAutoplay = NO;
videoPlayer.movieTitle = @"sample";
[self.view addSubview:videoPlayer.view];
[videoPlayer.moviePlayer setFullscreen:YES animated:YES];
}
- (void) moviePlayBackDidFinish:(NSNotification*)notification {
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
NSLog(@"Is this working?");
View2 *second =[[View2 alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:second animated:YES];
[player.view removeFromSuperview];
}