Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7404735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:17:52+00:00 2026-05-29T05:17:52+00:00

I am giving my entire code below if that helps anyway….. #import ContentViewController.h #import

  • 0

I am giving my entire code below if that helps anyway…..

#import "ContentViewController.h"
#import "ContentViewController.h"
#import "MediaPlayerViewController.h"
#import "TwitterViewController.h"
#import "YoutubeViewController.h"

@implementation ContentViewController

@synthesize imageView;
@synthesize imageView1;
@synthesize tableView;
@synthesize navigationController;
@synthesize toolBar;
@synthesize item;

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

- (void)didReceiveMemoryWarning
{
  // Releases the view if it doesn't have a superview.
   [super didReceiveMemoryWarning];

  // Release any cached data, images, etc that aren't in use.
}

#pragma mark - XMLParser Delegate

-(void)parseXMLFileAtURL:(NSString *)URL{

NSURL *xmlURL = [NSURL URLWithString:URL];
rssParser = [[NSXMLParser alloc]initWithContentsOfURL:xmlURL];
[rssParser setDelegate:self];
[rssParser setShouldProcessNamespaces:NO];
[rssParser setShouldReportNamespacePrefixes:NO];
[rssParser setShouldResolveExternalEntities:NO];
[rssParser parse];
NSLog(@"Parsed");
}

-(void)parserDidStartDocument:(NSXMLParser *)parser{

NSLog(@"Found file and started parsing");
}

-(void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError{

NSString *errorString = [NSString stringWithFormat:@"Unable to download feed from website (Error Code %i)",  [parseError code]];
NSLog(@"Error parsing xml: %@", errorString);
UIAlertView *errorAlert = [[UIAlertView alloc]initWithTitle:@"Error loading content" message:errorString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
}

-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{

  currentElement = [elementName copy];
   if ([elementName isEqualToString:@"channel"]) {

    rssElement      = [[NSMutableDictionary alloc]init];

    title           = [[NSMutableString alloc]init];
    link            = [[NSMutableString alloc]init];
    description     = [[NSMutableString alloc]init];
    copyright       = [[NSMutableString alloc]init];
  } 
}


-(void)parser: (NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{

    if ([elementName isEqualToString:@"channel"]) {

    [rssElement setObject:title                 forKey:@"title"];
    [rssElement setObject:link                  forKey:@"link"];
    [rssElement setObject:description           forKey:@"description"];
    [rssElement setObject:copyright             forKey:@"copyright"];

    [item addObject:[rssElement copy]];
    NSLog(@"adding stories %@", title);
  }
}


-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{

  if ([currentElement isEqualToString:@"title"]) {
    [title appendString:string];
  }else if ([currentElement isEqualToString:@"link"]) {
    [link appendString:string];
  }else if ([currentElement isEqualToString:@"description"]) {
    [description appendString:string];
  }else if ([currentElement isEqualToString:@"copyright"]) {
    [copyright appendString:string];
  }
}

-(void)parserDidEndDocument:(NSXMLParser *)parser{

NSLog(@"all done");
NSLog(@"item array has %d items", [item count]);
[tableView reloadData];
NSLog(@"Finished Parsing");
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
  [super viewDidLoad];
  // Do any additional setup after loading the view from its nib.

/* Add Segmented Controller */

if (segmentedControl == nil) {
    segmentedControl = [[UISegmentedControl alloc] initWithItems:
                        [NSArray arrayWithObjects:@"Video", @"Images", @"Audio", nil]];
}


[segmentedControl setFrame:CGRectMake(55.0, 47.0, 180.0, 31.0)];
[segmentedControl setSegmentedControlStyle:UISegmentedControlStyleBar];
[segmentedControl setWidth:70.0 forSegmentAtIndex:0];
[segmentedControl setWidth:70.0 forSegmentAtIndex:1];
[segmentedControl setWidth:70.0 forSegmentAtIndex:2];
[segmentedControl addTarget:self 
                     action:@selector(segmentClick:) 
           forControlEvents:UIControlEventValueChanged];
[segmentedControl setMomentary:YES];

//    [[[segmentedControl subviews]objectAtIndex:0]setTintColor:[UIColor blackColor]];

[self.view addSubview:segmentedControl];

/* Add Image View */

imageView1.image = [UIImage imageNamed:@"Harry.png"];

/* Add Page Control */

pageControl = [[UIPageControl alloc] init];
pageControl.frame = CGRectMake(120.0, 250.0, 100.0 ,10.0);
pageControl.numberOfPages = 5;
pageControl.currentPage = 0;

[self.view addSubview:pageControl];

/* Customize Table View */

tableView.backgroundColor = [UIColor clearColor];
imageView.image = [UIImage imageNamed:@"gradientBackground.png"];

item = [[NSMutableArray alloc]init];

if ([item count] == 0) {

    path = @"http://172.19.58.172/Android/GetApprovedList.php?ip=172.19.58.172&type=Video";
    [self parseXMLFileAtURL:path];
    [tableView reloadData];
    NSLog(@"Returned %@", item);
}

headerLabel = [[UILabel alloc]initWithFrame:CGRectMake(10.0, 270.0, 300.0, 14.0)];
headerLabel.text = @"Latest Videos";
headerLabel.textColor = [UIColor whiteColor];
headerLabel.backgroundColor = [UIColor clearColor];

[self.view addSubview:headerLabel];
}

/* Assign control to Segment Controller */

-(void)segmentClick:(UISegmentedControl *)segmentControl {

if (segmentControl.selectedSegmentIndex == 1){


    if ([item count] == 0) {

        path = @"http://172.19.58.172/Android/GetApprovedList.php?ip=172.19.58.172&type=Image";
        [self parseXMLFileAtURL:path];
        [tableView reloadData];
        headerLabel.text = @"Latest Images";
        NSLog(@"Returned %@",item);
    }
}
else if (segmentedControl.selectedSegmentIndex == 2){
    if ([item count] == 0) {

        path = @"http://172.19.58.172/Android/GetApprovedList.php?ip=172.19.58.172&type=Audio";
        [self parseXMLFileAtURL:path];
        [tableView reloadData];
        headerLabel.text = @"Latest Audios";
        NSLog(@"Returned no items");
        //            [[[segmentedControl subviews]objectAtIndex:2]setTintColor:[UIColor blackColor]];
    }
}
else {
    if ([item count] == 0) {

        path = @"http://172.19.58.172/Android/GetApprovedList.php?ip=172.19.58.172&type=Video";
        [self parseXMLFileAtURL:path];
        [tableView reloadData];
        headerLabel.text = @"Latest Videos";
        NSLog(@"Returned %@", item);
    }        
    //        [[[segmentedControl subviews]objectAtIndex:0]setTintColor:[UIColor blackColor]];
  }
}

#pragma mark Table View Data Source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
   NSLog(@"this is returned %@", item);
return item.count;
}

- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}

int feed = [indexPath indexAtPosition:[indexPath length] - 1];
cell.textLabel.text = [[item objectAtIndex:feed]objectForKey:@"title"];
cell.detailTextLabel.text = [[item objectAtIndex:feed]objectForKey:@"description"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}

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

NSString *moviePath = [self.item objectAtIndex:indexPath.row];
NSURL *movieURL = [NSURL fileURLWithPath:moviePath];
NSLog(@"Item has %@", movieURL);
playerController = [[MPMoviePlayerController alloc]initWithContentURL:movieURL];
[playerController play];

//    MediaPlayerViewController *mediaView = [[MediaPlayerViewController  alloc]initWithNibName:@"MediaPlayerViewController" bundle:nil];
//    [self presentModalViewController:mediaView animated:YES];

}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

    if (buttonIndex == 0) {
    shareAlert = [[UIActionSheet alloc]initWithTitle:@"Share to" delegate:self cancelButtonTitle:@"Cancel"     
 destructiveButtonTitle:@"Facebook" otherButtonTitles:@"Twitter", nil];
    [shareAlert showInView:self.view];
  }
  else if (buttonIndex == 1){
    NSLog(@"button 2");
  }
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 1) {
    TwitterViewController *twitterController = [[TwitterViewController alloc]initWithNibName:@"TwitterViewController" bundle:nil];
    [self presentModalViewController:twitterController animated:YES];

  }
}

