我尝试使用此代码在服务器上播放视频。我有一个错误。
//Play the video from server
- (IBAction)playVideo:(id)sender;
{
NNSURL *url = [[NSURL alloc]initWithString: aVideo.urlVideo];
NSLog(@"URLVIDEO %@", url);
MPMoviePlayerController *VideoPlayer = [[MPMoviePlayerController alloc]initWithContentURL: url];
[VideoPlayer play];
}
//控制台
URLVIDEO http://147.83.74.180/videos/low/ElTemps-index.m3u8
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Content URL must not be nil.'
aVideo.urlVideo在Video类上定义,当我解析xml文件时它获取一个值
//Video.h
NSString urlVideo;
//XMLParser.m
[aVideo setValue:currentElementValue forKey:elementName]; //here i add the string
如果我这样做,我可以播放视频:
NSString *videoURL = @"http://147.83.74.180/videos/low/ElTemps-index.m3u8";
MPMoviePlayerController *VideoPlayer = [[MPMoviePlayerController alloc]initWithContentURL:[NSURL URLWithString:videoURL]];
答案 0 :(得分:0)
aVideo.urlVideo不是有效的网址字符串。 NSURL是零。