MediaElement.js 知道播放器何时进入全屏
我需要在每次播放器进入全屏(或从全屏退出)时进行检查,换句话说,我需要在触发全屏方法时监听自定义事件,以便我可以执行下面的其他操作。
i need check every time player goes fullscreen (or goes out from fullscreen), in other words, i need to listen to a custom event when the fullscreen method is triggered so i can do other things below.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在初始化 MediaElement 之前,您需要添加以下代码:
You'll need to add this bit of code before initializing MediaElement:
实际上,打开全屏模式时会调度一个“enteredfullscreen”事件。但是,此事件不是在
mediaElement
上调度的,而是在player
上调度的。您可以在启动播放器后附加事件侦听器:
或使用
success
回调函数(只需添加player
作为第三个参数):Actually, there is an
"enteredfullscreen"
event being dispatched when opening the fullscreen mode. However, this event is not being dispatched on themediaElement
, but on theplayer
.You can either attach the event listener after initiating the player:
or use the
success
callback function (just add theplayer
as the third argument):我也试图找到解决这个问题的方法。我的解决方案是观察 Mediaelement 播放器对象的
isFullScreen
属性是否发生变化。示例代码:
I tried to find a solution to this problem as well. My solution is to watch the
isFullScreen
property of the Mediaelement player object for changes.Sample code: