MPMoviePlayerController “Loading Movie from server - mpmovieplayercontroller

its problem when i play the video it shows black screen and playing audio without the video and can't do any thing but close app.
here is my code
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *movieURL = [NSString stringWithFormat:#"http://www.aliakbar84.com/test/%d.mp4",indexPath.row];
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:movieURL]];
[moviePlayer play];
MPMoviePlayerViewController *movieplayer1 = [[MPMoviePlayerViewController alloc] initWithContentURL:movieurl];
[self presentMoviePlayerViewControllerAnimated:movieplayer1];

Why exactly are you initializing both, MPMoviePlayerController and MPMoviePlayerViewController?
That should not be done. Remove the initializing of MPMoviePlayerController!

Related

Display images from URL in a Detailviewcontroller with Tableviewcontroller as a parent

Hard to explain, but I'll try;
I am making an app for showing roadcameras. I have a TableViewController which leads to a DetailViewController.
What I want to achieve is that when I click on Row 1 it shows the picture from www.url1.com. If I click on Row 2, it shows the picture from www.url2.com, and so on. I can't seem to figure out how to do this.
I first started by using this code:
_place = #[#"E6 Minnesund",
#"E6 Heia"];
_url = #[#"http://webkamera.vegvesen.no/kamera?id=450848",
#"http://webkamera.vegvesen.no/kamera?id=100102"];
But stopped because I couldn't see how I could get this working...
Any ideas?
And please don't just rate the post down because you think its stupid. I'm kinda new to Xcode and for me, this is hard. Thanks in advance
I can post the whole project folder if necessary
just write the code in didselectrowAtIndexPath
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailViewController *picker = [[DetailViewController alloc] initWithNibName:#"DetailViewController" bundle:nil];
picker.row=indexPath.row;
[self.navigationController pushViewController:picker];
}
and in DetailViewController
in .h
#interface DetailViewController : UIViewController
{
}
#property(nonatomic,assign)int row;
in .m
- (void)viewDidLoad
{
dispatch_queue_t myqueue = dispatch_queue_create("myqueue", NULL);
// execute a task on that queue asynchronously
dispatch_async(myqueue, ^{
NSURL *url = [NSURL URLWithString:[_url objectAtIndex:row];
NSData *data = [NSData dataWithContentsOfURL:url];
dispatch_async(dispatch_get_main_queue(), ^{
Image.image = [UIImage imageWithData:data]; //UI updates should be done on the main thread
UIImageView * myImageView = [[UIImageView alloc] initWithImage:image];
[self.view addSubview:myImageView];
});
});

Xcode parsing RSS XML with images issue

I am trying to parse text with images in the UITableView and I can only see the text for every line but I can't see the images.
Here is my code;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [self.anaTablo dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
UILabel *textBaslik = (UILabel *) [cell viewWithTag:3];
UIImage *imagePic = (UIImage *) [cell viewWithTag:7];
textBaslik.text =[titleArray objectAtIndex:indexPath.row];
imagePic.images = [imageArray objectAtIndex:indexPath.row];
return cell;
}
but it didn't works and after searching I have tried this to;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
UILabel *textBaslik = (UILabel *) [cell viewWithTag:3];
UIImage *imagePic = (UIImage *) [cell viewWithTag:7];
textBaslik.text =[titleArray objectAtIndex:indexPath.row];
NSString *str1 = [[NSString alloc] initWithFormat:#"%#", imageArray];
NSData *bgImageData = [NSData dataWithContentsOfFile:str1];
UIImage *img1 = [UIImage imageWithData:bgImageData];
imagePic = [img1 objectAtIndex:indexPath.row];
return cell
}
Am I doing something wrong? I am kind new to Xcode
Thanks from now.
I check you code and i change the following
NSString *str1 = [[NSString alloc] initWithFormat:#"%#", imageArray];
NSData *bgImageData = [NSData dataWithContentsOfFile:str1];
UIImage *img1 = [UIImage imageWithData:bgImageData];
imagePic = [imageArray objectAtIndex:indexPath.row];
cell.imageView.image=imagePic;
in the delegate method
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
Now a new error appear, check it
Check this tutorial about parsing RSS with XMLParses, it works perfectly.
Wiki XML parse data
You should check this sample code using TBXML framework
TBXML parser

MPMoviePlayerController not playing URL from GDataFeedYouTubeVideo

I am using GDataFeedYouTubeVideo to populate a tableview with images and titles. This works. I want to play the video after the cell is selected. I am using the url from the feed to pass to the MPMoviePlayer and it looks like it loads because the screen goes black, the moviePlaybackDidFinish is called but does not play the video and goes back to displaying the tableview? An example url from the feed is:
https://www.youtube.com/v/o7QAMH3qRvU?version=3&f=user_uploads&app=youtube_gdata
This does work from a browser but not in the MPMoviePlayer? Please help me figure this one out. I would rather not have to write some hack routine to replace or remove the URLString returned by the feed. I am using ARC & Storyboards. The second time I select a cell I get:
An instance 0xce6a7b0 of class AVPlayerItem was deallocated while key value observers were still registered with it...
Yes I did try what was suggested in:
iOS 5 an instance of AVPlayerItem was deallocated
and this did not fix it.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
YouTubeVideo *item = [searchList objectAtIndex:indexPath.row];
if (item != nil) {
NSURL *url = [NSURL URLWithString:item.URLString];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(moviePlaybackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
}
}
- (void)moviePlaybackDidFinish:(NSNotification *)notification {
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
if ([player respondsToSelector:#selector(setFullscreen:animated:)])
[player.view removeFromSuperview];
}
Tried this and it works if I format the url slightly:
https://github.com/hellozimi/HCYoutubeParser

Xcode: How to switch to another window using TableView?

the error ---> when i click the name the application crashes...
rectification---> when i click the name in table it should jump to another view...
my code is
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[ListArr objectAtIndex:indexPath.row];
ListData *oList = [[ListData alloc] initWithNibName:#"ListData" bundle:nil];
NSString *psCatId = [NSString stringWithFormat:#"%d",indexPath.row+1];
oList.psId = psCatId;
[self presentModalViewController:oList animated:YES];
[oList release];
}

mwfeedpaser detailview

I just started using xcode and OBJ-c this year.
I am using mwfeedparser for a app I'm making but would like to change the look of the detailview.
right now i'm using the demo app that came with mwfeedparser to change the detail view.
i would like the detail view to have labels instead of being a tableview
i have changed this code
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DetailViewController *detail = [[DetailViewController alloc] initWithNibName:#"DetailView" bundle:nil];
detail.item = (MWFeedItem *)[itemsToDisplay objectAtIndex:indexPath.row];
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detail animated:YES];
// Deselect
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
when i run the code the detailview doesn't even come up. am I doing something wrong?
thanks for your help.
btw when i do get this done I'll put it up on github incase anybody else needs it
enter code hereself.parsedItems = [[NSMutableArray alloc] init];
- (void)feedParser:(MWFeedParser *)parser didParseFeedItem:(MWFeedItem *)item{
if (item) {
[self.parsedItems addObject:item];
}
}
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
DetailViewController *detail = [[DetailViewController alloc] initWithNibName:#"DetailView" bundle:nil];
detail.item = [self.parsedItems objectAtIndex:indexPath.row];
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detail animated:YES];
}

Resources