this.pause();
});
},
- removeAllVideos: function () {
- var $this = this;
- this.getActivePlayers().forEach(function (player) {
+ removeAllVideos: function (skipPopupVideos) {
+
+ // Videos contained inside a popup #view element are in a separate section of the DOM
+ // so they normally don't need to be removed. They are handled by the killVideosIn() function
+ skipPopupVideos = skipPopupVideos || true;
+
+ var $this = this,
+ playersToBeRemoved = this.getActivePlayers();
+
+ if (skipPopupVideos) {
+ // Filter out any videos that exist inside the #view element
+ playersToBeRemoved = playersToBeRemoved.filter(function (player) {
+ return ! $.contains(document.getElementById('view'), document.getElementById(player.id()));
+ });
+ }
+
+ // Remove video players
+ playersToBeRemoved.forEach(function (player) {
$this.disposeVideo(player);
});
},