-(void)moviePlayBackDidFinish:(NSNotification *)notification{
MPMoviePlayerController *moviePlayerController = [notification object];
[moviePlayerController.view removeFromSuperview];
[moviePlayerController release];
}

- (void)viewDidUnload
{
  [super viewDidUnload];
  // Release any retained subviews of the main view.
  // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
  // Return YES for supported orientations
  return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

Changed didSelectRow method like following:

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

moviePath = [[item objectAtIndex:indexPath.row]objectForKey:@"link"];
NSLog(@"moviepath has %@", moviePath);
movieURL = [NSURL URLWithString:moviePath];
NSLog(@"movieURL has %@", movieURL);
viewController = [[MPMoviePlayerViewController alloc]initWithContentURL:movieURL];
[self presentMoviePlayerViewControllerAnimated:viewController];

viewController.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
[playerController play];
viewController = nil; 

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayBackDidFinish:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:viewController];

}

- (void) moviePlayBackDidFinish:(NSNotification*)notification {

viewController = [notification object];

[[NSNotificationCenter defaultCenter] removeObserver:self      
                                                name:MPMoviePlayerPlaybackDidFinishNotification
                                              object:viewController];

if ([viewController respondsToSelector:@selector(setFullscreen:animated:)])
{
    [viewController.view removeFromSuperview];
}

}

Now, on selecting any row a blank screen is coming and the application gets stuck there. Video is not played

Any help in this regard is appreciated.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:17:53+00:00Added an answer on May 29, 2026 at 5:17 am

    By looking at you code what i can tell you is that you dont have to reallocate your item object.

    If you have allocated your item object somewhere in the class and stored the values in it then do not reallocate it again as you did here:

    item = [[NSMutableArray alloc]init];
    NSString *moviePath = [item objectAtIndex:indexPath.row];
    

    by reallocating it you are allocating a new memory to it and in the new memory there is no objects present.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm giving my first steps on Python. I saw that we don't have switch
I'm running a piece of code within a web page that queries the IIS
To dynamically fill DropDown controls on my HTML Form, I have written code that
I am working on some code that scrapes a page for two css classes
I have a block of code that generally works fine except when big lumps
I've got some JSON data that is giving me a list of languages with
So, I have a code, that compiled on MSVC 9 and some previous (dunno
Giving a URL to the TOpenFileDialog, the Execute method throws an exception: OpenDialog1.Filename :=
Update: giving a much more thorough example. The first two solutions offered were right
People keep giving me examples with carp instead of warn. Why? What makes carp

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.