video 元素单击全屏播放

本文介绍了一个使用AngularJS实现的视频播放器,该播放器支持鼠标悬停预览和单击全屏播放功能。通过JavaScript操作DOM元素,实现对视频的播放控制和全屏效果,为用户提供更好的交互体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 angular.js 

<div ng-click="Fn.play(item.id)" id="{{item.id}}" ng-mouseover="Fn.hover(item.id,'block')" ng-mouseout="Fn.hover(item.id,'none')">
                                <video loop="loop" controls="controls" ng-src="{{item.img}}" width="200px" height="120px">
                                  
                                  </video>
                                <div class="title">{{item.title}}</div>
                                <div class="banner banner1"></div>
                            </div>

 事件

单击全屏播放

                play: function (v) {


                    var video = document.getElementById(v).children[0];
                    var button = document.getElementById(v).children[2];

                    if (video.paused) {
                        if (video.requestFullscreen) {
                            video.requestFullscreen();
                        } else if (video.mozRequestFullScreen) {
                            video.mozRequestFullScreen();
                        } else if (video.webkitRequestFullScreen) {
                            video.webkitRequestFullScreen();
                        }
                        video.play();
                        button.style.display = "none";
                    } else {
                        if (video.exitFullscreen) {
                            video.exitFullscreen();
                        } else if (video.mozCancelFullScreen) {
                            video.mozCancelFullScreen();
                        } else if (video.webkitCancelFullScreen) {
                            video.webkitCancelFullScreen();
                        }
                        video.pause();
                        button.style.display = "block";
                    }


                },
                hover: function (id, value) {

                    var video = document.getElementById(id).children[0];
                    var button = document.getElementById(id).children[2];
                    if (video.paused) {
                        button.style.display = value;
                    }

                },

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值