MT Demo

ViewController.h

#import <UIKit/UIKit.h>

#import <AVFoundation/AVFoundation.h>

#import <MediaPlayer/MediaPlayer.h>

@interface ViewController : UIViewController <UITableViewDataSource,UITableViewDelegate>

@property MPMoviePlayerViewController *moviePlayer;

@end

ViewController.m

#import “ViewController.h”

@interface ViewController ()

@property NSArray * jsonData ;

@property NSMutableArray *name;

@property NSMutableArray *photo;

@property NSMutableArray *url;

@end

@implementation ViewController

– (void)viewDidLoad {

    [super viewDidLoad];

    

    self.name = [[NSMutableArray alloc] init];

    self.photo = [[NSMutableArray alloc] init];

    self.url = [[NSMutableArray alloc] init];

    

    NSURL *url = [NSURL URLWithString:@”http://project-demo-server.info/iphonevideo/displayvieo.php?cat=office&#8221;];

    

    NSData *data = [NSData dataWithContentsOfURL:url];

    

    NSData *photo ;

    

    self.jsonData = [NSJSONSerialization JSONObjectWithData:data options:nil error:nil];

    

    for(int i = 0; i<self.jsonData.count; i++)

    {

        

        [self.name addObject:[[self.jsonData objectAtIndex:i] valueForKey:@”videoname”]];

        

        

        photo = [[NSData alloc] initWithContentsOfURL:[[NSURL alloc] initWithString:@”http://www.project-demo-server.info/iphonevideo/images/Neck-and-Wrist-Stretches.jpg&#8221;]];

        

        [self.photo addObject:[UIImage imageWithData:photo]];

        

        [self.url addObject:[[NSURL alloc ] initWithString:[[self.jsonData objectAtIndex:i] valueForKey:@”video”]]] ;

    

    }

    // Do any additional setup after loading the view, typically from a nib.

}

– (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

– (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

#warning Potentially incomplete method implementation.

    // Return the number of sections.

    return 1;

}

– (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

#warning Incomplete method implementation.

    // Return the number of rows in the section.

    return [self.name count];

}

– (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@”cell” forIndexPath:indexPath];

     if(cell == nil)

     {

     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@”cell”];

     }

     

     cell.textLabel.text = [self.name objectAtIndex:indexPath.row];

     

     cell.imageView.image = [self.photo objectAtIndex:indexPath.row];

     

return cell;

}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

    

   // NSString *path = [[NSBundle mainBundle]pathForResource:

                     // @”videoTest” ofType:@”mov”];

    

    self.moviePlayer = [[MPMoviePlayerViewController

                    alloc]initWithContentURL:[self.url objectAtIndex:indexPath.row]];

    [self presentModalViewController:self.moviePlayer animated:NO];

}

@end

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s