0

セルにビデオがあるプレイリスト形式のテーブルビュー コントローラー ページを作成しようとしています。開示ボタンをクリックすると、ビデオが再生されます。これについてのアイデアはありますか?.または、それに関する優れたチュートリアルへのリンクはありますか? 私はこれについて頭を悩ませてきました..無駄にウェブをサーフィンするのに多くの時間を費やしています..どんな助けも大歓迎であり、投票に感謝します

ここに私のサンプルコードがあります..それが最善の方法ではないかもしれないことを知っているので、うまくいきません

ここに私のヘッダーファイルがあります

 #import <UIKit/UIKit.h>
 #import <MediaPlayer/MediaPlayer.h>

 @interface BIDVideosViewController : UIViewController

 <UITableViewDelegate, UITableViewDataSource>

 @property (nonatomic,strong) NSArray *tableList;

 @end

ここに私の.mファイルがあります

 #import "BIDVideosViewController.h"

 @interface BIDVideosViewController ()
 {
 MPMoviePlayerController *moviePlayer;

 }

  @end

  @implementation BIDVideosViewController

  @synthesize tableList;

  - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
}
return self;
 }

 - (void)viewDidLoad
{
[super viewDidLoad];
UITableView *table = [[UITableView alloc]initWithFrame:self.view.bounds];
[table setDelegate:self];
[table setDataSource:self];
[self.view addSubview:table];
tableList = [[NSMutableArray alloc] initWithObjects:@"Gangan",@"SwimGood", nil];
self.tableList = array;
// Do any additional setup after loading the view.
}

 - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
 {
 return [tableList count];
 }

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {
static NSString *DisclosureButtonIdentifier = @"DisclosurebutotonIdentifier";
UITableViewCell *cell = [tableView   dequeueReusableCellWithIdentifier:DisclosureButtonIdentifier];
if (cell == nil)
{
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DisclosureButtonIdentifier];
}
NSInteger row = [indexPath row];
NSString *rowString = [tableList objectAtIndex:row];
cell.textLabel.text = rowString;
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   NSString *stringPath = [[NSBundle mainBundle]pathForResource:@"Gangan" ofType:@"mp4"];
  NSURL *url = [NSURL fileURLWithPath:stringPath];
  moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
   [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayBackDidFinish:)
                                                   name:MPMoviePlayerScalingModeDidChangeNotification
                                           object:moviePlayer];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(endPlay:)
                                                name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(stopBusyIndicator:)
                                             name:MPMoviePlayerLoadStateDidChangeNotification
                                           object:moviePlayer];

moviePlayer.scalingMode = MPMovieScalingModeAspectFit;

moviePlayer.movieControlMode = MPMovieControlModeDefault; //'movieControlMode' is deprecated

//moviePlayer.backgroundColor = [UIColor blackColor];

moviePlayer.view.frame = CGRectMake(212, 84, 600, 600);

 [self.view addSubview:moviePlayer.view];       
 [moviePlayer play];                           </i>
4

1 に答える 1

1

MediaPLayerフレームワークを追加します。

MPMoviePlayerController *moviePlayer;   
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
                [[NSNotificationCenter defaultCenter] addObserver:self
                                                         selector:@selector(moviePlayBackDidFinish:) 
                                                             name:MPMoviePlayerScalingModeDidChangeNotification 
                                                           object:moviePlayer];

                [[NSNotificationCenter defaultCenter] addObserver:self
                                                         selector:@selector(endPlay:) 
                                                             name:MPMoviePlayerPlaybackDidFinishNotification 
                                                           object:moviePlayer];
                [[NSNotificationCenter defaultCenter] addObserver:self
                                                         selector:@selector(stopBusyIndicator:) 
                                                             name:MPMoviePlayerLoadStateDidChangeNotification 
                                                           object:moviePlayer];

                moviePlayer.scalingMode = MPMovieScalingModeAspectFit; 
                moviePlayer.movieControlMode = MPMovieControlModeDefault;
                //moviePlayer.backgroundColor = [UIColor blackColor];

                    moviePlayer.view.frame = CGRectMake(212, 84, 600, 600);

                }
                [self.view addSubview:moviePlayer.view];
                [moviePlayer play];
于 2012-10-15T12:52:30.290 に答える