更新时间:2023-09-02 20:53:52
这里的问题是玩家不是未定义。发生了什么事情,你有一个全球玩家参考,你正在做以下事情:
The problem here is player is NOT undefined. What's happening is you have a global player reference, and you're doing the following with it:
目前,播放器
包含对您最后一位***播放器的引用即使该玩家已经被摧毁,也可以使用is。
Currently, player
holds a reference to whatever the last *** player you were using is, even if that player has already been destroyed.
你应该做的是在你摧毁它时清除对玩家的引用。毁灭不会(也不可能)这样做。您还可以简化if条件,因为!player
将自行检查null和undefined:
What you should be doing is clearing out your reference to the player when you destroy it. Destroy won't (and can't) do that. You can also simplify your if condition since !player
will check for null and undefined on its own:
var resetView = function() {
// If a *** player is active, make sure we stop it.
if (!player) {
console.log("Player could not be found.");
} else {
player.stopVideo();
player.destroy();
player = null; // Clear out the reference to the destroyed player
}