在我的项目中,我必须显示videos
来自JSON
的回复,其形式为网址(" http://eyeforweb.info.bh-in-15.webhostbox.net/myconnect/index.php?do=/video/63/video-videovideo/")
问题是,当我想在UIWebView
中显示它时,它什么也没有显示,当我尝试第二种方法时,我得到相同的结果
请帮我展示和播放视频
目前我正在使用以下代码:
NSURL *streamURL = [NSURL URLWithString:@"http://eyeforweb.info.bh-in-15.webhostbox.net/myconnect/index.php?do=/video/63/video-videovideo/"];
_streamPlayer = [[MPMoviePlayerController alloc] initWithContentURL:streamURL];
// depending on your implementation your view may not have it's bounds set here
// in that case consider calling the following 4 msgs later
[self.streamPlayer.view setFrame: CGRectMake(15, 75, VidScroll.frame.size.width-30, 300)];
self.streamPlayer.controlStyle = MPMovieControlStyleEmbedded;
[VidScroll addSubview: self.streamPlayer.view];
[self.streamPlayer play];
答案 0 :(得分:1)
看起来你得到了html而不是视频的网址(正如你所提到的,JSON
)。
为了您的方便,我得到了视频的网址: d607c47e50827b3a90e3a24442c72dae.flv
答案 1 :(得分:1)
通过打印streamPlayer的长度进行检查,看看你是否真的在加载视频。
代码示例:(未经测试)
NSData* data = [NSData dataWithContentsOfURL:streamURL options:NSDataReadingUncached error:&error];
if (error) {
NSLog(@"%@", [error localizedDescription]);
} else {
NSLog(@"Data has loaded successfully.");
NSLog(@"Bytes %ld",data.count);
}
否则等待几秒钟/在加载视频时收到通知。视频可能没有到达。