本文介绍了嵌入式视频在UIView中使用iPhone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想编写一个应用程序,在视图中下载(或流式传输)视频(根据需要进行编码)。我不想使用SDK中的MPVideoPlayer,因为它会全屏打开视频。我想在视频上放置另一个UIView(透明),以便我的用户可以对视频进行注释。
I would like to write an app that downloads (or streams) a video (encoded as required) in a view. I dont want to use the MPVideoPlayer from the SDK as it opens the video in full screen. I would like to place another UIView (transparent) over the video so that my users can annotate over the video.
任何人都有任何想法或者可以指出我的一些代码将在UIView中播放视频吗?
Anyone have any idea or can point me to some code that will play video in a UIView?
推荐答案
试试这个:
UIViewController *v = [[UIViewController alloc] init];
v.view.backgroundColor = [UIColor orangeColor];
NSString *path = [[NSBundle mainBundle] pathForResource:@"demo" ofType:@"mp4"];
if (![[NSFileManager defaultManager] fileExistsAtPath:path])
{
NSLog(@"cannot find %@ in bundle or doctuments", path);
}
NSURL *url = [NSURL fileURLWithPath:path];
MoviePlayerViewController *mpvc = [[MoviePlayerViewController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:mpvc.moviePlayer];
mpvc.moviePlayer.fullscreen = NO;
[mpvc.moviePlayer setControlStyle:MPMovieControlStyleNone];
mpvc.moviePlayer.view.frame = CGRectMake(10, 100, 300, 300);
[v.view addSubview:mpvc.moviePlayer.view];
[mpvc.moviePlayer play];
[self presentModalViewController:v animated:YES];
[v release];
这篇关于嵌入式视频在UIView中使用iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!