我正在創建一個播放列表格式的tableview控制器頁面,該頁面包含單元格中的視頻。點擊披露按鈕後,視頻播放等。關於如何去做這件事的任何想法?..或者一個關於它的好教程的鏈接? 我已經在this..spending那麼多時間在網上衝浪無果開裂我的頭.. 任何幫助將非常感激並表決 感謝帶有視頻顯示的表格
這裏是我的樣品code..i知道它可能不是去了解它的最佳方式,因此它是不行的工作
這裏是我的頭文件
#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>
您想在播放按鈕後播放單元格內或其他控制器中的視頻嗎? – Deepak
我想要點擊披露按鈕後播放視頻,就像youtube的工作方式@Deepak – DanKiiing
哦!所以你可以去MPMoviePlayerController。 – Deepak