如何停止在 Twitter Bootstrap 模型上播放 Youtube 视频 关闭 [英] How to stop a Youtube Video Playing on Twitter Bootstrap Model Close

查看:27
本文介绍了如何停止在 Twitter Bootstrap 模型上播放 Youtube 视频 关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何停止多个 Youtube 视频在 Twitter Bootstrap 模型上的播放关闭?

How do stop a multiple Youtube Video's Playing on Twitter Bootstrap Model Close?

这就是我所拥有的......当我只有一个视频时它工作正常......

This is what I have... When I have just one video it works fine...

var player = document.getElementById('MjXAo2qxMlA'); //save the object or embed youtube video in a variable
$('#ttvideoModalTwo').on('hide', function () {
  player.stopVideo();
})

var player = document.getElementById('zXscUitXHPc'); //save the object or embed youtube video in a variable
$('#ttvideoModalOne').on('hide', function () {
  player.stopVideo();
})

推荐答案

根据 API,您可以通过 $.stopVideo() 函数来停止播放视频,包括在您的 $.stopVideo() 函数中code>modal('hide') 方法,一旦模态关闭,您应该能够停止视频,如下所示:

According to the API you can pass the $.stopVideo() function to stop the video from playing, include that inside your modal('hide') method and you should be able to stop the video once the modal is closed, like so:

JS

var player = document.getElementById('objectId'); //save the object or embed youtube video in a variable
$('#myModal').on('hide', function () {
  player.stopVideo();
})

Youtube API 文档

这篇关于如何停止在 Twitter Bootstrap 模型上播放 Youtube 视频 关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