是否可以在视频之上使用uibutton / uiview? 基本上,我想要一个屏幕(UIVIew),上面有按钮。因此,视频将按原样播放,用户可以使用buttons / uiview
执行操作我的视频文件采用mov格式
答案 0 :(得分:2)
试试这个...
- (void)playVideoInLoopMode:(BOOL)loop
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"myvideo" ofType:@"m4v"]];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:url];
mp.controlStyle = MPMovieControlStyleNone;
if (loop)
{
mp.repeatMode = MPMovieRepeatModeOne;
}
mp.view.frame = CGRectMake(0.0, 0.0, self.view.bounds.size.width, self.view.bounds.size.height);
self.player = mp;
[self.view addSubview:self.player.view];
image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myimage.png"]];
image.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[self.player addSubview:image];
[self.player prepareToPlay];
[self.player play];
}
答案 1 :(得分:0)
尝试[player.view addSubview:button]
其中player是MPMoviePlayerController实例。
答案 2 :(得分:0)
你可以试试这个:
视频强> 放置一个mp4文件video.mp4
<强> CSS 强> 的style.css
#video{ position: relative; }
.myButtons a{ position: absolute; right: 10px;
border: 1px solid blue; display: block; background: #FFF;
z-index: 2147483647;
}
<强> HTML / PHP 强> 的index.php
<!DOCTYPE HTML>
<html>
<head>
<title>Title Here</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!--[if lte IE 8]><script src="assets/js/ie/html5shiv.js"></script><![endif]-->
<script src="js.js"></script>
<link rel="stylesheet" href="style.css" />
<!--[if lte IE 9]><link rel="stylesheet" href="assets/css/ie9.css" /><![endif]-->
<!--[if lte IE 8]><link rel="stylesheet" href="assets/css/ie8.css" /><![endif]-->
</head>
<body>
<div id="video">
<video width="100%" src="video.mp4" controls></video><br><br/>
<div class="myButtons">
<?php
$i=1;
echo "<a href=\"#\" style=\"top:0px\">btn-primary</a>";
$j = 30*$i;
echo "<a href=\"#\" style=\"top:$j"."px\">btn-primary</a>";
$j = 30*++$i;
echo "<a href=\"#\" style=\"top:$j"."px\">btn-primary</a>";
$j = 30*++$i;
echo "<a href=\"#\" style=\"top:$j"."px\">btn-primary</a>";
?>
</div>
</div>
<style>
button{
display: block;
margin-top: 10px;
}
</style>
</body>
</html>
我面临的唯一问题是,在全屏显示的手机上,按钮消失了......任何有iOS / Android解决方案的人?
下一个要执行的测试是使用jwPlayer进行,会让你保持更新。