[LayaAir 1.0]iframe页面嵌套下失焦(焦点在父窗口被聚焦),playMusic背景音乐播放无声音

public static function playSound(url:String, loops:int = 1, complete:Handler = null, soundClass:Class = null, startTime:Number = 0):SoundChannel {
if ((!_isActive && loops != 0) || !url) return null;
if (_muted) return null;
_recoverWebAudio();
url = URL.formatURL(url);
if (url == _tMusic) {
if (_musicMuted) return null;
} else {
if (Render.isConchApp) {
var ext:String = Utils.getFileExtension(url);
if (ext != "wav" && ext != "ogg") {
alert("The sound only supports wav or ogg format,for optimal performance reason,please refer to the official website document.");
return null;
}
}
if (_soundMuted) return null;
}
var tSound:Sound;
if (!Browser.onMiniGame)
{
tSound= Laya.loader.getRes(url);
}
if (!soundClass) soundClass = _soundClass;
if (!tSound) {
tSound = new soundClass();
tSound.load(url);
if (!Browser.onMiniGame)
{
Loader.cacheRes(url, tSound);
}
}
var channel:SoundChannel;
channel = tSound.play(startTime, loops);
if (!channel) return null;
channel.url = url;
channel.volume = (url == _tMusic) ? musicVolume : soundVolume;
channel.completeHandler = complete;
return channel;
}
AS 版本修改playSound方法如上,主要改动字体加粗部分;增加条件 loops != 0 (一般为0是背景音乐)排除背景音乐。
原因可能是laya播放音频时,焦点不在stage上,然后被!_isActive = false 这个条件return了。
 
版本 1.7.20
 
其他影响尚未清楚,自行斟酌
已邀请:

Aar0n

赞同来自:

           

要回复问题请先

商务合作
商务合作