我想播放视频(如果视频不存在,则显示图像)喜欢Instagram?



我想在UITableViewCell中播放视频,如Instagram.如果没有视频,那么它必须显示与Instagram功能相同的图像。但我不知道该怎么做。

我下载了AWEasyVideoPlayer,但它对我没有帮助,

请帮我 或者分享一些演示,以便我了解这一点。 提前谢谢。

我已经使用此代码完成了此功能。

if (videoavailable) {
cell.Videoplayview.hidden=YES;
[cell.ImageUploadedimageview sd_setImageWithURL:[NSURL URLWithString:[[allpostdataarray objectAtIndex:indexPath.section] objectForKey:@"post_image"]] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];

}else{
cell.Videoplayview.hidden=NO;
NSString *path = [[allpostdataarray objectAtIndex:indexPath.section] objectForKey:@"post_video"];
NSURL *videoURL = [NSURL URLWithString:path];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[moviePlayer.view setFrame:CGRectMake(0,0, cell.ImageUploadedimageview.frame.size.width , cell.ImageUploadedimageview.frame.size.height)];
[moviePlayer prepareToPlay];
[moviePlayer play];
[cell.Videoplayview addSubview:moviePlayer.view];

}

如果您确实尝试了某些方法,我们可以指导您朝着正确的方向前进或帮助您解决一些困难。因为您没有发布任何代码,所以这里有一个关于类似 Instagram 的应用程序的教程。它有点过时了,但它引导我朝着正确的方向前进,希望它也能帮助你。

https://www.raywenderlich.com/13511/how-to-create-an-app-like-instagram-with-a-web-service-backend-part-12

Ray Wenderlich 以 Objective-C 和 Swift 中非常好的教程而闻名。

最新更新