将按钮或UIView放在视频顶部



是否可以在视频顶部使用uibutton/uiview?基本上,我想有一个屏幕(UIVIew),上面有按钮。所以,视频会按原样播放,用户可以用按钮执行操作/uiew

我的视频文件是mov格式的

试试这个。。。

 - (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];
 }

尝试[player.view addSubview:button],其中播放器是MPMoviePlayerController实例。

你可以试试这个:

视频放置mp4文件视频.mp4

CSSstyle.css

 #video{ position: relative; }
.myButtons a{  position: absolute; right: 10px;
    border: 1px solid blue; display: block; background: #FFF; 
    z-index: 2147483647;
} 

HTML/PHPindex.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进行,它将使您不断更新。

最新更新