1. Hey! Guest! The 32nd GMC Jam will take place between Feb 22nd, 12:00 UTC (Friday noon) and Feb 25th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

HTML5 No sounds at all when exporting to HTML5

Discussion in 'GameMaker Studio 2 Community Tech Support' started by Shy Lev-Ari, Jan 18, 2019.

  1. Shy Lev-Ari

    Shy Lev-Ari Member

    Joined:
    Dec 29, 2018
    Posts:
    13
    So I just bought the HTML5 license..

    ...and OMG my game is so bad. So many bugs ahhhhhhh.

    First item on the list - no sound, at all. What is going on?
     
  2. BaBiA Game Studio

    BaBiA Game Studio Member

    Joined:
    Jun 20, 2016
    Posts:
    672
    You're probably going to have to give us a bit more info. How are you trying to play your sounds? Have you added them to the IDE and can you play them through the preview in the IDE? Maybe some of your other bugs are causing problems affecting the sounds?

    More info please.
     
  3. Cowlord

    Cowlord Member

    Joined:
    Jun 29, 2017
    Posts:
    54
    There are problems with audio in HTML5. Go into the compression settings or whatever it is called and try every setting until one works.
     
  4. chmod777

    chmod777 Member

    Joined:
    Aug 26, 2016
    Posts:
    167
    More and more browsers (including desktops) require a user interaction (click or touch) before audio can be played as expected, so that might be the issue.
     
    Michael Bateman likes this.
  5. Michael Bateman

    Michael Bateman Member

    Joined:
    Jun 25, 2016
    Posts:
    228
    Likely this. No independent click from user to agree to sound; no sound will play.
     
  6. Shy Lev-Ari

    Shy Lev-Ari Member

    Joined:
    Dec 29, 2018
    Posts:
    13
    Holy meatballs! That was it..
    I "clicked" and.. sound. What the what?!

    Ok so my game is keyboard only.. Do i do an ugly "click to start"? can i emulate a mouse click with the keyboard? Is there a setting i need to turn on?

    BTW I'm test running the game (clicking the PLAY button, building for HTML5, which opens my chrome in a new tab)
     
  7. Kyon

    Kyon Member

    Joined:
    Jun 27, 2016
    Posts:
    410
    On your site it should load the game a few frames after loading the page.
    Browsers don't like sound to be played directly when someone opens a page. You can't edit this within gamemaker.
    Maybe make a "Play" button or something in your game, that could fix it.
    Or what I said before, load it a second later or so, might work.
     
  8. Shy Lev-Ari

    Shy Lev-Ari Member

    Joined:
    Dec 29, 2018
    Posts:
    13
    I plan on uploading it to GameJolt and/or NewGround. Do they do what you say? Do you recommend other such places? I don't have a website of my own I ca upload this too.
     
  9. chmod777

    chmod777 Member

    Joined:
    Aug 26, 2016
    Posts:
    167
    The "Play" button is certainly the best option.
    But you can try to add this piece of code in an extension (not tested but this might work):
    Code:
    document.addEventListener("keyup", function() {
       if(window.AudioContext && g_WebAudioContext && g_WebAudioContext.state == "suspended") {
           g_WebAudioContext.resume();
       }
    }, false);
     
  10. Shy Lev-Ari

    Shy Lev-Ari Member

    Joined:
    Dec 29, 2018
    Posts:
    13

    Umm I've never used extensions before. Tried to jus t "create new extension' and copy paste it, but doesn't seem to be formated that way. What do I do with this code please? :)
     
  11. chmod777

    chmod777 Member

    Joined:
    Aug 26, 2016
    Posts:
    167
    You need to create a .js file from a text editor like Notepad++ with the above code inside. Then you just have to create an extension in GameMaker and adds the JS file in it.
     
  12. Shy Lev-Ari

    Shy Lev-Ari Member

    Joined:
    Dec 29, 2018
    Posts:
    13
    haha yes! almost :)

    Audio is working, only after the second keystroke is released (any key stroke).

    Tried adding a simulated keystroek, but it didn't help.

    I have a "splash" screen with no sound, and it then moves to a second room with the menu. There is supposed to be music playing right away, but it doesn't at all (untill you return to the main menu from the main game room, i.e. when you go "bac" one room, and the room of the menu retsrats).

    If this is the best we can do, i'll take it. I hope it is not, but I don't understand the JS code to alter it :)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice