简体   繁体   English

Android上的HTML5声音问题

[英]HTML5 sound problems on Android

I was trying to compile my Android app with HTML5 that I created using Construct 2. I followed all the steps but the game didn't have sound. 我正在尝试使用通过Construct 2创建的HTML5编译我的Android应用。我遵循了所有步骤,但是游戏没有声音。 I tried to find many ways to solve the problem but I didn't find any solutions. 我试图找到许多解决问题的方法,但没有找到任何解决方案。 I didn't use HTML5 audio tags or anything similar, and I tried to change the Javascript code to provide access to the audio but I failed. 我没有使用HTML5音频标签或类似标签,但尝试更改Javascript代码以提供对音频的访问权限,但失败了。 The files are here: HTML5 Game . 文件在这里: HTML5 Game

Can't actually get at the files but here's a pure JS solution to playing sounds: 实际上无法获取文件,但这是播放声音的纯JS解决方案:

var sound = new Audio("audio/sound.wav");
var sound2 = new Audio("audio/othersound.wav");
sound.volume = 12;
sound.play();

Should be pretty self-explanatory. 应该很不言自明。 Create an Audio object and call play() to play it. 创建一个Audio对象,然后调用play()进行播放。

When you import your sounds into Construct you have to import all three types (WAV, MP3, OGG). 当您将声音导入到Construct中时,您必须导入所有三种类型(WAV,MP3,OGG)。 Then Construct will use the correct one for the platform. 然后,Construct将使用正确的平台。 On Android I have only had the OGG files work on my Construct 2 games. 在Android上,我只能在自己的Construct 2游戏中使用OGG文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM