user3197287
user3197287

Reputation: 17

passing video url using json in ios

hi I'm trying to view the videos from my server for that i have stored the video url in mysql database using the json and php code I'm passing the url to the iOS but now I'm getting some problem here

previously using this same format fetching the images from my server but now i want to view the videos this is the first time im working on the videos not to able to get it

this is the code which i used to fetch the url form database and liking to the ios nsurl format

tabecell.m file code:

#import "vediopoliticalCell.h"
#import "vedios.h"
@implementation vediopoliticalCell
   //@synthesize movieplayer,titile;

 - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
          {
      self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
        if (self) {
               // Initialization code
                  }
                       return self;
             }

        - (void)setSelected:(BOOL)selected animated:(BOOL)animated
          {
              [super setSelected:selected animated:animated];

              // Configure the view for the selected state
           }

       -(void)setDataSource:(vedios *)inVideosObj
         {
              self.titile.text = inVideosObj.title;

             NSURL *url =[NSURL URLWithString:inVideosObj.video];
             NSURLRequest *request =[NSURLRequest requestWithURL:url];
             connection =[[NSURLConnection alloc] initWithRequest:request delegate:self];
             self.responseData = [[NSMutableData alloc]init];
         }
        - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
         {
              [self.responseData appendData:data];
         }

           - (void)connectionDidFinishLoading:(NSURLConnection *)connection;
             {
                 MPMoviePlayerController *play = [[MPMoviePlayerController    alloc]initWithContentURL:self.responseData];
             }

In this code:

 - (void)connectionDidFinishLoading:(NSURLConnection *)connection;
             {
                 MPMoviePlayerController *play = [[MPMoviePlayerController    alloc]initWithContentURL:self.responseData];
             }

im getting a waring called: Incompatible pointer types sending 'NSMutableData ' to parameter of type Nsurl

previously for the image i using this code:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection;
   {
       UIImage *image = [UIImage imageWithData:self.responseData];
       self.thumbImageView.image = image;
   }

now i dont know how to use for the videos please can anyone help me with this

thanks in advance

Upvotes: 1

Views: 564

Answers (2)

santhu
santhu

Reputation: 4792

self.responseData is NSMutableData but MPMoviePlayerController needs url to load the video.

So, first you have to get url-string from data.

NSString *url =[NSString stringWithUTF8String:[responseData bytes]]
MPMoviePlayerController *play = [[MPMoviePlayerController    alloc]initWithContentURL:[NSURL urlWithString:url]];
//Now present the MPMoviePlayerController

Upvotes: 1

Akhilrajtr
Akhilrajtr

Reputation: 5182

Try this

In setDataSource: method

-(void)setDataSource:(vedios *)inVideosObj
{
     self.titile.text = inVideosObj.title;

     NSURL *url =[NSURL URLWithString:inVideosObj.video];
     MPMoviePlayerViewController *videoDeatilView = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
     //now you can present this videoDeatilView and 
     //[videoDeatilView.moviePlayer play]; will play the video
}

Upvotes: 1

Related Questions