I am working on determining if an event is live by reading from an XML file http://www.calvaryccm.com/ServiceTimes.asmx/IsServiceTime.
It returns a boolean result, but I cannot figure out how to access it using objective-c. This is what I have so far:
NSError * error = nil;
NSString * responseString = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.calvaryccm.com/ServiceTimes.asmx/IsServiceTime"] encoding:NSUTF8StringEncoding error:&error];
NSLog(responseString);
if (error) {
NSLog(@"%@", [error localizedDescription]);
}
if ([responseString isEqualToString:@"true"]) {
// Handle active content.
NSString *baseVideoUrl = @"http://streaming5.calvaryccm.com:1935/live/iPhone/playlist.m3u8";
NSLog(@" finalUrl is : %@",baseVideoUrl);
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:baseVideoUrl]];
if ([moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {
// Use the 3.2 style API
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
}
} else {
// Inform user that the content is unavailable
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle: @"Live Service"
message: @"There is no service going on at this time"
delegate: nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
Firstly your NSLog statement should be:
This will properly log out the response String, you will then get this value back (I just tried it):
Your response String is not equal to true because it is the fully qualified XML String representation. You need to either search the String, you could do this by looking for if it contains the text “true” or “false”.
Alternatively you can use a lightweight XML solution like GDataXMLNode