0

我尝试使用此代码在服务器上播放视频。我有一个错误。

//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]];
4

1 回答 1

0

aVideo.urlVideo 不是有效的 URL 字符串。它是 nil 的 NSURL。

于 2010-05-11T23:25:32.060 回答